mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- Centralized all "Protection from" checks to the hasProtectionFrom function.
This commit is contained in:
@@ -3345,6 +3345,8 @@ public class CardFactoryUtil {
|
|||||||
|
|
||||||
if (target.getName().equals("Gaea's Revenge") && !spell.isGreen()) return false;
|
if (target.getName().equals("Gaea's Revenge") && !spell.isGreen()) return false;
|
||||||
|
|
||||||
|
if(hasProtectionFrom(spell,target)) return false;
|
||||||
|
|
||||||
if(target.getKeyword() != null) {
|
if(target.getKeyword() != null) {
|
||||||
ArrayList<String> list = target.getKeyword();
|
ArrayList<String> list = target.getKeyword();
|
||||||
|
|
||||||
@@ -3361,6 +3363,7 @@ public class CardFactoryUtil {
|
|||||||
if(spell.isAura()) return false;
|
if(spell.isAura()) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* taken care of by hasProtectionFrom
|
||||||
if(kw.equals("Protection from white") && spell.isWhite()) return false;
|
if(kw.equals("Protection from white") && spell.isWhite()) return false;
|
||||||
if(kw.equals("Protection from blue") && spell.isBlue()) return false;
|
if(kw.equals("Protection from blue") && spell.isBlue()) return false;
|
||||||
if(kw.equals("Protection from black") && spell.isBlack()) return false;
|
if(kw.equals("Protection from black") && spell.isBlack()) return false;
|
||||||
@@ -3386,6 +3389,7 @@ public class CardFactoryUtil {
|
|||||||
|
|
||||||
if(kw.equals("Protection from colored spells") && (spell.isInstant() || spell.isSorcery() || spell.isAura() ) &&
|
if(kw.equals("Protection from colored spells") && (spell.isInstant() || spell.isSorcery() || spell.isAura() ) &&
|
||||||
isColored(spell)) return false;
|
isColored(spell)) return false;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -3422,8 +3426,14 @@ public class CardFactoryUtil {
|
|||||||
if(kw.equals("Protection from artifacts") && card.isArtifact() &&
|
if(kw.equals("Protection from artifacts") && card.isArtifact() &&
|
||||||
!card.getName().contains("Artifact Ward")) return true;
|
!card.getName().contains("Artifact Ward")) return true;
|
||||||
|
|
||||||
|
if(kw.equals("Protection from enchantments") && card.getType().contains("Enchantment") &&
|
||||||
|
!card.getName().contains("Tattoo Ward")) return true;
|
||||||
|
|
||||||
if(kw.equals("Protection from everything")) return true;
|
if(kw.equals("Protection from everything")) return true;
|
||||||
|
|
||||||
|
if(kw.equals("Protection from colored spells") && (card.isInstant() || card.isSorcery() || card.isAura() ) &&
|
||||||
|
isColored(card)) return true;
|
||||||
|
|
||||||
if(kw.equals("Protection from Dragons")
|
if(kw.equals("Protection from Dragons")
|
||||||
&& (card.getType().contains("Dragon") || card.getKeyword().contains("Changeling"))) return true;
|
&& (card.getType().contains("Dragon") || card.getKeyword().contains("Changeling"))) return true;
|
||||||
if(kw.equals("Protection from Demons")
|
if(kw.equals("Protection from Demons")
|
||||||
@@ -3433,8 +3443,6 @@ public class CardFactoryUtil {
|
|||||||
if(kw.equals("Protection from Clerics")
|
if(kw.equals("Protection from Clerics")
|
||||||
&& (card.getType().contains("Cleric") || card.getKeyword().contains("Changeling"))) return false;
|
&& (card.getType().contains("Cleric") || card.getKeyword().contains("Changeling"))) return false;
|
||||||
|
|
||||||
if(kw.equals("Protection from enchantments") && card.getType().contains("Enchantment") &&
|
|
||||||
!card.getName().contains("Tattoo Ward")) return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -3445,12 +3453,16 @@ public class CardFactoryUtil {
|
|||||||
//and also combat damage?
|
//and also combat damage?
|
||||||
ArrayList<String> list = receiver.getKeyword();
|
ArrayList<String> list = receiver.getKeyword();
|
||||||
|
|
||||||
|
if(hasProtectionFrom(spell,receiver)) return false;
|
||||||
|
|
||||||
String kw = "";
|
String kw = "";
|
||||||
for(int i = 0; i < list.size(); i++) {
|
for(int i = 0; i < list.size(); i++) {
|
||||||
kw = list.get(i);
|
kw = list.get(i);
|
||||||
|
|
||||||
if(kw.equals("Prevent all damage that would be dealt to CARDNAME by artifact creatures.")
|
if(kw.equals("Prevent all damage that would be dealt to CARDNAME by artifact creatures.")
|
||||||
&& spell.isCreature() && spell.isArtifact()) return false;
|
&& spell.isCreature() && spell.isArtifact()) return false;
|
||||||
|
|
||||||
|
/* taken care of by hasProtectionFrom
|
||||||
if(kw.equals("Protection from white") && spell.isWhite()) return false;
|
if(kw.equals("Protection from white") && spell.isWhite()) return false;
|
||||||
if(kw.equals("Protection from blue") && spell.isBlue()) return false;
|
if(kw.equals("Protection from blue") && spell.isBlue()) return false;
|
||||||
if(kw.equals("Protection from black") && spell.isBlack()) return false;
|
if(kw.equals("Protection from black") && spell.isBlack()) return false;
|
||||||
@@ -3475,6 +3487,7 @@ public class CardFactoryUtil {
|
|||||||
if(kw.equals("Protection from everything")) return false;
|
if(kw.equals("Protection from everything")) return false;
|
||||||
|
|
||||||
if(kw.equals("Protection from colored spells") && !spell.isPermanent() && isColored(spell) ) return false;
|
if(kw.equals("Protection from colored spells") && !spell.isPermanent() && isColored(spell) ) return false;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class CombatUtil {
|
|||||||
|
|
||||||
if(attacker == null || blocker == null) return false;
|
if(attacker == null || blocker == null) return false;
|
||||||
|
|
||||||
if(!canBlockProtection(attacker, blocker)) return false;
|
if(CardFactoryUtil.hasProtectionFrom(attacker,blocker)) return false;
|
||||||
|
|
||||||
//rare case:
|
//rare case:
|
||||||
if(blocker.getKeyword().contains("Shadow")
|
if(blocker.getKeyword().contains("Shadow")
|
||||||
@@ -838,6 +838,7 @@ public class CombatUtil {
|
|||||||
}//canDamage
|
}//canDamage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*no longer needed
|
||||||
private static boolean canBlockProtection(Card attacker, Card blocker) {
|
private static boolean canBlockProtection(Card attacker, Card blocker) {
|
||||||
ArrayList<String> list = attacker.getKeyword();
|
ArrayList<String> list = attacker.getKeyword();
|
||||||
|
|
||||||
@@ -845,6 +846,7 @@ public class CombatUtil {
|
|||||||
for(int i = 0; i < list.size(); i++) {
|
for(int i = 0; i < list.size(); i++) {
|
||||||
kw = list.get(i);
|
kw = list.get(i);
|
||||||
|
|
||||||
|
|
||||||
if(kw.equals("Protection from creatures") || kw.equals("Protection from everything")) return false;
|
if(kw.equals("Protection from creatures") || kw.equals("Protection from everything")) return false;
|
||||||
if(kw.equals("Protection from artifacts") && blocker.isArtifact()) return false;
|
if(kw.equals("Protection from artifacts") && blocker.isArtifact()) return false;
|
||||||
|
|
||||||
@@ -864,6 +866,7 @@ public class CombatUtil {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public static boolean isDoranInPlay() {
|
public static boolean isDoranInPlay() {
|
||||||
CardList all = new CardList();
|
CardList all = new CardList();
|
||||||
|
|||||||
Reference in New Issue
Block a user