CantBeBlockedBy - attempts to build keyword description

This commit is contained in:
Maxmtg
2013-06-21 14:08:30 +00:00
parent dc390b796d
commit f3876079a9
2 changed files with 17 additions and 15 deletions

View File

@@ -77,6 +77,7 @@ import forge.game.player.Player;
import forge.game.zone.Zone; import forge.game.zone.Zone;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import forge.util.Expressions; import forge.util.Expressions;
import forge.util.TextUtil;
/** /**
* <p> * <p>
@@ -1977,7 +1978,6 @@ public class Card extends GameEntity implements Comparable<Card> {
if (keyword.startsWith("Permanents don't untap during their controllers' untap steps") if (keyword.startsWith("Permanents don't untap during their controllers' untap steps")
|| keyword.startsWith("PreventAllDamageBy") || keyword.startsWith("PreventAllDamageBy")
|| keyword.startsWith("CantBlock") || keyword.startsWith("CantBlock")
|| keyword.startsWith("CantBeBlockedBy")
|| keyword.startsWith("CantEquip") || keyword.startsWith("CantEquip")
|| keyword.startsWith("SpellCantTarget")) { || keyword.startsWith("SpellCantTarget")) {
continue; continue;
@@ -2121,7 +2121,22 @@ public class Card extends GameEntity implements Comparable<Card> {
} else if (keyword.startsWith("Equip") || keyword.startsWith("Fortification")) { } else if (keyword.startsWith("Equip") || keyword.startsWith("Fortification")) {
// keyword parsing takes care of adding a proper description // keyword parsing takes care of adding a proper description
continue; continue;
} else { } else if (keyword.startsWith("CantBeBlockedBy")) {
String expression = keyword.split(" ", 2)[1];
boolean hasNon = expression.contains("non");
sbLong.append(this.getName()).append(" cannot be blocked ");
if( hasNon ) sbLong.append("except ");
sbLong.append("by ");
String[] parts = TextUtil.split(expression, '.');
for(String part : parts) {
if( part.equalsIgnoreCase("creature"))
continue;
sbLong.append(part.toLowerCase()).append(" ");
}
sbLong.append("creatures");
}
else {
if ((i != 0) && (sb.length() != 0)) { if ((i != 0) && (sb.length() != 0)) {
sb.append(", "); sb.append(", ");
} }

View File

@@ -680,19 +680,6 @@ public class CombatUtil {
} }
} }
if (attacker.hasKeyword("CARDNAME can't be blocked by black creatures.") && blocker.isBlack()) {
return false;
}
if (attacker.hasKeyword("CARDNAME can't be blocked by blue creatures.") && blocker.isBlue()) {
return false;
}
if (attacker.hasKeyword("CARDNAME can't be blocked by green creatures.") && blocker.isGreen()) {
return false;
}
if (attacker.hasKeyword("CARDNAME can't be blocked by white creatures.") && blocker.isWhite()) {
return false;
}
if (blocker.hasKeyword("CARDNAME can block only creatures with flying.") && !attacker.hasKeyword("Flying")) { if (blocker.hasKeyword("CARDNAME can block only creatures with flying.") && !attacker.hasKeyword("Flying")) {
return false; return false;
} }