Fixed can't attack alone ability (issue #119), creature wasn't untapped when attack was reverted.

This commit is contained in:
LevelX2 2013-03-05 22:01:01 +01:00
parent 03402fd539
commit 2409e229c0
4 changed files with 9 additions and 11 deletions

View file

@ -55,7 +55,7 @@ public class CantAttackAloneAbility extends StaticAbility<CantAttackAloneAbility
@Override @Override
public String getRule() { public String getRule() {
return "Can't attack alone"; return "{this} can't attack alone.";
} }
@Override @Override

View file

@ -55,7 +55,7 @@ public class CantBlockAloneAbility extends StaticAbility<CantBlockAloneAbility>
@Override @Override
public String getRule() { public String getRule() {
return "Can't block alone"; return "{this} can't block alone.";
} }
@Override @Override

View file

@ -177,8 +177,8 @@ public class Combat implements Serializable, Copyable<Combat> {
count += group.getAttackers().size(); count += group.getAttackers().size();
} }
if (count == 1) { if (count == 1) {
List<UUID> tobeRemoved = new ArrayList<UUID>();
for (CombatGroup group: groups) { for (CombatGroup group: groups) {
List<UUID> tobeRemoved = new ArrayList<UUID>();
for (UUID attackingCreatureId: group.getAttackers()) { for (UUID attackingCreatureId: group.getAttackers()) {
Permanent attacker = game.getPermanent(attackingCreatureId); Permanent attacker = game.getPermanent(attackingCreatureId);
if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) { if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) {
@ -186,10 +186,11 @@ public class Combat implements Serializable, Copyable<Combat> {
tobeRemoved.add(attackingCreatureId); tobeRemoved.add(attackingCreatureId);
} }
} }
for (UUID attackingCreatureId : tobeRemoved) {
group.remove(attackingCreatureId);
}
} }
for (UUID attackingCreatureId : tobeRemoved) {
this.removeAttacker(attackingCreatureId, game);
}
} }
} }

View file

@ -499,12 +499,9 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
toBeRemoved.add(blockerId); toBeRemoved.add(blockerId);
} }
} }
for (UUID blockerId : toBeRemoved) { for (UUID blockerId : toBeRemoved) {
remove(blockerId); game.getCombat().removeBlocker(blockerId, game);
Permanent creature = game.getPermanent(blockerId);
if (creature != null) {
creature.setBlocking(creature.getBlocking() - 1);
}
} }
if (blockers.isEmpty()) { if (blockers.isEmpty()) {
this.blocked = false; this.blocked = false;