def apply_action(self): src, tgt = self.source, self.target g = Game.getgame() src.tags['darknoh_tag'] = src.tags['turn_count'] sk = self.associated_card card = sk.associated_cards[0] self.card = card migrate_cards([sk], tgt.showncards, unwrap=True) self.n = n = len(tgt.cards) + len(tgt.showncards) - tgt.life if n <= 0: return True cards = user_choose_cards(self, tgt, ('cards', 'showncards')) if not cards: cl = list(tgt.cards) + list(tgt.showncards) try: cl.remove(card) except: pass cards = cl[:n] g.players.reveal(cards) g.process_action(DropCards(src, tgt, cards)) return True
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
def apply_action(self): g = Game.getgame() src, tgt = self.source, self.target g.process_action(DropCards(src, tgt, [self.card])) if self.do_damage: g.process_action(Damage(src, tgt, 1)) return True
def apply_action(self): src, tgt = self.source, self.target cards = self.cards g = Game.getgame() g.players.reveal(cards) g.process_action(DropCards(src, tgt, cards)) return True
def apply_action(self): tgt = self.target src = self.source g = Game.getgame() g.process_action(DropCards(src, src, self.cards)) g.process_action(LifeLost(src, tgt, 1)) g.process_action(Wine(src, tgt)) return True
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
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 fatetell_postprocess(self): g = Game.getgame() tgt = self.target if not self.cancelled and self.succeeded: g.process_action(DropCards(None, tgt, [self.associated_card])) else: pl = g.players stop = pl.index(tgt) next = stop - len(pl) + 1 while next < stop: if not pl[next].dead: migrate_cards([self.associated_card], pl[next].fatetell) return next += 1
def apply_action(self): src = self.source tgt = self.target cards = user_choose_cards(self, tgt, ('cards', 'showncards')) g = Game.getgame() if cards: self.peer_action = 'drop' g.process_action(DropCards(src, tgt, cards)) else: self.peer_action = 'draw' g.process_action(DrawCards(src, 1)) 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, 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 handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, Damage): if not act.succeeded: return act src, tgt = act.source, act.target if not (src and src.has_skill(AyaRoundfanSkill) and tgt.equips): return act g = Game.getgame() pa = g.action_stack[-1] if not isinstance(pa, basic.BaseAttack): return act cards = user_choose_cards(self, src, ('cards', 'showncards')) if not cards: return act g = Game.getgame() g.process_action(DropCards(src, src, cards)) g.process_action(AyaRoundfan(src, tgt)) return act
def handle(self, evt_type, arg): if evt_type == 'attack_aftergraze': act, succeed = arg assert isinstance(act, basic.BaseAttack) if succeed: return arg src = act.source tgt = act.target if not src or not src.has_skill(LaevateinSkill): return arg g = Game.getgame() cards = user_choose_cards(self, src, ('cards', 'showncards', 'equips')) if not cards: return arg g.process_action(DropCards(src, src, cards)) g.process_action(Laevatein(src, tgt)) return act, True return arg
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 handle(self, evt_type, act): if evt_type == 'action_apply' and isinstance(act, PlayerDeath): g = Game.getgame() T = Identity.TYPE tgt = act.target dead = lambda p: p.dead or p is tgt # curtain's win survivors = [p for p in g.players if not dead(p)] if len(survivors) == 1: pl = g.players pl.reveal([p.identity for p in g.players]) if survivors[0].identity.type == T.CURTAIN: g.winners = survivors[:] g.game_end() deads = defaultdict(list) for p in g.players: if dead(p): deads[p.identity.type].append(p) def winner(*identities): pl = g.players pl.reveal([p.identity for p in g.players]) g.winners = [p for p in pl if p.identity.type in identities] g.game_end() def no(identity): return len(deads[identity]) == g.identities.count(identity) # attackers' & curtain's win if len(deads[T.BOSS]): if g.double_curtain: winner(T.ATTACKER) else: if no(T.ATTACKER): winner(T.CURTAIN) else: winner(T.ATTACKER) # boss & accomplices' win if no(T.ATTACKER) and no(T.CURTAIN): winner(T.BOSS, T.ACCOMPLICE) # all survivors dropped if all([p.dropped for p in survivors]): pl = g.players pl.reveal([p.identity for p in pl]) g.winners = [] g.game_end() elif evt_type == 'action_after' and isinstance(act, PlayerDeath): T = Identity.TYPE g = Game.getgame() tgt = act.target src = act.source if src: if tgt.identity.type == T.ATTACKER: g.process_action(DrawCards(src, 3)) elif tgt.identity.type == T.ACCOMPLICE: if src.identity.type == T.BOSS: g.players.exclude(src).reveal(list(src.cards)) cards = [] cards.extend(src.cards) cards.extend(src.showncards) cards.extend(src.equips) cards and g.process_action(DropCards(src, src, cards)) return act
def fatetell_postprocess(self): g = Game.getgame() tgt = self.target g.process_action(DropCards(None, tgt, [self.associated_card]))