mirror of
https://github.com/correl/mage.git
synced 2025-04-02 17:00:11 -09:00
another small fix
This commit is contained in:
parent
ef947493db
commit
61bb7d075b
1 changed files with 65 additions and 0 deletions
|
@ -53,6 +53,7 @@ import mage.cards.SplitCard;
|
|||
import mage.constants.*;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.Counters;
|
||||
import mage.filter.FilterMana;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameState;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -73,6 +74,12 @@ public class Spell extends StackObjImpl implements Card {
|
|||
private final List<SpellAbility> spellAbilities = new ArrayList<>();
|
||||
private final List<Card> spellCards = new ArrayList<>();
|
||||
|
||||
private static final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
|
||||
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";
|
||||
private static final String regexRed = ".*\\x7b.{0,2}R.{0,2}\\x7d.*";
|
||||
private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*";
|
||||
private static final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*";
|
||||
|
||||
private final Card card;
|
||||
private final ObjectColor color;
|
||||
private final ObjectColor frameColor;
|
||||
|
@ -906,6 +913,64 @@ public class Spell extends StackObjImpl implements Card {
|
|||
return card.getMainCard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterMana getColorIdentity() {
|
||||
FilterMana mana = new FilterMana();
|
||||
mana.setBlack(getManaCost().getText().matches(regexBlack));
|
||||
mana.setBlue(getManaCost().getText().matches(regexBlue));
|
||||
mana.setGreen(getManaCost().getText().matches(regexGreen));
|
||||
mana.setRed(getManaCost().getText().matches(regexRed));
|
||||
mana.setWhite(getManaCost().getText().matches(regexWhite));
|
||||
|
||||
for (String rule : getRules()) {
|
||||
rule = rule.replaceAll("(?i)<i.*?</i>", ""); // Ignoring reminder text in italic
|
||||
if (!mana.isBlack() && (rule.matches(regexBlack) || this.color.isBlack())) {
|
||||
mana.setBlack(true);
|
||||
}
|
||||
if (!mana.isBlue() && (rule.matches(regexBlue) || this.color.isBlue())) {
|
||||
mana.setBlue(true);
|
||||
}
|
||||
if (!mana.isGreen() && (rule.matches(regexGreen) || this.color.isGreen())) {
|
||||
mana.setGreen(true);
|
||||
}
|
||||
if (!mana.isRed() && (rule.matches(regexRed) || this.color.isRed())) {
|
||||
mana.setRed(true);
|
||||
}
|
||||
if (!mana.isWhite() && (rule.matches(regexWhite) || this.color.isWhite())) {
|
||||
mana.setWhite(true);
|
||||
}
|
||||
}
|
||||
if (isTransformable()) {
|
||||
Card secondCard = getSecondCardFace();
|
||||
ObjectColor color = secondCard.getColor(null);
|
||||
mana.setBlack(mana.isBlack() || color.isBlack());
|
||||
mana.setGreen(mana.isGreen() || color.isGreen());
|
||||
mana.setRed(mana.isRed() || color.isRed());
|
||||
mana.setBlue(mana.isBlue() || color.isBlue());
|
||||
mana.setWhite(mana.isWhite() || color.isWhite());
|
||||
for (String rule : secondCard.getRules()) {
|
||||
rule = rule.replaceAll("(?i)<i.*?</i>", ""); // Ignoring reminder text in italic
|
||||
if (!mana.isBlack() && rule.matches(regexBlack)) {
|
||||
mana.setBlack(true);
|
||||
}
|
||||
if (!mana.isBlue() && rule.matches(regexBlue)) {
|
||||
mana.setBlue(true);
|
||||
}
|
||||
if (!mana.isGreen() && rule.matches(regexGreen)) {
|
||||
mana.setGreen(true);
|
||||
}
|
||||
if (!mana.isRed() && rule.matches(regexRed)) {
|
||||
mana.setRed(true);
|
||||
}
|
||||
if (!mana.isWhite() && rule.matches(regexWhite)) {
|
||||
mana.setWhite(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZone(Zone zone, Game game) {
|
||||
card.setZone(zone, game);
|
||||
|
|
Loading…
Add table
Reference in a new issue