Exemplo n.º 1
0
    def handle(self, evt_type, act):
        if evt_type != 'action_before':
            return act

        if not isinstance(act, InstantSpellCardAction):
            return act

        if isinstance(act, Reject):
            # HACK
            return act

        if ForEach.is_group_effect(act):
            return act

        src = act.source
        tgt = act.target

        if not src or tgt is src:
            return act

        if not tgt.has_skill(ReversedScales):
            return act

        if not user_input([tgt], ChooseOptionInputlet(self, (False, True))):
            return act

        g = Game.getgame()
        g.process_action(ReversedScalesAction(tgt, act))

        return act
Exemplo n.º 2
0
    def is_valid(self):
        try:
            cards = ForEach.get_actual_action(self).cards
        except:
            return False

        if self.target.dead:
            return False

        return bool([c for c in cards if c.detached])
Exemplo n.º 3
0
    def is_valid(self):
        try:
            cards = ForEach.get_actual_action(self).cards
        except:
            return False

        if self.target.dead:
            return False

        return bool([c for c in cards if c.detached])
Exemplo n.º 4
0
    def handle(self, evt_type, act):
        if evt_type == 'action_after' and isinstance(act, Damage):
            g = Game.getgame()
            pact = g.action_stack[-1]
            src, tgt = act.source, act.target

            if ForEach.is_group_effect(pact): return act
            if src is tgt: return act

            self.process(src, tgt)
            self.process(tgt, src)

        return act
Exemplo n.º 5
0
    def handle(self, evt_type, act):
        if evt_type == 'action_after' and isinstance(act, Damage):
            g = Game.getgame()
            pact = g.action_stack[-1]
            src, tgt = act.source, act.target

            if ForEach.is_group_effect(pact): return act
            if src is tgt: return act

            self.process(src, tgt)
            self.process(tgt, src)

        return act
Exemplo n.º 6
0
    def handle(self, evt_type, act):
        if evt_type == 'action_before' and ForEach.is_group_effect(act):
            g = Game.getgame()
            tgt = act.target
            if not tgt.has_skill(GodDescendant):
                return act

            opt = user_input([tgt], ChooseOptionInputlet(self, ('skip', 'draw', None)))

            if opt == 'skip':
                g.process_action(GodDescendantSkipAction(tgt, tgt, act))
            elif opt == 'draw':
                g.process_action(GodDescendantDrawAction(tgt, tgt, act))

        return act
Exemplo n.º 7
0
    def apply_action(self):
        pact = ForEach.get_actual_action(self)
        cards = pact.cards
        cards_avail = [c for c in cards if c.detached]
        if not cards_avail: return False
        tgt = self.target

        card = user_input(
            [tgt],
            ChooseIndividualCardInputlet(self, cards_avail),
            trans=pact.trans,
        ) or random_choose_card([cards_avail])

        migrate_cards([card], tgt.cards)

        pact.trans.notify('harvest_choose', card)
        self.card = card
        return True
Exemplo n.º 8
0
    def apply_action(self):
        pact = ForEach.get_actual_action(self)
        cards = pact.cards
        cards_avail = [c for c in cards if c.detached]
        if not cards_avail: return False
        tgt = self.target

        card = user_input(
            [tgt],
            ChooseIndividualCardInputlet(self, cards_avail),
            trans=pact.trans,
        ) or random_choose_card([cards_avail])

        migrate_cards([card], tgt.cards)

        pact.trans.notify('harvest_choose', card)
        self.card = card
        return True
Exemplo n.º 9
0
    def handle(self, evt_type, act):
        if evt_type == 'action_before' and ForEach.is_group_effect(act):
            tgt = act.target
            if not tgt.has_skill(Heterodoxy): return act

            g = Game.getgame()
            for a in reversed(g.action_stack):
                if isinstance(a, HeterodoxyAction):
                    break
            else:
                return act

            if not user_input([tgt], ChooseOptionInputlet(self, (False, True))):
                return act

            act.cancelled = True
            g.process_action(HeterodoxySkipAction(tgt, tgt))

        return act
Exemplo n.º 10
0
    def handle(self, evt_type, act):
        if evt_type == 'action_before' and ForEach.is_group_effect(act):
            tgt = act.target
            if not tgt.has_skill(Heterodoxy): return act

            g = Game.getgame()
            for a in reversed(g.action_stack):
                if isinstance(a, HeterodoxyAction):
                    break
            else:
                return act

            if not user_input([tgt], ChooseOptionInputlet(self,
                                                          (False, True))):
                return act

            act.cancelled = True
            g.process_action(HeterodoxySkipAction(tgt, tgt))

        return act