From 88e5ddb807c8d53562b0dbf18fbadf1e456ced14 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 17 Mar 2013 16:12:29 +0100 Subject: [PATCH] Added new method to add an attacker later to combat. --- Mage/src/mage/game/combat/Combat.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Mage/src/mage/game/combat/Combat.java b/Mage/src/mage/game/combat/Combat.java index a8abbdcc66..456f2e90b7 100644 --- a/Mage/src/mage/game/combat/Combat.java +++ b/Mage/src/mage/game/combat/Combat.java @@ -122,6 +122,32 @@ public class Combat implements Serializable, Copyable { this.attackerId = playerId; } + /** + * Add an additional attacker to the combat (e.g. token of Geist of Saint Traft) + * This method doesn't trigger ATTACKER_DECLARED event (as intended). + * + * @param creatureId - creature that shall be added to the combat + * @param game + * @return + */ + public boolean addAttackingCreature(UUID creatureId, Game game) { + Player player = game.getPlayer(attackerId); + if (defenders.size() == 1) { + declareAttacker(creatureId, defenders.iterator().next(), game); + return true; + } + else { + TargetDefender target = new TargetDefender(defenders, creatureId); + target.setRequired(true); + player.chooseTarget(Outcome.Damage, target, null, game); + if (target.getFirstTarget() != null) { + declareAttacker(creatureId, target.getFirstTarget(), game); + return true; + } + } + return false; + } + public void selectAttackers(Game game) { if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS, attackerId, attackerId))) { Player player = game.getPlayer(attackerId);