forked from External/mage
fixed implementation of Embodiment of Agonies, added a test
This commit is contained in:
parent
2b1974a79e
commit
2f72726a7f
2 changed files with 123 additions and 8 deletions
|
|
@ -3,6 +3,8 @@ package mage.cards.e;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
|
|
@ -16,9 +18,7 @@ import mage.counters.CounterType;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
|
@ -68,11 +68,7 @@ enum EmbodimentOfAgoniesValue implements DynamicValue {
|
|||
.getCards(game)
|
||||
.stream()
|
||||
.filter(card -> !card.isLand())
|
||||
.forEach(card -> card
|
||||
.getManaCost()
|
||||
.stream()
|
||||
.forEach(manaCost -> stringSet.add(manaCost.getText()))
|
||||
);
|
||||
.forEach(card -> stringSet.add(getCosts(card.getManaCost())));
|
||||
stringSet.removeIf(s -> s == null || s.equals(""));
|
||||
return stringSet.size();
|
||||
}
|
||||
|
|
@ -86,4 +82,23 @@ enum EmbodimentOfAgoniesValue implements DynamicValue {
|
|||
public String getMessage() {
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String getCosts(ManaCosts<ManaCost> costs) {
|
||||
List<String> newList = new ArrayList();
|
||||
int generic = 0;
|
||||
boolean hasGeneric = false;
|
||||
for (String s : costs.getSymbols()) {
|
||||
if (s.matches("\\{\\d*\\}")) {
|
||||
generic += Integer.parseInt(s.substring(1, s.length() - 1));
|
||||
hasGeneric = true;
|
||||
} else {
|
||||
newList.add(s);
|
||||
}
|
||||
}
|
||||
Collections.sort(newList);
|
||||
if (hasGeneric) {
|
||||
newList.add("{" + generic + "}");
|
||||
}
|
||||
return String.join("", newList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
package org.mage.test.cards.single;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class EmbodimentOfAgoniesTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testCard() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
|
||||
addCard(Zone.HAND, playerA, "Embodiment of Agonies");
|
||||
addCard(Zone.GRAVEYARD, playerA, "Rakdos Cackler"); // Mana Cost: {B/R}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Surgical Extraction"); // Mana Cost: {B/P}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Tormented Soul"); // Mana Cost: {B}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Gut Shot"); // Mana Cost: {R/P}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Lightning Bolt"); // Mana Cost: {R}
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Embodiment of Agonies");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
// Creature should be 5/5 as there are 5 distinct mana costs in graveyard
|
||||
assertPowerToughness(playerA, "Embodiment of Agonies", 5, 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCard2() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
|
||||
addCard(Zone.HAND, playerA, "Embodiment of Agonies");
|
||||
addCard(Zone.GRAVEYARD, playerA, "Turn // Burn"); // Mana Cost: {3}{U}{R}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Prophetic Bolt"); // Mana Cost: {3}{U}{R}
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Embodiment of Agonies");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
// Creature should be 1/1 as there 1 distinct mana cost in graveyard
|
||||
assertPowerToughness(playerA, "Embodiment of Agonies", 1, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCard3() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
|
||||
addCard(Zone.HAND, playerA, "Embodiment of Agonies");
|
||||
addCard(Zone.GRAVEYARD, playerA, "Turn // Burn"); // Mana Cost: {3}{U}{R}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Divination"); // Mana Cost: {2}{U}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Magma Jet"); // Mana Cost: {1}{R}
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Embodiment of Agonies");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
// Creature should be 3/3 as there are 3 distinct mana costs in graveyard
|
||||
assertPowerToughness(playerA, "Embodiment of Agonies", 3, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCard4() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
|
||||
addCard(Zone.HAND, playerA, "Embodiment of Agonies");
|
||||
addCard(Zone.GRAVEYARD, playerA, "Ancestral Vision"); // No Mana Cost
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Embodiment of Agonies");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
// Creature should be dead as there are no mana costs in graveyards
|
||||
assertGraveyardCount(playerA, "Embodiment of Agonies", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCard5() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
|
||||
addCard(Zone.HAND, playerA, "Embodiment of Agonies");
|
||||
addCard(Zone.GRAVEYARD, playerA, "Lightning Bolt"); // Mana Cost: {R}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Fireball"); // Mana Cost: {X}{R}
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Embodiment of Agonies");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
// Creature should be dead as there are no mana costs in graveyards
|
||||
assertGraveyardCount(playerA, "Embodiment of Agonies", 1);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue