Change deathtouch into a state-based action (as specified by the comp rules) rather than directly destroying the creature, fixing some bugs related to triggers.

This commit is contained in:
elcnesh
2014-11-23 14:51:41 +00:00
parent 2e5202e9f1
commit d7943d767f
3 changed files with 15 additions and 2 deletions

View File

@@ -210,6 +210,7 @@ public class GameAction {
if (fromBattlefield) {
c.setZone(zoneTo);
c.setDamage(0); //clear damage after a card leaves the battlefield
c.setHasBeenDealtDeathtouchDamage(false);
if (c.isTapped()) {
c.setTapped(false); //untap card after it leaves the battlefield if needed
game.fireEvent(new GameEventCardTapped(c, false));
@@ -703,7 +704,8 @@ public class GameAction {
}
}
// Rule 704.5g - Destroy due to lethal damage
else if (c.getNetToughness() <= c.getDamage()) {
// Rule 704.5h - Destroy due to deathtouch
else if (c.getNetToughness() <= c.getDamage() || c.hasBeenDealtDeathtouchDamage()) {
if (desCreats == null) {
desCreats = new LinkedList<Card>();
}
@@ -1129,6 +1131,7 @@ public class GameAction {
&& (c.getShieldCount() > 0 || c.hasKeyword("If CARDNAME would be destroyed, regenerate it."))) {
c.subtractShield(c.getController().getController().chooseRegenerationShield(c));
c.setDamage(0);
c.setHasBeenDealtDeathtouchDamage(false);
c.tap();
c.addRegeneratedThisTurn();
if (game.getCombat() != null) {

View File

@@ -143,6 +143,7 @@ public class DamageDealEffect extends SpellAbilityEffect {
if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) {
if (removeDamage) {
c.setDamage(0);
c.setHasBeenDealtDeathtouchDamage(false);
c.clearAssignedDamage();
}
else if (noPrevention) {

View File

@@ -200,6 +200,7 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
private String oracleText = "";
private int damage;
private boolean hasBeenDealtDeathtouchDamage = false;
// regeneration
private List<CardShields> shields = new ArrayList<CardShields>();
@@ -5138,6 +5139,13 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
getGame().fireEvent(new GameEventCardStatsChanged(this));
}
public final boolean hasBeenDealtDeathtouchDamage() {
return hasBeenDealtDeathtouchDamage;
}
public final void setHasBeenDealtDeathtouchDamage(final boolean hasBeenDealtDeatchtouchDamage) {
this.hasBeenDealtDeathtouchDamage = hasBeenDealtDeatchtouchDamage;
}
public final Map<Card, Integer> getAssignedDamageMap() {
return assignedDamageMap;
}
@@ -5545,7 +5553,7 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
}
if (source.hasKeyword("Deathtouch") && isCreature()) {
game.getAction().destroy(this, null);
setHasBeenDealtDeathtouchDamage(true);
damageType = DamageType.Deathtouch;
}
@@ -6038,6 +6046,7 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
public void onCleanupPhase(final Player turn) {
setDamage(0);
setHasBeenDealtDeathtouchDamage(false);
resetPreventNextDamage();
resetPreventNextDamageWithEffect();
resetReceivedDamageFromThisTurn();