mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 11:49:56 -08:00
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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue