示例#1
0
    def apply_action(self):
        src, tgt = self.source, self.target
        g = Game.getgame()

        catnames = ('cards', 'showncards', 'equips', 'fatetell')
        cats = [getattr(tgt, i) for i in catnames]

        l = []
        for i in xrange(2):
            if not (tgt.cards or tgt.showncards or tgt.equips or tgt.fatetell):
                break

            card = user_input(
                [src], ChoosePeerCardInputlet(self, tgt, catnames)
            )

            if not card:
                card = random_choose_card(cats)
            if card:
                l.append(card)
                g.players.exclude(tgt).reveal(card)
                g.process_action(DropCards(src, tgt, [card]))

        self.cards = l
        return True
示例#2
0
    def apply_action(self):
        src, tgt = self.source, self.target
        g = Game.getgame()

        c = user_input([src], ChoosePeerCardInputlet(self, tgt, ['cards', 'showncards', 'equips']))
        c = c or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
        g.players.reveal(c)

        g.process_action(DropCards(src, tgt, [c]))

        action = 'draw'
        if tgt.life < tgt.maxlife:
            action = user_input([tgt], ChooseOptionInputlet(self, ('heal', 'draw'))) or 'draw'

        if action == 'heal':
            g.process_action(EirinHeal(src, tgt))
        else:
            g.deck.getcards(3)
            g.deck.cards.rotate(3)
            cl = g.deck.getcards(3)
            g.process_action(ShowCards(tgt, cl))

            drop = [c for c in cl if 'basic' in c.category]
            get = [c for c in cl if c not in drop]

            if get:
                migrate_cards(get, tgt.cards)

            if drop:
                migrate_cards(drop, g.deck.droppedcards)

        ttags(src)['sky_silk'] = True
        return True
示例#3
0
    def apply_action(self):
        tgt = self.target
        src = self.source

        catnames = ('cards', 'showncards', 'equips', 'fatetell')
        cats = [getattr(tgt, i) for i in catnames]
        card = user_input([src], ChoosePeerCardInputlet(self, tgt, catnames))
        card = card or random_choose_card(cats)
        if not card:
            return False

        self.card = card
        src.reveal(card)

        src.tags['spirit_away_tag'] += 1

        cl = getattr(tgt, 'yukari_dimension', None)
        if cl is None:
            cl = CardList(tgt, 'yukari_dimension')
            tgt.yukari_dimension = cl
            tgt.showncardlists.append(cl)

        migrate_cards([card], cl)

        return True
示例#4
0
    def apply_action(self):
        src, tgt = self.source, self.target
        g = Game.getgame()

        catnames = ('cards', 'showncards', 'equips', 'fatetell')
        cats = [getattr(tgt, i) for i in catnames]

        l = []
        for i in xrange(2):
            if not (tgt.cards or tgt.showncards or tgt.equips or tgt.fatetell):
                break

            card = user_input(
                [src], ChoosePeerCardInputlet(self, tgt, catnames)
            )

            if not card:
                card = random_choose_card(cats)
            if card:
                l.append(card)
                g.players.exclude(tgt).reveal(card)
                g.process_action(DropCards(src, tgt, [card]))

        self.cards = l
        return True
示例#5
0
    def handle(self, evt_type, act):
        if evt_type == 'action_before' and isinstance(act, BaseAttack) and not marked(act, 'freaking_power'):
            src = act.source
            if not src.has_skill(FreakingPower): return act
            if not user_input([src], ChooseOptionInputlet(self, (False, True))):
                return act
            tgt = act.target
            Game.getgame().process_action(FreakingPowerAction(act))

        elif evt_type == 'action_after' and isinstance(act, Damage):
            g = Game.getgame()

            if act.cancelled: return act
            
            pact = g.action_stack[-1]
            if not marked(pact, 'freaking_power'):
                return act

            src, tgt = pact.source, act.target
            if tgt.dead: return act

            if not (tgt.cards or tgt.showncards or tgt.equips):
                return act

            catnames = ('cards', 'showncards', 'equips')
            card = user_input([src], ChoosePeerCardInputlet(self, tgt, catnames))
            card = card or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
            if card:
                g.players.exclude(tgt).reveal(card)
                g.process_action(DropCards(src, tgt, [card]))

        return act
