Esempio n. 1
0
    def active_action_disp(ilet, skills, rawcards, params, players):
        g = Game.getgame()

        stage = ilet.initiator

        if not skills and not rawcards:
            raise ActionDisplayResult(False, stage.ui_meta.idle_prompt, False, [], [])

        usage = getattr(ilet.initiator, 'card_usage', 'none')

        if skills:
            if any(not g.me.has_skill(s) for s in skills):
                raise ActionDisplayResult(False, u'您不能这样出牌', False, [], [])
            cards = [thbactions.skill_wrap(g.me, skills, rawcards, params)]
            usage = cards[0].usage if usage == 'launch' else usage
        else:
            cards = rawcards

        card = actv_handle_card_selection(g, stage, cards)
        players, disables, prompt = actv_handle_target_selection(g, stage, card, players)

        act = stage.launch_card_cls(g.me, players, card)

        shootdown = act.action_shootdown()
        if shootdown is not None:
            raise ActionDisplayResult(False, shootdown.ui_meta.shootdown_message, True, disables, players)

        raise ActionDisplayResult(True, prompt, True, disables, players)
Esempio n. 2
0
    def active_action_disp(ilet, skills, rawcards, params, players):
        g = Game.getgame()

        stage = ilet.initiator

        if not skills and not rawcards:
            raise ActionDisplayResult(False, stage.ui_meta.idle_prompt, False,
                                      [], [])

        usage = getattr(ilet.initiator, 'card_usage', 'none')

        if skills:
            if any(not g.me.has_skill(s) for s in skills):
                raise ActionDisplayResult(False, u'您不能这样出牌', False, [], [])
            cards = [thbactions.skill_wrap(g.me, skills, rawcards, params)]
            usage = cards[0].usage if usage == 'launch' else usage
        else:
            cards = rawcards

        card = actv_handle_card_selection(g, stage, cards)
        players, disables, prompt = actv_handle_target_selection(
            g, stage, card, players)

        act = stage.launch_card_cls(g.me, players, card)

        shootdown = act.action_shootdown()
        if shootdown is not None:
            raise ActionDisplayResult(False,
                                      shootdown.ui_meta.shootdown_message,
                                      True, disables, players)

        raise ActionDisplayResult(True, prompt, True, disables, players)
Esempio n. 3
0
    def passive_action_disp(ilet, skills, rawcards, params, players):
        g = Game.getgame()

        usage = getattr(ilet.initiator, 'card_usage', 'none')

        if skills:
            if any(not g.me.has_skill(s) for s in skills):
                raise ActionDisplayResult(False, u'您不能这样出牌', False, [], [])
            cards = [thbactions.skill_wrap(g.me, skills, rawcards, params)]
            usage = cards[0].usage if usage == 'launch' else usage
        else:
            cards = rawcards

        cards, prompt_card = pasv_handle_card_selection(g, ilet, cards)
        plsel, disables, players, prompt_target = pasv_handle_player_selection(
            g, ilet, players)

        verify = getattr(ilet.initiator, 'ask_for_action_verify', None)
        rst = not verify or verify(g.me, cards, players)
        if not rst:
            raise ActionDisplayResult(False, rst.ui_meta.shootdown_message,
                                      plsel, disables, players)

        raise ActionDisplayResult(True, prompt_target or prompt_card, plsel,
                                  disables, players)
Esempio n. 4
0
    def handle(self, evt_type, act):
        if evt_type != 'action_after': return act
        if not isinstance(act, LaunchCard): return act

        g = Game.getgame()

        card = act.card
        if not card: return act
        if 'basic' not in card.category: return act
        if card.color != Card.RED: return act

        if card.is_card(VirtualCard):
            rawcards = VirtualCard.unwrap([card])
        else:
            rawcards = [card]

        if not all(c.resides_in is None or c.resides_in.type == 'droppedcard'
                   for c in rawcards):
            return act

        tgt = act.source
        self.target = tgt  # for ui

        if tgt.dead: return act

        for p in g.players:
            if p.dead or p is tgt: continue
            if not p.has_skill(ImperishableNight): continue
            if p is g.current_player: continue

            if not user_input([p], ChooseOptionInputlet(self, (False, True))):
                continue

            cards = user_choose_cards(self, p,
                                      ('cards', 'showncards', 'equips'))

            if cards:
                g.players.reveal(cards)
                skill = skill_wrap(p, [ImperishableNight], cards, {})
                assert skill_check(skill)  # should not fail
                g.deck.register_vcard(skill)
                rst = g.process_action(LaunchCard(p, [tgt], skill))
                assert rst

        return act
Esempio n. 5
0
    def handle(self, evt_type, act):
        if evt_type != 'action_after': return act
        if not isinstance(act, LaunchCard): return act

        g = Game.getgame()

        card = act.card
        if not card: return act
        if 'basic' not in card.category: return act
        if card.color != Card.RED: return act

        if card.is_card(VirtualCard):
            rawcards = VirtualCard.unwrap([card])
        else:
            rawcards = [card]

        if not all(
            c.resides_in is None or c.resides_in.type == 'droppedcard'
            for c in rawcards
        ): return act

        tgt = act.source
        self.target = tgt  # for ui

        if tgt.dead: return act

        for p in g.players:
            if p.dead or p is tgt: continue
            if not p.has_skill(ImperishableNight): continue
            if p is g.current_player: continue

            if not user_input([p], ChooseOptionInputlet(self, (False, True))):
                continue

            cards = user_choose_cards(self, p, ('cards', 'showncards', 'equips'))

            if cards:
                g.players.reveal(cards)
                skill = skill_wrap(p, [ImperishableNight], cards, {})
                assert skill_check(skill)  # should not fail
                g.deck.register_vcard(skill)
                rst = g.process_action(LaunchCard(p, [tgt], skill))
                assert rst

        return act
Esempio n. 6
0
    def passive_action_disp(ilet, skills, rawcards, params, players):
        g = Game.getgame()

        usage = getattr(ilet.initiator, 'card_usage', 'none')

        if skills:
            if any(not g.me.has_skill(s) for s in skills):
                raise ActionDisplayResult(False, u'您不能这样出牌', False, [], [])
            cards = [thbactions.skill_wrap(g.me, skills, rawcards, params)]
            usage = cards[0].usage if usage == 'launch' else usage
        else:
            cards = rawcards

        cards, prompt_card = pasv_handle_card_selection(g, ilet, cards)
        plsel, disables, players, prompt_target = pasv_handle_player_selection(g, ilet, players)

        verify = getattr(ilet.initiator, 'ask_for_action_verify', None)
        rst = not verify or verify(g.me, cards, players)
        if not rst:
            raise ActionDisplayResult(False, rst.ui_meta.shootdown_message, plsel, disables, players)

        raise ActionDisplayResult(True, prompt_target or prompt_card, plsel, disables, players)
Esempio n. 7
0
 def ask_for_action_verify(self, p, cl, tl):
     tgt = self.target
     skill = skill_wrap(p, [ImperishableNight], cl, {})
     return LaunchCard(p, [tgt], skill).can_fire()
Esempio n. 8
0
 def ask_for_action_verify(self, p, cl, tl):
     tgt = self.target
     skill = skill_wrap(p, [ImperishableNight], cl, {})
     return LaunchCard(p, [tgt], skill).can_fire()