Exemplo n.º 1
0
    def apply_action(self):
        tgt = self.target
        g = Game.getgame()

        pl = BatchList([p for p in g.players if not p.dead])
        pl = pl.rotate_to(tgt)[1:]
        rst = user_input(pl, ChooseOptionInputlet(self, (False, True)), timeout=6, type='all')

        afc = self.their_afc_action
        for p in pl:
            if p in rst and rst[p]:
                act = copy(afc)
                act.__class__ = classmix(DoNotProcessCard, afc.__class__)
                act.target = p
                if g.process_action(act):
                    self.their_afc_action.card = act.card
                    return True
        else:
            return False

        return True
Exemplo n.º 2
0
    def handle(self, evt_type, act):
        if evt_type != 'action_before': return act
        if not isinstance(act, DropCards): return act

        g = Game.getgame()
        pact = g.action_stack[-1]
        if not isinstance(pact, Demolition): return act
        if not pact.source.has_skill(Envy): return act

        src = pact.source
        tgt = pact.target
        self.card = card = pact.card

        assert len(act.cards) == 1
        assert card is act.cards[0]

        if card.resides_in is None:
            return act

        if card.resides_in.type not in ('cards', 'showncards', 'equips'):
            return act

        assert tgt is card.resides_in.owner

        if src.dead: return act
        if card.suit != Card.DIAMOND: return act

        dist = LaunchCard.calc_distance(src, EnvyRecycle())
        if not dist[tgt] <= 0: return act

        g.emit_event('ui_show_disputed', [card])

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

        act.__class__ = classmix(EnvyRecycleAction, act.__class__)
        return act
Exemplo n.º 3
0
    def handle(self, evt_type, act):
        if evt_type != 'action_before': return act
        if not isinstance(act, DropCards): return act

        g = Game.getgame()
        pact = g.action_stack[-1]
        if not isinstance(pact, Demolition): return act
        if not pact.source.has_skill(Envy): return act

        src = pact.source
        tgt = pact.target
        self.card = card = pact.card

        assert len(act.cards) == 1
        assert card is act.cards[0]

        if card.resides_in is None:
            return act

        if card.resides_in.type not in ('cards', 'showncards', 'equips'):
            return act

        assert tgt is card.resides_in.owner

        if src.dead: return act
        if card.suit != Card.DIAMOND: return act

        dist = LaunchCard.calc_distance(src, EnvyRecycle())
        if not dist[tgt] <= 0: return act

        g.emit_event('ui_show_disputed', [card])

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

        act.__class__ = classmix(EnvyRecycleAction, act.__class__)
        return act
Exemplo n.º 4
0
    def apply_action(self):
        tgt = self.target
        g = Game.getgame()

        pl = BatchList([p for p in g.players if not p.dead])
        pl = pl.rotate_to(tgt)[1:]
        rst = user_input(pl,
                         ChooseOptionInputlet(self, (False, True)),
                         timeout=6,
                         type='all')

        afc = self.their_afc_action
        for p in pl:
            if p in rst and rst[p]:
                act = copy(afc)
                act.__class__ = classmix(DoNotProcessCard, afc.__class__)
                act.target = p
                if g.process_action(act):
                    self.their_afc_action.card = act.card
                    return True
        else:
            return False

        return True