示例#6
0
    def apply_action(self):
        tgt = self.target
        c = self.card
        g = Game.getgame()
        tgt.reveal(c)
        migrate_cards([c], tgt.cards, unwrap=True)

        choice = user_input([tgt],
                            ChooseOptionInputlet(self, ('reforge', 'action')))
        if choice == 'reforge':
            g.process_action(TeachTargetReforgeAction(tgt, tgt))
        else:
            act = TeachTargetActionStage(tgt)
            g.process_action(act)
            if act.action_count == 1:
                return False

            c = random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
            if not c:
                return False

            g.players.reveal(c)
            g.process_action(Reforge(tgt, tgt, c))

        return True
示例#7
0
 def apply_action(self):
     tgt = self.target
     c, = user_choose_cards(self, tgt,
                            ('cards', 'showncards', 'equips')) or (None, )
     c = c or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
     self.card = c
     return True
示例#8
0
    def apply_action(self):
        src, tgt = self.source, self.target
        cards = user_choose_cards(self, tgt, ('cards', 'showncards'))
        c = cards[0] if cards else random_choose_card([tgt.cards, tgt.showncards])
        src.reveal(c)
        migrate_cards([c], src.cards)

        return True
示例#9
0
    def apply_action(self):
        src, tgt = self.source, self.target
        cards = user_choose_cards(self, tgt, ('cards', 'showncards'))
        c = cards[0] if cards else random_choose_card(
            [tgt.cards, tgt.showncards])
        src.reveal(c)
        migrate_cards([c], src.cards)

        return True
示例#10
0
 def apply_action(self):
     g = Game.getgame()
     src, tgt = self.source, self.target
     c = user_input([src], ChoosePeerCardInputlet(self, tgt, ('cards', 'showncards')))
     c = c or random_choose_card([tgt.cards, tgt.showncards])
     if not c: return False
     g.players.exclude(tgt).reveal(c)
     g.process_action(DropCards(src, tgt, [c]))
     return True
示例#11
0
 def apply_action(self):
     tgt = self.target
     assert tgt.cards
     c = random_choose_card([tgt.cards])
     g = Game.getgame()
     g.players.reveal(c)
     tgt.tags['mind_hack_effect-%s' % g.turn_count] = True
     migrate_cards([c], tgt.showncards)
     return True
示例#12
0
    def apply_action(self):
        src, tgt = self.source, self.target
        g = Game.getgame()

        equip = user_input([src], ChoosePeerCardInputlet(self, tgt, ['equips']))
        equip = equip or random_choose_card([tgt.equips])
        g.process_action(DropCards(src, tgt, [equip]))
        self.card = equip

        return True
示例#13
0
    def apply_action(self):
        src, tgt = self.source, self.target
        g = Game.getgame()

        equip = user_input([src], ChoosePeerCardInputlet(self, tgt, ['equips']))
        equip = equip or random_choose_card([tgt.equips])
        g.process_action(DropCards(src, tgt, [equip]))
        self.card = equip

        return True
示例#14
0
文件: keine.py 项目: zzkklep/thbattle
    def apply_action(self):
        g = Game.getgame()
        tgt = self.target
        c = user_choose_cards(self, tgt, ('cards', 'showncards', 'equips'))
        c = c[0] if c else random_choose_card(
            [tgt.cards, tgt.showncards, tgt.equips])
        if not c:
            return False

        g.process_action(Reforge(tgt, tgt, c))
        return True
示例#15
0
    def apply_action(self):
        src, tgt = self.source, self.target
        cards = user_choose_cards(self, src, ('cards', 'showncards', 'equips'))
        c = cards[0] if cards else random_choose_card([src.cards, src.showncards, src.equips])
        if not c:
            return False

        tgt.reveal(c)
        migrate_cards([c], tgt.cards)

        return True
