def handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, Damage): tgt = act.target if tgt.dead: return act if not tgt.has_skill(Echo): return act g = Game.getgame() pact = g.action_stack[-1] card = getattr(pact, 'associated_card', None) if not card: return act if not card.detached or card.unwrapped: return act if not VirtualCard.unwrap([card]): return act if not user_input([tgt], ChooseOptionInputlet(self, (False, True))): return act attack = card.is_card(AttackCard) pl = attack and user_choose_players(self, tgt, [p for p in g.players if not p.dead]) p = pl[0] if pl else tgt g.process_action(EchoAction(tgt, p, card)) return act
def handle(self, evt_type, act): if evt_type == 'action_done' and isinstance(act, Attack): src = act.source tgt = act.target if src.dead or tgt.dead: return act if not src.has_skill(Resonance): return act g = Game.getgame() pl = [p for p in g.players if not p.dead and p not in (src, tgt)] if not pl: return act pl = user_choose_players(self, src, pl) if not pl: return act g.process_action(ResonanceAction(src, pl[0], tgt)) return act
def handle(self, evt_type, act): if evt_type == 'choose_target': act, tl = arg = act card = act.card if not card.is_card(HarvestCard): return arg pl = [p for p in tl if p.has_skill(AkiTribute) and not p.dead] assert len(pl) <= 1, 'Multiple AkiTributes!' if not pl: return arg p = pl[0] tl.remove(p) tl.insert(0, p) return act, tl elif evt_type == 'harvest_finish': g = Game.getgame() pl = [p for p in g.players if p.has_skill(AkiTribute) and not p.dead] assert len(pl) <= 1, 'Multiple AkiTributes!' if not pl: return act src = pl[0] cards = [c for c in act.cards if c.detached] if not cards: return act candidates = [p for p in g.players if not p.dead] pl = user_choose_players(self, src, candidates) if not pl: return act tgt, = pl g.process_action(AkiTributeCollectCard(src, tgt, cards)) return act
def handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, Damage): src = act.source if not src: return act if not src.has_skill(DestructionImpulse): return act g = Game.getgame() ttags(src)['destruction_tag'] = True elif evt_type == 'action_after' and isinstance(act, PlayerTurn): tgt = act.target if not tgt.has_skill(DestructionImpulse): return act g = Game.getgame() if ttags(tgt)['destruction_tag']: return act dist = LaunchCard.calc_distance(tgt, DestructionImpulse(tgt)) dist.pop(tgt, '') for k in dist: dist[k] = max(dist[k], 0) nearest = min(dist.values()) candidates = [p for p, d in dist.items() if d == nearest] candidates = [p for p in g.players if p in candidates] # order matters if len(candidates) > 1: pl = user_choose_players(self, tgt, candidates) p = pl[0] if pl else candidates[0] else: p = candidates[0] g.process_action(DestructionImpulseAction(tgt, p)) return act
def handle(self, evt_type, act): if evt_type == 'choose_target': act, tl = arg = act card = act.card if not card.is_card(HarvestCard): return arg pl = [p for p in tl if p.has_skill(AkiTribute) and not p.dead] assert len(pl) <= 1, 'Multiple AkiTributes!' if not pl: return arg p = pl[0] tl.remove(p) tl.insert(0, p) return act, tl elif evt_type == 'harvest_finish': g = Game.getgame() pl = [ p for p in g.players if p.has_skill(AkiTribute) and not p.dead ] assert len(pl) <= 1, 'Multiple AkiTributes!' if not pl: return act src = pl[0] cards = [c for c in act.cards if c.detached] if not cards: return act candidates = [p for p in g.players if not p.dead] pl = user_choose_players(self, src, candidates) if not pl: return act tgt, = pl g.process_action(AkiTributeCollectCard(src, tgt, cards)) return act
def handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, PlayerDeath): src = act.source if not src or not src.has_skill(S****t): return act dist = LaunchCard.calc_distance(src, AttackCard()) candidates = [ k for k, v in dist.items() if v <= 0 and k is not src ] if not candidates: return act pl = user_choose_players(self, src, candidates) if pl: Game.getgame().process_action(SadistAction(src, pl[0])) elif evt_type == 'action_before' and isinstance(act, Damage): src = act.source tgt = act.target if not src or src is tgt: return act if not src.has_skill(S****t): return act if tgt.life == 1: act.amount += 1 return act
def handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, PlayerDeath): src = act.source if not src or not src.has_skill(S****t): return act dist = LaunchCard.calc_distance(src, AttackCard()) candidates = [k for k, v in dist.items() if v <= 0 and k is not src] if not candidates: return act pl = user_choose_players(self, src, candidates) if pl: Game.getgame().process_action(SadistAction(src, pl[0])) elif evt_type == 'action_before' and isinstance(act, Damage): src = act.source tgt = act.target if not src or src is tgt: return act if not src.has_skill(S****t): return act if tgt.life == 1: act.amount += 1 return act
def handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, Damage): tgt = act.target if tgt.dead: return act if not tgt.has_skill(Echo): return act g = Game.getgame() pact = g.action_stack[-1] card = getattr(pact, 'associated_card', None) if not card or not card.is_card(PhysicalCard): return act if not card.detached or card.unwrapped: return act if not user_input([tgt], ChooseOptionInputlet(self, (False, True))): return act attack = card.is_card(AttackCard) pl = attack and user_choose_players( self, tgt, [p for p in g.players if not p.dead]) p = pl[0] if pl else tgt g.process_action(EchoAction(tgt, p, card)) return act
def handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, DropCardStage): self.n = n = act.dropn if n <= 0: return act tgt = act.target if not tgt.has_skill(AutumnWind): return act g = Game.getgame() if not user_input([tgt], ChooseOptionInputlet(self, (False, True))): return act candidates = [ p for p in g.players if p is not tgt and (p.cards or p.showncards or p.equips) and not p.dead ] pl = candidates and user_choose_players(self, tgt, candidates) if not pl: return act g.process_action(AutumnWindAction(tgt, pl)) return act
def handle(self, evt_type, act): if evt_type == 'action_done' and isinstance(act, Attack): src = act.source tgt = act.target if act.cancelled or src.dead or tgt.dead: return act if not src.has_skill(Resonance): return act g = Game.getgame() pl = [p for p in g.players if not p.dead and p not in (src, tgt)] if not pl: return act pl = user_choose_players(self, src, pl) if not pl: return act g.process_action(ResonanceAction(src, pl[0], tgt)) return act
def apply_action(self): g = Game.getgame() src = self.source pl = [p for p in g.players if not p.dead] attacker, victim = user_choose_players(self, src, pl) or (None, None) if attacker is None: return False self.target_list = attacker, victim g.process_action(LaunchCard(src, [attacker, victim], LittleLegionDollControlCard(attacker))) return True
def handle(self, evt_type, act): if evt_type == 'action_apply' and isinstance(act, PlayerTurn): tgt = act.target if not tgt.has_skill(Qiliao): return act qi = getattr(tgt, 'meirin_qiliao', None) if not qi: return act g = Game.getgame() pl = user_choose_players(self, tgt, [p for p in g.players if not p.dead]) if not pl: return act g.process_action(QiliaoRecoverAction(tgt, pl[0])) return act
def apply_action(self): g = Game.getgame() src = self.source pl = [p for p in g.players if not p.dead and p.life < p.maxlife] if not pl: return False beneficiary, = user_choose_players(self, src, pl) or (None,) if beneficiary is None: return False g.process_action(LittleLegionCoverEffect(src, beneficiary, 1)) return True
def apply_action(self): g = Game.getgame() src = self.source pl = [p for p in g.players if not p.dead and p.life < p.maxlife] if not pl: return False beneficiary, = user_choose_players(self, src, pl) or (None, ) if beneficiary is None: return False g.process_action(LittleLegionCoverEffect(src, beneficiary, 1)) return True
def apply_action(self): g = Game.getgame() src = self.source pl = [p for p in g.players if not p.dead and p is not src] if not pl: return False victim, = user_choose_players(self, src, pl) or (None,) if victim is None: return False lc = LaunchCard(src, [victim], LittleLegionAttackCard(src), bypass_check=True) g.process_action(lc) return True
def apply_action(self): tgt = self.target g = Game.getgame() g.process_action(DrawCards(tgt, 1)) ttags(tgt)['miracle_times'] += 1 if ttags(tgt)['miracle_times'] == 3: candidates = [p for p in g.players if not p.dead and p.life < p.maxlife] if candidates: beneficiery, = user_choose_players(self, tgt, candidates) or (None,) if beneficiery: g.process_action(MiracleHeal(tgt, beneficiery)) return True
def handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, DrawCardStage): tgt = act.target if not tgt.has_skill(Jolly): return act g = Game.getgame() pl = user_choose_players(self, tgt, [p for p in g.players if not p.dead]) if not pl: pl = [tgt] p = pl[0] g.process_action(JollyDrawCard(tgt, p)) return act
def handle(self, evt_type, act): if evt_type == 'action_before' and isinstance(act, DropCardStage): g = Game.getgame() tgt = act.target if not tgt.has_skill(Shipwreck): return act candidates = [p for p in g.players if not p.dead and (p.cards or p.showncards or p.equips)] victim, = user_choose_players(self, tgt, candidates) or (None,) if not victim: return act act.__class__ = ShipwreckDropCardStage act.init(victim=victim) return act
def apply_action(self): tgt = self.target g = Game.getgame() g.process_action(DrawCards(tgt, 1)) ttags(tgt)['miracle_times'] += 1 if ttags(tgt)['miracle_times'] == 3: candidates = [ p for p in g.players if not p.dead and p.life < p.maxlife ] if candidates: beneficiery, = user_choose_players(self, tgt, candidates) or (None, ) if beneficiery: g.process_action(MiracleHeal(tgt, beneficiery)) return True
def handle(self, evt_type, act): if evt_type == 'action_apply' and isinstance(act, ActionStage): src = act.target g = Game.getgame() candidates = list(p for p in g.players if not p.dead and p is not src and p.life < p.maxlife) if not (src.has_skill(KeineGuard) and bool(candidates)): return act tl = user_choose_players(self, src, candidates) if not tl: return act tgt = tl[0] g.process_action(KeineGuardAction(src, tgt)) return act
def handle(self, evt_type, act): if evt_type == 'action_before' and isinstance(act, DrawCardStage): if act.cancelled: return act tgt = act.target if not tgt.has_skill(Virtue): return act g = Game.getgame() pl = [p for p in g.players if not p.dead and p is not tgt] pl = pl and user_choose_players(self, tgt, pl) if not pl: return act act.cancelled = True g.process_action(VirtueAction(tgt, pl[0])) return act
def handle(self, evt_type, act): if evt_type == 'action_before' and isinstance(act, DropCardStage): g = Game.getgame() tgt = act.target if not tgt.has_skill(Shipwreck): return act candidates = [ p for p in g.players if not p.dead and (p.cards or p.showncards or p.equips) ] victim, = user_choose_players(self, tgt, candidates) or (None, ) if not victim: return act act.__class__ = ShipwreckDropCardStage act.init(victim=victim) return act
def handle(self, evt_type, act): if evt_type == 'action_after' and isinstance(act, Damage): tgt = act.target if tgt.dead: return act if not tgt.has_skill(Echo): return act g = Game.getgame() pact = g.action_stack[-1] card = getattr(pact, 'associated_card', None) if not card: return act if not card.detached or card.unwrapped: return act if not VirtualCard.unwrap([card]): return act if not user_input([tgt], ChooseOptionInputlet(self, (False, True))): return act attack = card.is_card(AttackCard) pl = attack and user_choose_players( self, tgt, [p for p in g.players if not p.dead]) p = pl[0] if pl else tgt for lc in reversed(g.action_stack): if isinstance(lc, LaunchCard) and lc.card_action is pact: break else: lc = None g.process_action(EchoAction(tgt, p, lc, card)) return act
def handle(self, evt_type, act): if evt_type == "action_after" and isinstance(act, DropCardStage): self.n = n = act.dropn if n <= 0: return act tgt = act.target if not tgt.has_skill(AutumnWind): return act g = Game.getgame() if not user_input([tgt], ChooseOptionInputlet(self, (False, True))): return act candidates = [p for p in g.players if p is not tgt and (p.cards or p.showncards or p.equips) and not p.dead] pl = candidates and user_choose_players(self, tgt, candidates) if not pl: return act g.process_action(AutumnWindAction(tgt, pl)) return act