Exemplo n.º 1
0
    def __init__(self):
        clickable.unregister_all()
        hero.stat_display.set_mode("adventure")

        self.root = pytality.buffer.Buffer(height=main.screen_height, width=main.screen_width - main.sidebar_width)
        self.frame_l = data.load_buffer("frame-l.ans", width=80, crop=False)
        self.frame_r = data.load_buffer("frame-r.ans", width=49, crop=True)
        self.frame_r.x = 80
        self.i = 0
Exemplo n.º 2
0
 def __init__(self, **kwargs):
     super(MoraleMeter, self).__init__(width=19, height=16, **kwargs)
     self.base = data.load_buffer('meter.ans', width=6, crop=True)
     self.meter = data.load_buffer('meter.ans', width=6, crop=True)
     self.title = pytality.buffer.PlainText("HERO MORALE", y=-2, fg=pytality.colors.WHITE, center_to=self.width)
     self.text_lines = [
         pytality.buffer.RichText("<%s>- DESPONDENT\n  <%s>-10%% stats</>", x=5, y=13),
         pytality.buffer.RichText("<%s>- APATHETIC\n  <%s>-5%% stats</>", x=5, y=10),
         pytality.buffer.RichText("<%s>- DRIVEN\n  <%s></>", x=5, y=7),
         pytality.buffer.RichText("<%s>- HEROIC\n  <%s>+10%% stats</>", x=5, y=4),
         pytality.buffer.RichText("<%s>- HOT BLOODED\n  <%s>+20%% stats</>", x=5, y=1),
     ]
     self.children = [self.title, self.meter] + self.text_lines
     self.last_value = None
     self.i = 0
Exemplo n.º 3
0
 def __init__(self, width=16, height=16, crop=True, file_names=None, anim_delay=5, **kwargs):
     super(BattleSprite, self).__init__(width=width, height=height, **kwargs)
     self.sprites = [data.load_buffer(file_name, width=width, crop=crop, max_height=height) for file_name in file_names]
     self.overlay = overlay.Overlay(width=width, height=width, x=0, y=0)
     self.children = [self.sprites[0], self.overlay]
     self.anim_delay = self.anim_timer = anim_delay
     self.anim_index = 0
Exemplo n.º 4
0
def victory_setup():
    global active_text
    pytality.term.clear()
    clickable.unregister_all()
    active_text = pytality.buffer.PlainText(
        "The hero is too demoralized to continue fighting. You lose.",
        y=main.screen_height / 2 + 10,
        center_to=main.screen_width,
        fg=pytality.colors.LIGHTRED,
        children=[data.load_buffer("grave.ans", width=42, x=(main.screen_width - 42) / 2, y=-15, crop=True)],
    )
Exemplo n.º 5
0
def victory_setup():
    global active_text
    pytality.term.clear()
    clickable.unregister_all()
    active_text = pytality.buffer.PlainText(
        "The final boss has been defeated. The world is saved. You win.",
        y=main.screen_height / 2 + 10,
        center_to=main.screen_width,
        fg=pytality.colors.LIGHTGREEN,
        children=[data.load_buffer("earf.ans", width=40, x=(main.screen_width - 40) / 2, y=-30, crop=True)],
    )
Exemplo n.º 6
0
    def __init__(self, parent=None, **kwargs):
        self.portrait = data.load_buffer(self.art_file, width=14, crop=True)

        self.name_text = pytality.buffer.PlainText(self.name, y=11, center_to=14, fg=pytality.colors.WHITE)
        self.line1 = pytality.buffer.PlainText(y=12, center_to=14, **effect_text[self.tags[0]])
        self.line2 = pytality.buffer.PlainText(y=13, center_to=14, **effect_text[self.tags[1]])

        self.overlay = overlay.Overlay(width=16, height=16, x=-1, y=-1)
        self.parent = parent
        self.mode = "in"
        super(MonsterCard, self).__init__(
            width=16, height=16,
            boxtype=pytality.boxtypes.BoxSingle,
            border_fg=pytality.colors.DARKGREY,
            children=[self.portrait, self.name_text, self.line1, self.line2, self.overlay],
            **kwargs
        )
        self.overlay.start("fade_in")