示例#16
0
 def apply_action(self):
     src, tgt = self.source, self.target
     cl = VirtualCard.unwrap([self.associated_card])
     assert len(cl) == 1
     g = Game.getgame()
     ttags(src)['teach_used'] = True
     g.process_action(Reforge(src, src, cl[0]))
     cl = user_choose_cards(self, src, ('cards', 'showncards', 'equips'))
     c = cl[0] if cl else random_choose_card([src.cards, src.showncards, src.equips])
     g.process_action(TeachTargetEffect(src, tgt, c))
     return True
示例#17
0
    def apply_action(self):
        src, tgt = self.source, self.target
        cards = user_choose_cards(self, src, ('cards', 'showncards', 'equips'))
        c = cards[0] if cards else random_choose_card(
            [src.cards, src.showncards, src.equips])
        if not c:
            return False

        tgt.reveal(c)
        migrate_cards([c], tgt.cards)

        return True
示例#18
0
    def apply_action(self):
        src, tgt = self.source, self.target
        ttags(src)['dismantle'] = True

        g = Game.getgame()
        c = user_input([src], ChoosePeerCardInputlet(self, tgt, ('equips', )))
        c = c or random_choose_card([tgt.equips])
        if not c: return False

        g.process_action(Reforge(src, tgt, c))
        g.process_action(DrawCards(tgt, 1))

        return True
示例#19
0
    def apply_action(self):
        src, tgt = self.source, self.target
        ttags(src)['dismantle'] = True

        g = Game.getgame()
        c = user_input([src], ChoosePeerCardInputlet(self, tgt, ('equips', )))
        c = c or random_choose_card([tgt.equips])
        if not c: return False

        g.process_action(Reforge(src, tgt, c))
        g.process_action(DrawCards(tgt, 1))

        return True
示例#20
0
    def apply_action(self):
        g = Game.getgame()
        cl = self.cards
        track_ids = set([c.track_id for c in cl])

        src, tgt = self.source, self.target
        for c in cl:
            c = user_input([src], ChoosePeerCardInputlet(self, tgt, ('cards', 'showncards', 'equips')))
            c = c or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
            if not c: return True
            g.players.reveal(c)
            g.process_action(DollBlastEffect(src, tgt, c, c.track_id in track_ids))

        return True
示例#21
0
    def apply_action(self):
        src, tgt = self.source, self.target
        ttags(src)['bakadesu'] = True

        cl = user_choose_cards(self, tgt, ('cards', 'showncards'))
        g = Game.getgame()
        if cl:
            g.process_action(LaunchCard(tgt, [src], cl[0]))
        else:
            c = user_input([src], ChoosePeerCardInputlet(self, tgt, ('cards', 'showncards', 'equips')))
            c = c or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
            c and g.process_action(CirnoDropCards(src, tgt, [c]))

        return True
示例#22
0
    def apply_action(self):
        g = Game.getgame()
        cl = self.cards
        track_ids = set([c.track_id for c in cl])

        src, tgt = self.source, self.target
        for c in cl:
            c = user_input([src], ChoosePeerCardInputlet(self, tgt, ('cards', 'showncards', 'equips')))
            c = c or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
            if not c: return True
            g.players.reveal(c)
            g.process_action(DollBlastEffect(src, tgt, c, c.track_id in track_ids))

        return True
示例#23
0
    def apply_action(self):
        g = Game.getgame()
        card = self.card
        tgt = self.target
        g = Game.getgame()

        weapons = [e for e in tgt.equips if e.equipment_category == 'weapon']
        if len(weapons) > 1:
            e = user_input([tgt], ChooseIndividualCardInputlet(self, weapons))
            e = e or random_choose_card([weapons])
            g.process_action(DropCards(tgt, tgt, [e]))

        migrate_cards([card], tgt.equips)

        return True
