mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
"can be blocked only by creatures with defender" now also uses a common keyword
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user