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 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
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
def getInputletInstances(self): from thb.cards import AttackCard from thb.characters.youmu import Youmu from thb.common import CharChoice from thb.inputlets import ActionInputlet from thb.inputlets import ChooseGirlInputlet from thb.inputlets import ChooseIndividualCardInputlet from thb.inputlets import ChooseOptionInputlet from thb.inputlets import ChoosePeerCardInputlet from thb.inputlets import ProphetInputlet g, p = self.makeGame() ilets = [ ActionInputlet(self, ['cards', 'showncards'], []), ChooseGirlInputlet(self, {p: [CharChoice(Youmu)]}), ChooseIndividualCardInputlet(self, [AttackCard()]), ChooseOptionInputlet(self, (False, True)), ChoosePeerCardInputlet(self, p, ['cards']), ProphetInputlet(self, [AttackCard()]), ] for i in ilets: i.actor = p return g, p, ilets
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
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
def testChoosePeerCardInputlet(self): from game.autoenv import user_input from thb.inputlets import ChoosePeerCardInputlet from thb.cards import migrate_cards g, p = self.makeGame() tgt = g.players[1] cards = g.deck.getcards(5) migrate_cards(cards, tgt.cards) showncards = g.deck.getcards(5) migrate_cards(showncards, tgt.showncards) ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards']) ilet.set_card(cards[1]) eq_(ilet.data(), cards[1].sync_id) p.client.gdlist.append([r'>I:ChoosePeerCard:\d+', cards[2].sync_id]) ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards']) eq_(user_input([p], ilet), cards[2]) p.client.gdlist.append([r'>I:ChoosePeerCard:\d+', showncards[2].sync_id]) 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)
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
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
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
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
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
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
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
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
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
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
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
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
def testChoosePeerCardInputlet(self): from game.autoenv import user_input from thb.inputlets import ChoosePeerCardInputlet from thb.cards import migrate_cards g, p = self.makeGame() tgt = g.players[1] cards = g.deck.getcards(5) migrate_cards(cards, tgt.cards) showncards = g.deck.getcards(5) migrate_cards(showncards, tgt.showncards) ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards']) ilet.set_card(cards[1]) eq_(ilet.data(), cards[1].sync_id) p.client.gdlist.append([r'>I:ChoosePeerCard:\d+', cards[2].sync_id]) ilet = ChoosePeerCardInputlet(self, target=tgt, categories=['cards']) eq_(user_input([p], ilet), cards[2]) p.client.gdlist.append( [r'>I:ChoosePeerCard:\d+', showncards[2].sync_id]) 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)