示例#24
0
    def apply_action(self):
        g = Game.getgame()
        card = self.card
        tgt = self.target
        g = Game.getgame()

        weapons = [e for e in tgt.equips if e.equipment_category == 'weapon']
        if len(weapons) > 1:
            e = user_input([tgt], ChooseIndividualCardInputlet(self, weapons))
            e = e or random_choose_card([weapons])
            g.process_action(DropCards(tgt, tgt, [e]))

        migrate_cards([card], tgt.equips)

        return True
示例#25
0
    def apply_action(self):
        src, tgt, cl = self.source, self.target, self.cards
        g = Game.getgame()

        c = user_input([src], ChooseIndividualCardInputlet(self, cl)) or random_choose_card([cl])
        g.process_action(Reforge(src, tgt, c))

        '''
        candidates = [i for i in g.players if not i.dead]
        p, = user_choose_players(self, src, candidates) or (src,)

        g.process_action(DrawCards(p, 1))
        '''

        return True
示例#26
0
    def apply_action(self):
        src = self.source
        tgt = self.target

        catnames = ('cards', 'showncards', 'equips', 'fatetell')
        cats = [getattr(tgt, i) for i in catnames]
        card = user_input([src], ChoosePeerCardInputlet(self, tgt, catnames))
        if not card:
            card = random_choose_card(cats)
            if not card:
                return False

        self.card = card
        src.reveal(card)
        migrate_cards([card], src.cards, unwrap=True)
        return True
示例#27
0
    def apply_action(self):
        src, tgt = self.source, self.target
        g = Game.getgame()

        catnames = ('cards', 'showncards', 'equips')
        cats = [getattr(tgt, i) for i in catnames]

        card = user_input([src], ChoosePeerCardInputlet(self, tgt, catnames))
        card = card or random_choose_card(cats)

        assert card
        self.card = card

        g.players.reveal(card)
        g.process_action(DropCards(src, tgt, [card]))
        return True
示例#28
0
    def apply_action(self):
        self.damage.cancelled = True

        src, tgt = self.source, self.target
        g = Game.getgame()
        cl = user_choose_cards(self, tgt, ('cards', 'showncards', 'equips'))
        c = cl[0] if cl else random_choose_card([tgt.cards, tgt.showncards, tgt.equips])

        if c:
            damage = c.resides_in is not tgt.equips
            g.process_action(CirnoDropCards(src, tgt, [c]))

            if damage:
                g.process_action(LifeLost(src, tgt, 1))

        return True
示例#29
0
    def apply_action(self):
        src = self.source
        tgt = self.target
        g = Game.getgame()

        c = user_input([src], ChoosePeerCardInputlet(self, tgt, ('cards', 'showncards', 'equips')))
        c = c or random_choose_card([tgt.cards, tgt.showncards])
        if not c: return False
        src.reveal(c)
        migrate_cards([c], src.cards)
        src.tags['borrow_tag'] = src.tags['turn_count']

        if user_input([tgt], ChooseOptionInputlet(self, (False, True))):
            g.process_action(LaunchCard(tgt, [src], Daze(tgt), bypass_check=True))

        return True
示例#30
0
    def apply_action(self):
        src, tgt = self.source, self.target

        g = Game.getgame()

        catnames = ("cards", "showncards", "equips")
        cats = [getattr(tgt, i) for i in catnames]
        card = user_input([src], ChoosePeerCardInputlet(self, tgt, catnames))
        card = card or random_choose_card(cats)
        if not card:
            return False

        self.card = card
        g.players.exclude(tgt).reveal(card)
        g.process_action(DropCards(src, tgt, cards=[card]))
        return True
示例#31
0
    def apply_action(self):
        t = self.target
        src = self.source
        g = Game.getgame()

        catnames = ('cards', 'showncards', 'equips')
        cats = [getattr(t, i) for i in catnames]
        cards = user_choose_cards(self, t, catnames)
        if not cards:
            cards = [random_choose_card(cats)]

        if cards:
            g.players.exclude(t).reveal(cards)
            migrate_cards(cards, src.showncards)

        return True
