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

View File

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

View File

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