mirror of
https://github.com/correl/mage.git
synced 2025-03-13 01:09:53 -09:00
fixed color identity function not working for transguild courier
This commit is contained in:
parent
466150cf19
commit
590e412550
2 changed files with 66 additions and 63 deletions
Mage/src/main/java/mage/cards
|
@ -31,7 +31,6 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
|
@ -46,12 +45,6 @@ import mage.game.permanent.Permanent;
|
|||
|
||||
public interface Card extends MageObject {
|
||||
|
||||
final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
|
||||
final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";
|
||||
final String regexRed = ".*\\x7b.{0,2}R.{0,2}\\x7d.*";
|
||||
final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*";
|
||||
final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*";
|
||||
|
||||
UUID getOwnerId();
|
||||
|
||||
String getCardNumber();
|
||||
|
@ -188,62 +181,7 @@ public interface Card extends MageObject {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
default 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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
default FilterMana getColorIdentity();
|
||||
|
||||
List<UUID> getAttachments();
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import mage.counters.Counter;
|
|||
import mage.counters.CounterType;
|
||||
import mage.counters.Counters;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterMana;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
|
@ -75,6 +76,12 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(CardImpl.class);
|
||||
|
||||
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.*";
|
||||
|
||||
protected UUID ownerId;
|
||||
protected String cardNumber;
|
||||
public String expansionSetCode;
|
||||
|
@ -844,6 +851,64 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
return this;
|
||||
}
|
||||
|
||||
@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) {
|
||||
game.setZone(getId(), zone);
|
||||
|
|
Loading…
Add table
Reference in a new issue