1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-02 03:18:09 -09:00

* Hapatra, Vizier of Poisons - Fixed that it was not triggering off of Infect (fixes ).

This commit is contained in:
LevelX2 2017-05-19 17:51:04 +02:00
parent e090b26240
commit 67a66d90da
3 changed files with 51 additions and 31 deletions
Mage.Tests/src/test/java/org/mage/test/cards/single/akh
Mage/src/main/java/mage/game/permanent

View file

@ -7,11 +7,14 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class BontuTheGlorifiedTest extends CardTestPlayerBase {
//Menace
//Indestructible
//Bontu the Glorified can't attack or block unless a creature died under your control this turn.
//{1}{B}, Sacrifice another creature: Scry 1. Each opponent loses 1 life and you gain 1 life.
String bontu = "Bontu the Glorified";
String swamp = "Swamp";
String grizzly = "Grizzly Bears";
@Test
public void testBontuNotAttack() {
addCard(Zone.BATTLEFIELD, playerA, bontu);

View file

@ -12,60 +12,60 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
* @author escplan9
*/
public class HapatraVizierOfPoisonsTest extends CardTestPlayerBase {
/*
/*
Hapatra, Vizier of Poisons BG
Legendary Creature - Human Cleric 2/2
Whenever Hapatra, Vizier of Poisons deals combat damage to a player, you may put a -1/-1 counter on target creature.
Whenever you put one or more -1/-1 counters on a creature, create a 1/1 green Snake creature token with deathtouch.
*/
private String hapatra = "Hapatra, Vizier of Poisons";
Whenever you put one or more -1/-1 counters on a creature, create a 1/1 green Snake creature token with deathtouch.
*/
private final String hapatra = "Hapatra, Vizier of Poisons";
@Test
public void hapatraCombatDamageToPlayer() {
String gBears = "Grizzly Bears";
addCard(Zone.BATTLEFIELD, playerA, hapatra);
addCard(Zone.BATTLEFIELD, playerB, gBears);
attack(3, playerA, hapatra);
setChoice(playerA, "Yes"); // opt to place -1/-1 counter on creature
addTarget(playerA, gBears);
setStopAt(3, PhaseStep.END_COMBAT);
execute();
assertLife(playerB, 18);
assertCounterCount(playerB, gBears, CounterType.M1M1, 1);
assertPowerToughness(playerB, gBears, 1, 1); // 2/2 with -1/1 counter
assertPermanentCount(playerA, "Snake", 1);
assertAbility(playerA, "Snake", DeathtouchAbility.getInstance(), true);
}
/*
Test is failing due to bug: issue #3288.
Issue #3288.
Hapatra, Vizier of Poisons is not triggering off of Infect. Tested with Blight Mamba
*/
*/
@Test
public void infectDamageTriggersHapatra() {
String bMamba = "Blight Mamba"; // {1}{G} 1/1 Creature - Snake, Infect with {1}{G}:Regen
String bMamba = "Blight Mamba"; // {1}{G} 1/1 Creature - Snake, Infect with {1}{G}:Regen
String wOmens = "Wall of Omens"; // {1}{W} 0/4 defender ETB: draw a card
addCard(Zone.BATTLEFIELD, playerA, hapatra);
addCard(Zone.BATTLEFIELD, playerA, bMamba);
addCard(Zone.BATTLEFIELD, playerB, wOmens);
attack(3, playerA, bMamba);
block(3, playerB, wOmens, bMamba);
setStopAt(3, PhaseStep.END_COMBAT);
execute();
assertLife(playerB, 20);
assertCounterCount(playerB, CounterType.POISON, 0);
assertCounterCount(playerB, wOmens, CounterType.M1M1, 1);
assertPowerToughness(playerB, wOmens, -1, 3); // 0/4 with -1/-1 counter
assertCounterCount(playerB, wOmens, CounterType.M1M1, 1);
assertPermanentCount(playerA, "Snake", 1);
assertAbility(playerA, "Snake", DeathtouchAbility.getInstance(), true);
}

View file

@ -27,6 +27,7 @@
*/
package mage.game.permanent;
import java.util.*;
import mage.MageObject;
import mage.MageObjectReference;
import mage.ObjectColor;
@ -55,13 +56,21 @@ import mage.players.Player;
import mage.util.GameLog;
import mage.util.ThreadLocalStringBuilder;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
public abstract class PermanentImpl extends CardImpl implements Permanent {
public class MarkedDamageInfo {
public MarkedDamageInfo(Counter counter, MageObject sourceObject) {
this.counter = counter;
this.sourceObject = sourceObject;
}
Counter counter;
MageObject sourceObject;
}
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(300);
protected boolean tapped;
@ -96,7 +105,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
protected int attachedToZoneChangeCounter;
protected MageObjectReference pairedPermanent;
protected Counters counters;
protected List<Counter> markedDamage;
protected List<MarkedDamageInfo> markedDamage;
protected int timesLoyaltyUsed = 0;
protected Map<String, String> info;
protected int createOrder;
@ -141,8 +150,8 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
}
if (permanent.markedDamage != null) {
markedDamage = new ArrayList<>();
for (Counter counter : permanent.markedDamage) {
markedDamage.add(counter.copy());
for (MarkedDamageInfo mdi : permanent.markedDamage) {
markedDamage.add(new MarkedDamageInfo(mdi.counter.copy(), mdi.sourceObject));
}
}
if (permanent.info != null) {
@ -768,8 +777,12 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
if (markedDamage == null) {
return 0;
}
for (Counter counter : markedDamage) {
addCounters(counter, null, game);
for (MarkedDamageInfo mdi : markedDamage) {
Ability source = null;
if (mdi.sourceObject instanceof Permanent) {
source = ((Permanent) mdi.sourceObject).getSpellAbility();
}
addCounters(mdi.counter, source, game);
}
markedDamage.clear();
return 0;
@ -811,10 +824,14 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|| source.getAbilities().containsKey(WitherAbility.getInstance().getId()))) {
if (markDamage) {
// mark damage only
markDamage(CounterType.M1M1.createInstance(actualDamage));
markDamage(CounterType.M1M1.createInstance(actualDamage), source);
} else {
Ability damageSourceAbility = null;
if (source instanceof Permanent) {
damageSourceAbility = ((Permanent) source).getSpellAbility();
}
// deal damage immediately
addCounters(CounterType.M1M1.createInstance(actualDamage), null, game);
addCounters(CounterType.M1M1.createInstance(actualDamage), damageSourceAbility, game);
}
} else {
this.damage += actualDamage;
@ -840,11 +857,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return event.getAmount();
}
private void markDamage(Counter counter) {
private void markDamage(Counter counter, MageObject source) {
if (markedDamage == null) {
markedDamage = new ArrayList<>();
}
markedDamage.add(counter);
markedDamage.add(new MarkedDamageInfo(counter, source));
}
@Override