Exemplo n.º 7
0
    def __init__(self, dungeon, final_boss):
        sidebar_width = 26
        bottom_height = 17

        self.message_log = dungeon.message_log
        self.stat_display = dungeon.stat_display
        self.stat_display.set_mode("battle")
        clickable.unregister_all()


        self.battle_window = pytality.buffer.Buffer(
            x=sidebar_width,
            y=0,
            height=main.screen_height - bottom_height,
            width=main.screen_width - (sidebar_width * 2)

        )
        self.action_window = ActionWindow(
            width=main.screen_width - sidebar_width * 2,
            height=bottom_height,
            x=sidebar_width,
            y=main.screen_height - bottom_height,
            border_fg=pytality.colors.LIGHTGREY,
            battle=self,
        )
        self.action_overlay = overlay.Overlay(
            width=self.action_window.width,
            height=self.action_window.height - 1,
            x=0, y=0
        )

        self.real_boss = final_boss
        if self.real_boss:
            self.boss_sprite = BattleSprite(file_names=["finalboss.ans"], width=61, height=48, x=self.battle_window.width - 61, y=0, crop=True)
            self.boss_portrait = data.load_buffer("finalbossport.ans", width=16, crop=True)
            sound.play_music("The_Final_Threat.mp3")
        else:
            self.boss_sprite = BattleSprite(file_names=["you2.ans", "you2alt.ans"], width=34, height=31, x=self.battle_window.width - 40, y=14, crop=True)
            self.boss_portrait = data.load_buffer("youport.ans", width=16, crop=True)
            sound.play_music("OHC_Changeling_Rumble.mp3")

        act = (adventure.World.act - 1)
        self.boss_attack = 6 + (7 * act)
        self.boss_defense = 4 + (7 * act)
        self.boss_hp = self.boss_max_hp = 50 + (20 * act)

        self.hero_sprite = BattleSprite(file_names=[hero.active_hero.get_boss_file()], width=18, height=15, x=10, y=30)
        self.hero_portrait = data.load_buffer("heroportrait.ans", width=16, crop=True)

        self.battle_window.children = [self.boss_sprite, self.hero_sprite]

        self.fullscreen_flash = pytality.buffer.Buffer(
            x=sidebar_width,
            height=main.screen_height,
            width=main.screen_width - (sidebar_width * 2)
        )

        self.root = pytality.buffer.Buffer(height=0, width=0, children=[
            self.message_log,
            self.stat_display,
            self.battle_window,
            self.action_window
        ])
        self.i = 0
        self.flashed = False
        self.message_log.add("\n     <LIGHTRED>BOSS BATTLE!")

        self.next_state = "hero_talk"
        self.after_animation_state = None
        self.state_delay = 5

        self.pending_attack_type = None
        self.pending_attack_powerful = False
Exemplo n.º 8
0
import data
import main
import hero
import message
import monsters
import event
import sound
import clickable

log = logging.getLogger(__name__)

room_map = collections.defaultdict(list)
for file_name in os.listdir(data.data_dir):
    if 'room-' in file_name and '.ans' in file_name:
        prefix, directions, suffix = file_name.split('-', 2)
        room_buf = data.load_buffer(file_name, width=155, crop=True)
        room = Room(buf=room_buf, directions=directions, file_name=file_name)
        room_map[frozenset(directions)].append(room)

next_deltas = dict(
    n=('s', 0, -1),
    s=('n', 0, 1),
    w=('e', -1, 0),
    e=('w', 1, 0),
)
def generate_level(size, **kwargs):
    log.debug("Generating level")
    start_room = random.choice(random.choice([room for key, room in room_map.iteritems() if len(key) == 1]))
    room_count = random.randint(size-2, size+2)
    x = 0
    y = 0
Exemplo n.º 9
0
                    rule.

                    That won't do at all. But the legends also tell of a great and powerful
                    hero, who will rise from humble beginnings to save the world from
                    destruction at the hands of evil. And you know just who the prophecy
                    says is going to be that hero.


