Пример #1
0
    def getInputletInstances(self):
        from gamepack.thb.cards import AttackCard
        from gamepack.thb.characters.youmu import Youmu
        from gamepack.thb.common import CharChoice
        from gamepack.thb.inputlets import ActionInputlet
        from gamepack.thb.inputlets import ChooseGirlInputlet
        from gamepack.thb.inputlets import ChooseIndividualCardInputlet
        from gamepack.thb.inputlets import ChooseOptionInputlet
        from gamepack.thb.inputlets import ChoosePeerCardInputlet
        from gamepack.thb.inputlets import ProphetInputlet

        g, p = self.makeGame()

        ilets = [
            ActionInputlet(self, ['cards', 'showncards'], []),
            ChooseGirlInputlet(self, {p: [CharChoice(Youmu)]}),
            ChooseIndividualCardInputlet(self, [AttackCard()]),
            ChooseOptionInputlet(self),
            ChoosePeerCardInputlet(self, p, ['cards']),
            ProphetInputlet(self, [AttackCard()]),
        ]

        for i in ilets:
            i.actor = p

        return g, p, ilets
Пример #2
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()

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

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

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

        return act
Пример #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 testChoosePeerCardInputlet(self):
        from game.autoenv import user_input
        from gamepack.thb.inputlets import ChoosePeerCardInputlet
        from gamepack.thb.cards import migrate_cards

        g, p = self.makeGame()
        tgt = g.players[1]

        cards = g.deck.getcards(5)
        migrate_cards(cards, tgt.cards, no_event=True)

        showncards = g.deck.getcards(5)
        migrate_cards(showncards, tgt.showncards, no_event=True)

        ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards'])
        ilet.set_card(cards[1])
        eq_(ilet.data(), cards[1].syncid)

        p.client.gdlist.append([r'>I:ChoosePeerCard:\d+', cards[2].syncid])
        ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards'])
        eq_(user_input([p], ilet), cards[2])

        p.client.gdlist.append([r'>I:ChoosePeerCard:\d+', showncards[2].syncid])
        ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards'])
        eq_(user_input([p], ilet), None)

        p.client.gdlist.append([r'>I:ChoosePeerCard:\d+', 343434])
        ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards'])
        eq_(user_input([p], ilet), None)
Пример #5
0
 def apply_action(self):
     src, tgt = self.source, self.target
     c = user_input([src],
                    ChoosePeerCardInputlet(
                        self, tgt, ('cards', 'showncards', 'equips')))
     if not c: return False
     src.reveal(c)
     migrate_cards([c], src.cards)
     return True
Пример #6
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
Пример #7
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
Пример #8
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
Пример #9
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
Пример #10
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
Пример #11
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
Пример #12
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
Пример #13
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
Пример #14
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
Пример #15
0
    def testChoosePeerCardInputlet(self):
        from game.autoenv import user_input
        from gamepack.thb.inputlets import ChoosePeerCardInputlet
        from gamepack.thb.cards import migrate_cards

        g, p = self.makeGame()
        tgt = g.players[1]

        cards = g.deck.getcards(5)
        migrate_cards(cards, tgt.cards, no_event=True)

        showncards = g.deck.getcards(5)
        migrate_cards(showncards, tgt.showncards, no_event=True)

        ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards'])
        ilet.set_card(cards[1])
        eq_(ilet.data(), cards[1].syncid)

        p.client.gdlist.append([r'>I:ChoosePeerCard:\d+', cards[2].syncid])
        ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards'])
        eq_(user_input([p], ilet), cards[2])

        p.client.gdlist.append(
            [r'>I:ChoosePeerCard:\d+', showncards[2].syncid])
        ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards'])
        eq_(user_input([p], ilet), None)

        p.client.gdlist.append([r'>I:ChoosePeerCard:\d+', 343434])
        ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards'])
        eq_(user_input([p], ilet), None)