mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
updated ManaSpentToCastCount, added tests
This commit is contained in:
parent
cdfe8be5fc
commit
70b040473b
3 changed files with 45 additions and 17 deletions
|
@ -5,6 +5,7 @@ import mage.abilities.keyword.FirstStrikeAbility;
|
|||
import mage.abilities.keyword.HasteAbility;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
@ -136,4 +137,39 @@ public class ManaWasSpentToCastTest extends CardTestPlayerBase {
|
|||
assertAbility(playerA, "Jaded Sell-Sword", FirstStrikeAbility.getInstance(), false);
|
||||
assertAbility(playerA, "Jaded Sell-Sword", HasteAbility.getInstance(), false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVerazol() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
|
||||
addCard(Zone.HAND, playerA, "Verazol, the Split Current");
|
||||
|
||||
setChoice(playerA, "X=2");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Verazol, the Split Current");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertCounterCount(playerA, "Verazol, the Split Current", CounterType.P1P1, 4);
|
||||
assertPowerToughness(playerA, "Verazol, the Split Current", 4, 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProssh() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Wastes");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Sphere of Resistance");
|
||||
addCard(Zone.HAND, playerA, "Prossh, Skyraider of Kher");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Prossh, Skyraider of Kher");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertPermanentCount(playerA, "Kobolds of Kher Keep", 7);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.common.ManaPaidSourceWatcher;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
@ -17,18 +14,7 @@ public enum ManaSpentToCastCount implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Spell spell = game.getStack().getSpell(sourceAbility.getSourceId());
|
||||
if (spell == null) {
|
||||
MageObject mageObject = game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.STACK);
|
||||
if (mageObject instanceof Spell) {
|
||||
spell = (Spell) mageObject;
|
||||
}
|
||||
}
|
||||
if (spell != null) {
|
||||
// NOT the cmc of the spell on the stack
|
||||
return spell.getSpellAbility().getManaCostsToPay().manaValue();
|
||||
}
|
||||
return 0;
|
||||
return ManaPaidSourceWatcher.getTotalPaid(sourceAbility.getSourceId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,5 +31,4 @@ public enum ManaSpentToCastCount implements DynamicValue {
|
|||
public String getMessage() {
|
||||
return "the amount of mana spent to cast it";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.UUID;
|
|||
public class ManaPaidSourceWatcher extends Watcher {
|
||||
|
||||
private static final class ManaPaidTracker implements Serializable {
|
||||
private int total = 0;
|
||||
private int whiteSnow = 0;
|
||||
private int blueSnow = 0;
|
||||
private int blackSnow = 0;
|
||||
|
@ -35,6 +36,7 @@ public class ManaPaidSourceWatcher extends Watcher {
|
|||
private int treasure = 0;
|
||||
|
||||
private void increment(MageObject sourceObject, ManaType manaType, Game game) {
|
||||
total++;
|
||||
if (sourceObject.hasSubtype(SubType.TREASURE, game)) {
|
||||
treasure++;
|
||||
}
|
||||
|
@ -108,6 +110,11 @@ public class ManaPaidSourceWatcher extends Watcher {
|
|||
manaMap.clear();
|
||||
}
|
||||
|
||||
public static int getTotalPaid(UUID sourceId, Game game) {
|
||||
ManaPaidSourceWatcher watcher = game.getState().getWatcher(ManaPaidSourceWatcher.class);
|
||||
return watcher == null ? 0 : watcher.manaMap.getOrDefault(sourceId, emptyTracker).total;
|
||||
}
|
||||
|
||||
public static int getTreasurePaid(UUID sourceId, Game game) {
|
||||
ManaPaidSourceWatcher watcher = game.getState().getWatcher(ManaPaidSourceWatcher.class);
|
||||
return watcher == null ? 0 : watcher.manaMap.getOrDefault(sourceId, emptyTracker).treasure;
|
||||
|
|
Loading…
Reference in a new issue