mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Moved hasProtectionFrom to the card class.
- Cleanup in checkStateEffects.
This commit is contained in:
@@ -8008,4 +8008,87 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
getCharacteristics().setCardColorsOverridden(cardColorsOverridden0);
|
||||
}
|
||||
|
||||
public final boolean hasProtectionFrom(Card source) {
|
||||
if (source == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isImmutable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getKeyword() != null) {
|
||||
final ArrayList<String> list = getKeyword();
|
||||
|
||||
String kw = "";
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
kw = list.get(i);
|
||||
|
||||
if (kw.equals("Protection from white") && source.isWhite() && !source.getName().contains("White Ward")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from blue") && source.isBlue() && !source.getName().contains("Blue Ward")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from black") && source.isBlack() && !source.getName().contains("Black Ward")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from red") && source.isRed() && !source.getName().contains("Red Ward")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from green") && source.isGreen() && !source.getName().contains("Green Ward")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from creatures") && source.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from artifacts") && source.isArtifact()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from enchantments") && source.isEnchantment()
|
||||
&& !source.getName().contains("Tattoo Ward")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from everything")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from colored spells")
|
||||
&& (source.isInstant() || source.isSorcery() || source.isAura()) && CardFactoryUtil.isColored(source)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from Dragons") && source.isType("Dragon")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from Demons") && source.isType("Demon")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from Goblins") && source.isType("Goblin")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from Clerics") && source.isType("Cleric")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from Gorgons") && source.isType("Gorgon")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.startsWith("Protection:")) { // uses isValid
|
||||
final String characteristic = kw.split(":")[1];
|
||||
final String[] characteristics = characteristic.split(",");
|
||||
if (source.isValid(characteristics, getController(), this)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // end Card class
|
||||
|
||||
@@ -891,10 +891,7 @@ public class GameAction {
|
||||
// I think the Keyword checks might be superfluous with
|
||||
// the isValid check
|
||||
if (!AllZoneUtil.isCardInPlay(perm)
|
||||
|| CardFactoryUtil.hasProtectionFrom(c, perm)
|
||||
|| ((c.hasKeyword("Enchant creature")
|
||||
|| c.hasKeyword("Enchant tapped creature")) && !perm.isCreature())
|
||||
|| (c.hasKeyword("Enchant tapped creature") && perm.isUntapped())
|
||||
|| perm.hasProtectionFrom(c)
|
||||
|| (tgt != null && !perm.isValid(tgt.getValidTgts(), c.getController(), c)))
|
||||
{
|
||||
c.unEnchantEntity(perm);
|
||||
|
||||
@@ -2531,82 +2531,7 @@ public class CardFactoryUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target.isImmutable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.getKeyword() != null) {
|
||||
final ArrayList<String> list = target.getKeyword();
|
||||
|
||||
String kw = "";
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
kw = list.get(i);
|
||||
|
||||
if (kw.equals("Protection from white") && card.isWhite() && !card.getName().contains("White Ward")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from blue") && card.isBlue() && !card.getName().contains("Blue Ward")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from black") && card.isBlack() && !card.getName().contains("Black Ward")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from red") && card.isRed() && !card.getName().contains("Red Ward")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from green") && card.isGreen() && !card.getName().contains("Green Ward")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from creatures") && card.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from artifacts") && card.isArtifact()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from enchantments") && card.isEnchantment()
|
||||
&& !card.getName().contains("Tattoo Ward")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from everything")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from colored spells")
|
||||
&& (card.isInstant() || card.isSorcery() || card.isAura()) && CardFactoryUtil.isColored(card)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.equals("Protection from Dragons") && card.isType("Dragon")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from Demons") && card.isType("Demon")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from Goblins") && card.isType("Goblin")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from Clerics") && card.isType("Cleric")) {
|
||||
return true;
|
||||
}
|
||||
if (kw.equals("Protection from Gorgons") && card.isType("Gorgon")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kw.startsWith("Protection:")) { // uses isValid
|
||||
final String characteristic = kw.split(":")[1];
|
||||
final String[] characteristics = characteristic.split(",");
|
||||
if (card.isValid(characteristics, target.getController(), target)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return target.hasProtectionFrom(card);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user