From 8af26280940a3c130188dff4a711b40d2c14b67f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 2 Feb 2013 19:04:58 +0100 Subject: [PATCH] Fixed bug of ReturnToHandAllEffect, minor formating changes of Combat. --- .../effects/common/ReturnToHandAllEffect.java | 2 +- Mage/src/mage/game/combat/Combat.java | 45 +++++++++++-------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Mage/src/mage/abilities/effects/common/ReturnToHandAllEffect.java b/Mage/src/mage/abilities/effects/common/ReturnToHandAllEffect.java index 8d1c724574..04631ca9a7 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnToHandAllEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnToHandAllEffect.java @@ -58,7 +58,7 @@ public class ReturnToHandAllEffect extends OneShotEffect @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { permanent.moveToZone(Constants.Zone.HAND, source.getSourceId(), game, true); } return true; diff --git a/Mage/src/mage/game/combat/Combat.java b/Mage/src/mage/game/combat/Combat.java index 2146a89ffb..c7637cde7d 100644 --- a/Mage/src/mage/game/combat/Combat.java +++ b/Mage/src/mage/game/combat/Combat.java @@ -28,6 +28,8 @@ package mage.game.combat; +import java.io.Serializable; +import java.util.*; import mage.Constants.Outcome; import mage.abilities.effects.RequirementEffect; import mage.abilities.keyword.CantAttackAloneAbility; @@ -44,9 +46,6 @@ import mage.target.common.TargetDefender; import mage.util.Copyable; import mage.util.trace.TraceUtil; -import java.io.Serializable; -import java.util.*; - /** * @author BetaSteward_at_googlemail.com @@ -129,8 +128,9 @@ public class Combat implements Serializable, Copyable { //20101001 - 508.1d checkAttackRequirements(player, game); player.selectAttackers(game, attackerId); - if (game.isPaused() || game.isGameOver()) + if (game.isPaused() || game.isGameOver()) { return; + } checkAttackRestrictions(player, game); resumeSelectAttackers(game); } @@ -179,15 +179,15 @@ public class Combat implements Serializable, Copyable { if (count == 1) { for (CombatGroup group: groups) { List tobeRemoved = new ArrayList(); - for (UUID attackerId: group.getAttackers()) { - Permanent attacker = game.getPermanent(attackerId); + for (UUID attackingCreatureId: group.getAttackers()) { + Permanent attacker = game.getPermanent(attackingCreatureId); if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) { game.informPlayers(attacker.getName() + " can't attack alone. Removing it from combat."); - tobeRemoved.add(attackerId); + tobeRemoved.add(attackingCreatureId); } } - for (UUID attackerId : tobeRemoved) { - group.remove(attackerId); + for (UUID attackingCreatureId : tobeRemoved) { + group.remove(attackingCreatureId); } } } @@ -332,8 +332,9 @@ public class Combat implements Serializable, Copyable { } public void declareAttacker(UUID attackerId, UUID defenderId, Game game) { - if (!defenders.contains(defenderId)) + if (!defenders.contains(defenderId)) { return; + } Permanent defender = game.getPermanent(defenderId); CombatGroup newGroup = new CombatGroup(defenderId, defender != null); newGroup.attackers.add(attackerId); @@ -403,16 +404,18 @@ public class Combat implements Serializable, Copyable { public boolean hasFirstOrDoubleStrike(Game game) { for (CombatGroup group : groups) { - if (group.hasFirstOrDoubleStrike(game)) + if (group.hasFirstOrDoubleStrike(game)) { return true; + } } return false; } public CombatGroup findGroup(UUID attackerId) { for (CombatGroup group : groups) { - if (group.getAttackers().contains(attackerId)) + if (group.getAttackers().contains(attackerId)) { return group; + } } return null; } @@ -432,19 +435,22 @@ public class Combat implements Serializable, Copyable { } public boolean noAttackers() { - if (groups.isEmpty() || getAttackers().isEmpty()) + if (groups.isEmpty() || getAttackers().isEmpty()) { return true; + } return false; } public boolean isAttacked(UUID defenderId, Game game) { for (CombatGroup group : groups) { - if (group.getDefenderId().equals(defenderId)) + if (group.getDefenderId().equals(defenderId)) { return true; + } if (group.defenderIsPlaneswalker) { Permanent permanent = game.getPermanent(group.getDefenderId()); - if (permanent.getControllerId().equals(defenderId)) + if (permanent.getControllerId().equals(defenderId)) { return true; + } } } return false; @@ -466,8 +472,9 @@ public class Combat implements Serializable, Copyable { for (CombatGroup group : groups) { if (group.defenderIsPlaneswalker) { Permanent permanent = game.getPermanent(group.getDefenderId()); - if (permanent != null) + if (permanent != null) { playerDefenders.add(permanent.getControllerId()); + } } else { playerDefenders.add(group.getDefenderId()); } @@ -510,13 +517,15 @@ public class Combat implements Serializable, Copyable { if (group.blockers.contains(blockerId)) { group.blockers.remove(blockerId); group.blockerOrder.remove(blockerId); - if (group.blockers.isEmpty()) + if (group.blockers.isEmpty()) { group.blocked = false; + } } } Permanent creature = game.getPermanent(blockerId); - if (creature != null) + if (creature != null) { creature.setBlocking(0); + } } public UUID getAttackerId() {