* 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); Permanent creature = game.getPermanent(creatureId);
if (creature != null) { if (creature != null) {
creature.setAttacking(false); creature.setAttacking(false);
creature.setBlocking(0); creature.setBlocking(0);
for (CombatGroup group : groups) { for (CombatGroup group : groups) {
group.remove(creatureId); result |= group.remove(creatureId);
} }
} }
return result;
} }
public void endCombat(Game game) { public void endCombat(Game game) {

View file

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

View file

@ -817,7 +817,8 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
public boolean sacrifice(UUID sourceId, Game game) { public boolean sacrifice(UUID sourceId, Game game) {
//20091005 - 701.13 //20091005 - 701.13
if (!game.replaceEvent(GameEvent.getEvent(EventType.SACRIFICE_PERMANENT, objectId, sourceId, controllerId))) { 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()); Player player = game.getPlayer(getControllerId());
if (player != null) { if (player != null) {
game.informPlayers(new StringBuilder(player.getName()).append(" sacrificed ").append(this.getName()).toString()); 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 @Override
public boolean removeFromCombat(Game game) { 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; return true;
} }