* Commander - Fixed that sacrificing a commander as cost was not possible. Added game log message if creature was removed from combat.

This commit is contained in:
LevelX2 2013-12-15 14:17:39 +01:00
parent 9000b4480c
commit 6d0f30178d
3 changed files with 23 additions and 12 deletions

View file

@ -773,15 +773,17 @@ public class Combat implements Serializable, Copyable<Combat> {
}
}
public void removeFromCombat(UUID creatureId, Game game) {
public boolean removeFromCombat(UUID creatureId, Game game) {
boolean result = false;
Permanent creature = game.getPermanent(creatureId);
if (creature != null) {
creature.setAttacking(false);
creature.setBlocking(0);
for (CombatGroup group : groups) {
group.remove(creatureId);
result |= group.remove(creatureId);
}
}
return result;
}
public void endCombat(Game game) {

View file

@ -492,18 +492,22 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
return defenderIsPlaneswalker;
}
public void remove(UUID creatureId) {
public boolean remove(UUID creatureId) {
boolean result = false;
if (attackers.contains(creatureId)) {
attackers.remove(creatureId);
}
if (blockers.contains(creatureId)) {
blockers.remove(creatureId);
//20100423 - 509.2a
if (blockerOrder.contains(creatureId)) {
blockerOrder.remove(creatureId);
result = true;
} else {
if (blockers.contains(creatureId)) {
blockers.remove(creatureId);
result = true;
//20100423 - 509.2a
if (blockerOrder.contains(creatureId)) {
blockerOrder.remove(creatureId);
}
}
}
return result;
}
public void acceptBlockers(Game game) {

View file

@ -817,7 +817,8 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
public boolean sacrifice(UUID sourceId, Game game) {
//20091005 - 701.13
if (!game.replaceEvent(GameEvent.getEvent(EventType.SACRIFICE_PERMANENT, objectId, sourceId, controllerId))) {
if (moveToZone(Zone.GRAVEYARD, sourceId, game, true)) {
// Commander replacement effect does not prevent successful sacrifice
if (moveToZone(Zone.GRAVEYARD, sourceId, game, true) || game.getState().getZone(this.getId()).equals(Zone.COMMAND)) {
Player player = game.getPlayer(getControllerId());
if (player != null) {
game.informPlayers(new StringBuilder(player.getName()).append(" sacrificed ").append(this.getName()).toString());
@ -976,7 +977,11 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
@Override
public boolean removeFromCombat(Game game) {
game.getCombat().removeFromCombat(objectId, game);
if (this.isAttacking() || this.blocking > 0) {
if (game.getCombat().removeFromCombat(objectId, game)) {
game.informPlayers(new StringBuilder(this.getName()).append(" removed from combat").toString());
}
}
return true;
}