White Ward problem
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
1 post
• Page 1 of 1
White Ward problem
by Chris H. » 26 Apr 2010, 23:17
Someone mentioned that they had a problem with the White Ward. I tracked down the code responsible in CardFactoryUtil.hasProtectionFrom(). I made a slight addition to the checks and White Ward will no longer remove itself via the protection from white that it gives to the enchanted creature:

- Code: Select all
//does "target" have protection from "card"?
public static boolean hasProtectionFrom(Card card, Card target) {
if(target == null) return false;
if(target.getKeyword() != null) {
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") && CardUtil.getColors(card).contains(Constant.Color.White) &&
!card.getName().contains("White Ward")) return true;
if(kw.equals("Protection from blue") && CardUtil.getColors(card).contains(Constant.Color.Blue) &&
!card.getName().contains("Blue Ward")) return true;
if(kw.equals("Protection from black") && CardUtil.getColors(card).contains(Constant.Color.Black) &&
!card.getName().contains("Black Ward")) return true;
if(kw.equals("Protection from red") && CardUtil.getColors(card).contains(Constant.Color.Red) &&
!card.getName().contains("Red Ward")) return true;
if(kw.equals("Protection from green") && CardUtil.getColors(card).contains(Constant.Color.Green) &&
!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() &&
!card.getName().contains("Artifact Ward")) return true;
if(kw.equals("Protection from everything")) return true;
if(kw.equals("Protection from Dragons")
&& (card.getType().contains("Dragon") || card.getKeyword().contains("Changeling"))) return true;
if(kw.equals("Protection from Demons")
&& (card.getType().contains("Demon") || card.getKeyword().contains("Changeling"))) return true;
if(kw.equals("Protection from Goblins")
&& (card.getType().contains("Goblin") || card.getKeyword().contains("Changeling"))) return true;
if(kw.equals("Protection from enchantments") && card.getType().contains("Enchantment") &&
!card.getName().contains("Tattoo Ward")) return true;
}
}
return false;
}
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 59 guests