public static void AttackEachTurnIfAble(Creature source) { Game game = source.Owner.Game; bool attacked = false; Duelist.DuelistEventHandler setHasAttackedToFalse = (duelist) => { attacked = false; }; Game.AttackEventHandler setHasAttackedToTrue = (g, atking) => { if (atking == source) { attacked = true; } }; Game.DuelistEventHandler attack = (g, d) => { foreach (Duelist duelist in game.Duelists) { if (attacked) { return; } if (source.Owner != duelist) { game.AttackPlayer(source, duelist); } } foreach (Creature creature in game.GetAllInBattleZone <Creature>(source.Owner.BattleZone)) { if (attacked) { return; } game.Battle(source, creature); } }; game.BattleZonePut += (g, bz, putCard) => { if (putCard == source) { source.Owner.TurnStarted += setHasAttackedToFalse; game.Attacked += setHasAttackedToTrue; game.DuelistEndAttackStep += attack; } }; game.BattleZoneRemoved += (g, bz, removedCard) => { if (removedCard == source) { source.Owner.TurnStarted -= setHasAttackedToFalse; game.Attacked -= setHasAttackedToTrue; game.DuelistEndAttackStep -= attack; } }; }
public static void PowerAttacker(Creature source, int powerBuff) { Game.AttackEventHandler attacking = (game, atking) => { if (source == atking) { atking.Power += powerBuff; } }; Game.AttackEventHandler attacked = (game, atking) => { if (source == atking) { atking.Power -= powerBuff; } }; source.Owner.Game.Attacking += attacking; source.Owner.Game.Attacked += attacked; }
public static void PowerAttackerUntilEnd(Card source, int powerBuff, Func <Creature[]> args) { foreach (Creature creature in args()) { Game.AttackEventHandler attacking = (game, atking) => { if (creature == atking) { atking.Power += powerBuff; } }; Game.AttackEventHandler attacked = (game, atking) => { if (creature == atking) { atking.Power -= powerBuff; } }; creature.Owner.Game.Attacking += attacking; creature.Owner.Game.Attacked += attacked; creature.Owner.Game.DuelistTurnEnded += (game, duelist) => { creature.Owner.Game.Attacking -= attacking; creature.Owner.Game.Attacked -= attacked; }; } }