示例#32
0
    def apply_action(self):
        self.damage.cancelled = True

        src, tgt = self.source, self.target
        g = Game.getgame()
        cl = user_choose_cards(self, tgt, ('cards', 'showncards', 'equips'))
        c = cl[0] if cl else random_choose_card(
            [tgt.cards, tgt.showncards, tgt.equips])

        if c:
            damage = c.resides_in is not tgt.equips
            g.process_action(CirnoDropCards(src, tgt, [c]))

            if damage:
                g.process_action(LifeLost(src, tgt, 1))

        return True
示例#33
0
    def handle(self, evt_type, act):
        if evt_type == 'action_after' and isinstance(act, Damage):
            src = act.source
            tgt = act.target
            if not (src and src.has_skill(FerryFee)): return act
            if not (tgt.cards or tgt.showncards or tgt.equips): return act
            dist = LaunchCard.calc_distance(src, FerryFee(src))
            if not dist.get(tgt, 10000) <= 0: return act
            if user_input([src], ChooseOptionInputlet(self, (False, True))):
                catnames = ('cards', 'showncards', 'equips')
                card = user_input([src], ChoosePeerCardInputlet(self, tgt, catnames))
                card = card or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
                if not card: return act
                g = Game.getgame()
                g.process_action(FerryFeeEffect(src, tgt, card))

        return act
示例#34
0
    def apply_action(self):
        src, tgt = self.source, self.target
        ttags(src)['bakadesu'] = True

        cl = user_choose_cards(self, tgt, ('cards', 'showncards'))
        g = Game.getgame()
        if cl:
            g.process_action(LaunchCard(tgt, [src], cl[0]))
        else:
            c = user_input([src],
                           ChoosePeerCardInputlet(
                               self, tgt, ('cards', 'showncards', 'equips')))
            c = c or random_choose_card(
                [tgt.cards, tgt.showncards, tgt.equips])
            c and g.process_action(CirnoDropCards(src, tgt, [c]))

        return True
示例#35
0
    def handle(self, evt_type, act):
        if evt_type == 'action_apply' and isinstance(act, PlayerTurn):
            actor = act.target
            g = Game.getgame()

            for p in g.players:
                if not p.has_skill(Qiliao): continue
                qi = getattr(p, 'meirin_qiliao', None)
                if not qi: continue
                cl = user_choose_cards(self, actor, ('cards', 'showncards'))
                if not cl: continue
                g.process_action(DropCards(actor, actor, cl))
                if actor.dead: continue
                c = user_input([actor], ChooseIndividualCardInputlet(self, qi)) or random_choose_card([qi])
                g.players.reveal(c)
                g.process_action(DropCards(actor, p, [c]))

        return act
示例#36
0
    def apply_action(self):
        g = Game.getgame()
        src, tgt = self.source, self.target

        catnames = ('cards', 'showncards', 'equips', 'fatetell')
        cats = [getattr(tgt, i) for i in catnames]
        card = user_input([src], ChoosePeerCardInputlet(self, tgt, catnames))
        if not card:
            card = random_choose_card(cats)
            if not card:
                return False

        self.card = card
        g.players.exclude(tgt).reveal(card)
        g.process_action(
            DropCards(src, tgt, cards=[card])
        )
        return True
示例#37
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
示例#38
0
    def handle(self, evt_type, act):
        if evt_type == 'action_after' and isinstance(act, Damage):
            src = act.source
            tgt = act.target
            if not (src and src.has_skill(FerryFee)): return act
            if not (tgt.cards or tgt.showncards or tgt.equips): return act
            dist = LaunchCard.calc_distance(src, FerryFee(src))
            if not dist.get(tgt, 10000) <= 0: return act
            if user_input([src], ChooseOptionInputlet(self, (False, True))):
                catnames = ('cards', 'showncards', 'equips')
                card = user_input([src],
                                  ChoosePeerCardInputlet(self, tgt, catnames))
                card = card or random_choose_card(
                    [tgt.cards, tgt.showncards, tgt.equips])
                if not card: return act
                g = Game.getgame()
                g.process_action(FerryFeeEffect(src, tgt, card))

        return act
