It is currently 15 Jun 2025, 16:04
   
Text Size

CARDNAME can't block creatures with power ...

Post MTG Forge Related Programming Questions Here

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

CARDNAME can't block creatures with power ...

Postby Chris H. » 15 Apr 2010, 12:57

CARDNAME can't block creatures with power {rest of text string}


This keyword is for the various cards that are based upon the Ironclaw Orcs type of ability. The keyword currently has this format:

Code: Select all
CARDNAME can't block creatures with power {rest of text string}
`
The most common form will look like:

Code: Select all
CARDNAME can't block creatures with power {num} or {"greater." or "less."}
`
There are two other forms that will be recognized at this time. The cards which use this keyword have one of the following forms:

Code: Select all
CARDNAME can't block creatures with power 2 or greater.
CARDNAME can't block creatures with power 3 or greater.
CARDNAME can't block creatures with power 2 or less.
CARDNAME can't block creatures with power greater than CARDNAME's power.
CARDNAME can't block creatures with power equal to or greater than CARDNAME's toughness.
`
The cards.txt entries will look like this:

Code: Select all
Brassclaw Orcs
2 R
Creature Orc
no text
3/2
CARDNAME can't block creatures with power 2 or greater.

Ironclaw Buzzardiers
2 R
Creature Orc Scout
no text
2/2
CARDNAME can't block creatures with power 2 or greater.
abPump R:Flying

Ironclaw Curse
R
Enchantment Aura
Enchanted creature gets -0/-1 and can't block creatures with power equal to or greater than the enchanted creature's toughness.
Enchant creature
enPumpCurse:-0/-1/CARDNAME can't block creatures with power equal to or greater than CARDNAME's toughness.

Ironclaw Orcs
1 R
Creature Orc
no text
2/2
CARDNAME can't block creatures with power 2 or greater.

Spitfire Handler
1 R
Creature Goblin
no text
1/1
CARDNAME can't block creatures with power greater than CARDNAME's power.
abPump R:+1/+0

Sunweb
3 W
Creature Wall
no text
5/6
Flying
Defender
CARDNAME can't block creatures with power 2 or less.
`
The following cards will need additional code to implement:


Near the top of CombatUtil.java in the canBlock() method:

Code: Select all
//      if(attacker.getNetAttack() <= 2 && blocker.getName().equals("Sunweb")) return false;
//      if(attacker.getNetAttack() >= 2 && blocker.getName().equals("Ironclaw Orcs")) return false;

        // CARDNAME can't block creatures with power ...

        int powerLimit[] = {0};
        int keywordPosition = 0;
        boolean hasKeyword = false;
       
        ArrayList<String> blockerKeywords = blocker.getKeyword();
        for (int i = 0; i < blockerKeywords.size(); i++) {
           if (blockerKeywords.get(i).toString().startsWith("CARDNAME can't block creatures with power")) {
              hasKeyword = true;
              keywordPosition = i;
           }
        }
       
        if (hasKeyword) {    // The keyword "CARDNAME can't block creatures with power" ... is present
           String tmpString = blocker.getKeyword().get(keywordPosition).toString();
           String asSeparateWords[]  = tmpString.trim().split(" ");
           
           if (asSeparateWords.length >= 9) {
              if (asSeparateWords[6].matches("[0-9][0-9]?")) {
                 powerLimit[0] = Integer.parseInt((asSeparateWords[6]).trim());
                 
                 if (attacker.getNetAttack() >= powerLimit[0] && blocker.getKeyword().contains
                       ("CARDNAME can't block creatures with power " + powerLimit[0] + " or greater.")) return false;
                 if (attacker.getNetAttack() <= powerLimit[0] && blocker.getKeyword().contains
                       ("CARDNAME can't block creatures with power " + powerLimit[0] + " or less.")) return false;
              }
           }
           
           if (attacker.getNetAttack() > blocker.getNetAttack()
               && blocker.getKeyword().contains("CARDNAME can't block creatures with power greater than CARDNAME's power.")) return false;
           if (attacker.getNetAttack() >= blocker.getNetDefense()
                 && blocker.getKeyword().contains("CARDNAME can't block creatures with power equal to or greater than CARDNAME's toughness.")) return false;
           
        }// hasKeyword CARDNAME can't block creatures with power ...
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 25 guests


Who is online

In total there are 25 users online :: 0 registered, 0 hidden and 25 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 25 guests

Login Form