Exemplo n.º 1
0
            def make_box(text, **kwargs):
                text = pytality.buffer.RichText(text.strip(), initial_color=pytality.colors.WHITE, x=1, y=1)

                item = clickable.ClickableBox(
                    height=text.height + 4,
                    width=text.width + 4,
                    children=[text],
                    boxtype=pytality.boxtypes.BoxSingle,
                    border_bg=pytality.colors.BROWN, border_fg=pytality.colors.LIGHTGREY,
                    interior_bg=pytality.colors.BLACK, interior_fg=pytality.colors.BLACK,
                    hover_interior_bg=pytality.colors.BLACK, hover_interior_fg=pytality.colors.BLACK,
                    hover_border_bg=pytality.colors.BROWN, hover_border_fg=pytality.colors.YELLOW,
                    on_mouse_down=self.tutorial_dismiss,
                    **kwargs
                )
                clickable.register(item)
                self.tutorial_items.append(item)
Exemplo n.º 2
0
    def test_boxes(self):
        import game
        game.mode = 'test'
        root = pytality.buffer.Buffer(width=0, height=0)
        for i, cls in enumerate(all_types):
            p = cls(x=1 + i*17, y=20)
            clickable.register(p)
            root.children.append(p)

        @event.on('test.tick')
        def on_tick():
            for child in root.children:
                child.tick()

        @event.on('test.draw')
        def on_draw():
            root.draw()

        game.start()
Exemplo n.º 3
0
    def load_option(self, key):
        log.debug("loading option %r", key)
        option = options[key]
        self.root.children = [hero.stat_display, self.frame_l, self.frame_r]
        self.choice_items = []

        self.root.children.append(pytality.buffer.RichText(option.text, **option.text_kwargs))
        for choice_settings in option.choices:
            kwargs = dict(choice_settings)
            kwargs.update(option.choice_kwargs)
            choice = Choice(adventure=self, **kwargs)

            #if 'y' in option.choice_kwargs:
            #    option.choice_kwargs['y'] += choice.height + 1

            self.choice_items.append(choice)
            clickable.register(choice)
            self.root.children.append(choice)

        self.root.dirty = True
Exemplo n.º 4
0
    def tick(self):
        if self.next_card_in and not self.dungeon.level.active_monster:
            # and don't interact with the timer in combat
            # dont quite finish the timer if we're full
            if self.next_card_in > 5 or None in self.cards:
                self.next_card_in -= 1

        if self.next_card_in <= 0 and None in self.cards:
            slot = self.cards.index(None)
            card_cls = self.pick_card()
            log.debug("Creating new card in slot %r, class is %r", slot, card_cls)
            card = card_cls(parent=self, x=(1 + slot * 17), x_offset=self.x + self.padding_x, y_offset=self.y + self.padding_y)

            self.children.append(card)
            clickable.register(card)
            self.cards[slot] = card

            self.next_card_in = self.card_delay
        for card in self.cards:
            if card:
                card.tick()
Exemplo n.º 5
0
    def show_dialog(self, source, text, next_state, state_delay=None):
        if source == "hero":
            portrait = self.hero_portrait
            title = "Altrune The Bold"
        else:
            portrait = self.boss_portrait
            if self.real_boss:
                title = "World-Devourer"
            else:
                title = "Skulltaker"

        portrait.x = 1
        portrait.y = 1
        title_buffer = pytality.buffer.PlainText(
            title.center(portrait.width),
            fg=pytality.colors.WHITE
        )
        title_buffer.x = 1
        title_buffer.y = 13

        text_buffer = ClickableText(
            message=text,
            x=19,
            x_offset=self.action_window.x,
            y_offset=self.action_window.y + 1,
            on_mouse_down=self.dismiss_dialog
        )
        text_buffer.y = (self.action_window.inner_height - text_buffer.height - 2) / 2
        text_buffer.children = [pytality.buffer.PlainText(
            "[ Click To Continue ]",
            center_to=text_buffer.width,
            y=text_buffer.height + 2,
            fg=pytality.colors.WHITE,
        )]
        text_buffer.next_state = next_state
        text_buffer.state_delay = state_delay
        clickable.register(text_buffer)

        self.action_window.children = [self.action_window.title, portrait, title_buffer, text_buffer]
        self.action_window.dirty = True
Exemplo n.º 6
0
    def offer_choices(self, choices):

        if self.real_boss:
            self.pending_attack_type = random.choice(["phys", "magic"])
            self.pending_attack_powerful = random.choice([False, True])
            text = "<LIGHTMAGENTA>" + random.choice([
                "GRAAAALRGLARGLARLGALRLLALGLLLALLLGLLALGLLAGRLRLALBLBBALGBLBALGBLBLABLAGLALALFL",
                "GLOORPAAAARPLLALARALRALAPAPRLAPARLALAPRALLPARPAAAAARLPALAAALPALLPALPALPALAAAPL",
                "AAAGLGLGLAPRALGPALRAPLAGAAAAARGAGLAGPARALPAAAALPGLARAPLAGAAAALRLPARLPAALAAAALL",
            ] + [
                ''.join(random.choice('GLARB') for _ in range(80))
                for __ in range(5)
            ]
            )
            self.show_dialog("you", text, "boss_attack", 0)
            return

        self.choice_boxes = []
        self.action_window.children = [
            self.action_window.title,
            pytality.buffer.PlainText(
                message="Respond With:",
                center_to=self.action_window.width,
                y=1,
                fg=pytality.colors.WHITE,
            )
        ]
        box_width = 40
        power_attack = random.choice([0, 1])
        for i, choice in enumerate(choices):
            attack_type = random.choice(["phys", "magic"])
            attack_powerful = (i == power_attack)

            box_children = [
                pytality.buffer.RichText(choice['title'].center(box_width-2), y=1, x=0),
            ]
            if attack_type == "phys":
                box_children.append(pytality.buffer.PlainText("Physical Attack", fg=pytality.colors.LIGHTMAGENTA, center_to=box_width-2, y=3, x=0))
            else:
                box_children.append(pytality.buffer.PlainText("Magical Attack", fg=pytality.colors.YELLOW, center_to=box_width-2, y=3, x=0))

            if attack_powerful:
                box_children.append(pytality.buffer.PlainText("Powerful", fg=pytality.colors.RED, center_to=box_width-2, y=4, x=0))

            choice_box = clickable.ClickableBox(
                width=box_width, height=8,
                x=8 + 47 * i, y=3,
                x_offset=self.action_window.x,
                y_offset=self.action_window.y + 1,
                boxtype=pytality.boxtypes.BoxSingle,
                border_fg=pytality.colors.DARKGREY,
                children=box_children,
                on_mouse_down=self.box_clicked
            )
            choice_box.choice = choice

            choice_box.attack_type = attack_type
            choice_box.attack_powerful = attack_powerful

            self.choice_boxes.append(choice_box)
            clickable.register(choice_box)
            self.action_window.children.append(choice_box)

        self.action_window.dirty = True