\n\n\n\n\n\n\n\n\n\n\n\n
                    This is Altrune. And he doesn't have what it takes to save the world.

                    So you're going to train him to greatness, so he can save it for you.
                    And after that all that's over, well, you can deal with him then.
""",
        text_kwargs=dict(y=7, x=15, initial_color=pytality.colors.BLACK, bg=pytality.colors.WHITE, children=[
            data.load_buffer("youport-white.ans", width=18, max_height=12, crop=True, x=45, y=0),
            data.load_buffer("heroportrait-white.ans", width=18, max_height=12, crop=True, x=45, y=26)
        ]),
        choice_kwargs=dict(
            y=53
        ),
        choices=[
            dict(next="burn_2", text="   OK   ", x=63, y=53),
        ]
    ),
    burn_2=Option(
        text="""
                    Let's start by giving Altrune something to be heroic about.

                    Hero types always get <RED>SO MAD</> when you burn down their villages.
                    And his hometown of Idylburg is looking very flammable today.
Exemplo n.º 10
0
    def __init__(self):
        start = 20

        def line(text, y):
            return pytality.buffer.PlainText(text, y=start + y, center_to=main.screen_width, fg=pytality.colors.BLACK)

        lines = [
            line("It had been prophecied that he should come there.", y=0),
            line("They knew it when the pebbles were being made", y=4),
            line("and before the isles of coral were given unto the sea.", y=8),
            line("And thus the prophecy came unto fulfilment and passed into history...", y=12),
            line("                                                       - Lord Dunsany", y=16),
        ]
        self.i = 0

        color_set = (pytality.colors.DARKGREY, pytality.colors.LIGHTGREY, pytality.colors.WHITE)
        self.stages = []
        at_i = 5
        for line in lines:
            for color in color_set:
                self.stages.append((at_i, line, color))
                at_i += 3
            at_i += 40

        at_i += 15 * 7
        self.visible_i = at_i

        for color in (pytality.colors.LIGHTGREY, pytality.colors.DARKGREY, pytality.colors.BLACK):
            for line in lines:
                self.stages.append((at_i, line, color))
            at_i += 7

        self.end = at_i + 7
        self.reached_end = False
        self.fire_end = None

        self.title_tl_bg = data.load_buffer("itsfullofstars.ans", width=22, crop=True)
        self.title_tr_bg = data.load_buffer("itsfullofstars.ans", width=22, crop=True)
        self.title_tl = data.load_buffer("aswasforet1b-1.ans", width=80, crop=False)
        self.title_tr = data.load_buffer("aswasforet1b-2.ans", width=42, crop=True)
        self.title_bl = data.load_buffer("town1b-1.ans", width=80, crop=False)
        self.title_br = data.load_buffer("town1b-2.ans", width=75, crop=True)

        self.title_bl_fire = data.load_buffer("town1b-1fire.ans", width=80, crop=False)
        self.title_br_fire = data.load_buffer("town1b-2fire.ans", width=75, crop=True)
        self.title_tl.x = 15
        self.title_tr.x = 80 + 15
        self.title_tr_bg.x = main.screen_width - 22

        self.title_bl.y = self.title_bl_fire.y = main.screen_height - self.title_br.height + 1
        self.title_br.y = self.title_br_fire.y = main.screen_height - self.title_br.height + 1
        self.title_br.x = self.title_br_fire.x = 80

        self.start_text = pytality.buffer.PlainText("[ Click To Start ]", fg=pytality.colors.WHITE, y=65 / 2)
        self.start_text.x = (main.screen_width - self.start_text.width) / 2

        self.credits_text = pytality.buffer.RichText(
            "<DARKGREY>  Game By: Jesse Truscott & Joe Gracyk"
            + "                     Art: Devin Vance"
            + "                     Dialog: Dylan Pedersen"
            + "                     Music: Patashu "
        )

        self.root = pytality.buffer.Buffer(height=main.screen_height, width=main.screen_width, children=lines)