It is currently 09 Sep 2025, 17:12
   
Text Size

White Ward problem

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

White Ward problem

Postby 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: :mrgreen:

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;
    }
User avatar
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

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 59 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 59 users online :: 0 registered, 0 hidden and 59 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 59 guests

Login Form