"can be blocked only by creatures with defender" now also uses a common keyword

This commit is contained in:
Maxmtg
2013-06-21 14:47:44 +00:00
parent f3876079a9
commit 1d498a5ba3
5 changed files with 23 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ ManaCost:2 U
Types:Enchantment Aura
K:Enchant creature
A:SP$ Attach | Cost$ 2 U | ValidTgts$ Creature | AILogic$ Pump
S:Mode$ Continuous | Affected$ Creature.enchanted+YouCtrl | AddPower$ 1 | AddToughness$ 1 | AddHiddenKeyword$ CARDNAME can't be blocked except by creatures with defender. | Description$ Creatures you control that are enchanted get +1/+1 and can't be blocked except by creatures with defender.
S:Mode$ Continuous | Affected$ Creature.enchanted+YouCtrl | AddPower$ 1 | AddToughness$ 1 | AddKeyword$ CantBeBlockedBy Creature.withoutDefender | Description$ Creatures you control that are enchanted get +1/+1 and can't be blocked except by creatures with defender.
SVar:Picture:http://www.wizards.com/global/images/magic/general/infiltrators_magemark.jpg
Oracle:Enchant creature\nCreatures you control that are enchanted get +1/+1 and can't be blocked except by creatures with defender.
SetInfo:GPT Common

View File

@@ -1,7 +1,6 @@
Name:Noggle Bandit
ManaCost:1 UR UR
Types:Creature Noggle Rogue
Text:CARDNAME can't be blocked except by creatures with defender.
PT:2/2
K:CantBeBlockedBy Creature.withoutDefender
SVar:Picture:http://www.wizards.com/global/images/magic/general/noggle_bandit.jpg

View File

@@ -77,6 +77,7 @@ import forge.game.player.Player;
import forge.game.zone.Zone;
import forge.game.zone.ZoneType;
import forge.util.Expressions;
import forge.util.Lang;
import forge.util.TextUtil;
/**
@@ -2123,17 +2124,29 @@ public class Card extends GameEntity implements Comparable<Card> {
continue;
} else if (keyword.startsWith("CantBeBlockedBy")) {
String expression = keyword.split(" ", 2)[1];
boolean hasNon = expression.contains("non");
boolean hasNon = expression.contains("non") || expression.contains("without");
sbLong.append(this.getName()).append(" cannot be blocked ");
if( hasNon ) sbLong.append("except ");
sbLong.append("by ");
String[] parts = TextUtil.split(expression, '.');
List<String> partsAfterCreatures = new ArrayList<String>();
for(String part : parts) {
if( part.equalsIgnoreCase("creature"))
continue;
sbLong.append(part.toLowerCase()).append(" ");
if(part.startsWith("with"))
{
int cutIdx = part.startsWith("without") ? 7 : 4;
partsAfterCreatures.add(StringUtils.capitalize(part.substring(cutIdx)));
}
else
sbLong.append(part.toLowerCase()).append(" ");
}
sbLong.append("creatures");
if( !partsAfterCreatures.isEmpty() ) {
sbLong.append(" with ");
sbLong.append(Lang.joinHomogenous(partsAfterCreatures, null, hasNon ? "or" : "and"));
}
sbLong.append("creatures");
}
else {

View File

@@ -691,10 +691,6 @@ public class CombatUtil {
}
}
if (attacker.hasKeyword("CARDNAME can't be blocked except by creatures with defender.") && !blocker.hasKeyword("Defender")) {
return false;
}
if (attacker.hasKeyword("Horsemanship")) {
if (!blocker.hasKeyword("Horsemanship")) {
return false;

View File

@@ -36,8 +36,11 @@ public class Lang {
return has1 ? (has2 ? s1 + " and " + s2 : s1) : (has2 ? s2 : "");
}
public static <T> String joinHomogenous(Collection<T> objects) { return joinHomogenous(objects, null); }
public static <T> String joinHomogenous(Collection<T> objects) { return joinHomogenous(objects, null, "and"); }
public static <T> String joinHomogenous(Collection<T> objects, Function<T, String> accessor) {
return joinHomogenous(objects, accessor, "and");
}
public static <T> String joinHomogenous(Collection<T> objects, Function<T, String> accessor, String lastUnion) {
int remaining = objects.size();
StringBuilder sb = new StringBuilder();
for(T obj : objects) {
@@ -47,11 +50,12 @@ public class Lang {
else
sb.append(obj);
if( remaining > 1 ) sb.append(", ");
if( remaining == 1 ) sb.append(" and ");
if( remaining == 1 ) sb.append(" ").append(lastUnion).append(" ");
}
return sb.toString();
}
public static <T> String joinVerb(List<T> subjects, String verb) {
// English is simple - just add (s) for multiple objects.
return subjects.size() > 1 ? verb : verb + "s";