示例#39
0
    def handle(self, evt_type, act):
        if evt_type == 'action_apply' and isinstance(act, PlayerTurn):
            actor = act.target
            g = Game.getgame()

            for p in g.players:
                if not p.has_skill(Qiliao): continue
                qi = getattr(p, 'meirin_qiliao', None)
                if not qi: continue
                cl = user_choose_cards(self, actor, ('cards', 'showncards'))
                if not cl: continue
                g.process_action(DropCards(actor, actor, cl))
                if actor.dead: continue
                c = user_input([actor], ChooseIndividualCardInputlet(
                    self, qi)) or random_choose_card([qi])
                g.players.reveal(c)
                g.process_action(DropCards(actor, p, [c]))

        return act
示例#40
0
    def apply_action(self):
        src = self.source
        tgt = self.target
        g = Game.getgame()

        c = user_input([src],
                       ChoosePeerCardInputlet(
                           self, tgt, ('cards', 'showncards', 'equips')))
        c = c or random_choose_card([tgt.cards, tgt.showncards])
        if not c: return False
        src.reveal(c)
        migrate_cards([c], src.cards)
        src.tags['borrow_tag'] = src.tags['turn_count']

        if user_input([tgt], ChooseOptionInputlet(self, (False, True))):
            g.process_action(
                LaunchCard(tgt, [src], Daze(tgt), bypass_check=True))

        return True
示例#41
0
    def apply_action(self):
        g = Game.getgame()
        src, tgt = self.source, self.target
        src.tags['riverside_tag'] = src.tags['turn_count']
        tgt.tags['riverside_target'] = g.turn_count
        minhp = min([p.life for p in g.players if not p.dead])
        if tgt.life == minhp:
            has_card = tgt.cards or tgt.showncards or tgt.equips
            if has_card and user_input([src], ChooseOptionInputlet(self, ('drop', 'draw'))) == 'drop':
                self.action = 'drop'
                catnames = ('cards', 'showncards', 'equips')
                card = user_input([src], ChoosePeerCardInputlet(self, tgt, catnames))
                card = card or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
                g.players.reveal(card)
                g.process_action(DropCards(src, tgt, [card]))
            else:
                self.action = 'draw'
                g.process_action(DrawCards(src, 1))

        return True
示例#42
0
    def apply_action(self):
        src, tgt = self.source, self.target
        g = Game.getgame()
        g.process_action(DrawCards(tgt, 2))

        cl = user_choose_cards(self, tgt, ('cards', 'showncards', 'equips'))
        c = cl[0] if cl else random_choose_card([tgt.cards, tgt.showncards, tgt.equips])

        if not c: return False

        g.players.reveal(c)
        g.process_action(ShowCards(tgt, [c]))
        migrate_cards([c], src.cards)

        if c.suit == Card.HEART:
            g.process_action(DrawCards(src, 1))

        self.card = c

        return True
示例#43
0
    def apply_action(self):
        g = Game.getgame()
        src, tgt = self.source, self.target
        src.tags['riverside_tag'] = src.tags['turn_count']
        tgt.tags['riverside_target'] = g.turn_count
        minhp = min([p.life for p in g.players if not p.dead])
        if tgt.life == minhp:
            has_card = tgt.cards or tgt.showncards or tgt.equips
            if has_card and user_input(
                [src], ChooseOptionInputlet(self, ('drop', 'draw'))) == 'drop':
                self.action = 'drop'
                catnames = ('cards', 'showncards', 'equips')
                card = user_input([src],
                                  ChoosePeerCardInputlet(self, tgt, catnames))
                card = card or random_choose_card(
                    [tgt.cards, tgt.showncards, tgt.equips])
                g.players.reveal(card)
                g.process_action(DropCards(src, tgt, [card]))
            else:
                self.action = 'draw'
                g.process_action(DrawCards(src, 1))

        return True
示例#44
0
 def apply_action(self):
     tgt = self.target
     c, = user_choose_cards(self, tgt, ('cards', 'showncards', 'equips')) or (None,)
     c = c or random_choose_card([tgt.cards, tgt.showncards, tgt.equips])
     self.card = c
     return True