CombatUtil: updated CantBeBlockedBy CantBlock to work with multiple instances

turn Dragon Hunter Effect into a keyword like thing to work better with Text Change
This commit is contained in:
Hanmac
2017-01-19 06:09:51 +00:00
parent 50e17d0080
commit 7c29bcf5b9
4 changed files with 47 additions and 24 deletions

View File

@@ -1508,6 +1508,11 @@ public class Card extends GameEntity implements Comparable<Card> {
sbLong.append(getName()).append(" can't be blocked.\r\n");
} else if (keyword.equals("AllNonLegendaryCreatureNames")) {
sbLong.append(getName()).append(" has all names of nonlegendary creature cards.\r\n");
} else if (keyword.startsWith("IfReach")) {
String k[] = keyword.split(":");
sbLong.append(getName()).append(" can block ")
.append(CardUtil.getPluralType(k[1]))
.append(" as though it had reach.\r\n");
}
else {
if ((i != 0) && (sb.length() != 0)) {

View File

@@ -57,7 +57,7 @@ public final class CardUtil {
"Cycling", "Echo", "Kicker", "Flashback", "Madness", "Morph",
"Affinity", "Entwine", "Splice", "Ninjutsu", "Presence",
"Transmute", "Replicate", "Recover", "Suspend", "Aura swap",
"Fortify", "Transfigure", "Champion", "Evoke", "Prowl",
"Fortify", "Transfigure", "Champion", "Evoke", "Prowl", "IfReach",
"Reinforce", "Unearth", "Level up", "Miracle", "Overload",
"Scavenge", "Bestow", "Outlast", "Dash", "Renown", "Surge", "Emerge").build();
/** List of keyword endings of keywords that could be modified by text changes. */

View File

@@ -968,30 +968,38 @@ public class CombatUtil {
return false;
}
if (attacker.hasStartOfKeyword("CantBeBlockedBy ")) {
final int keywordPosition = attacker.getKeywordPosition("CantBeBlockedBy ");
final String parse = attacker.getKeywords().get(keywordPosition).toString();
final String[] k = parse.split(" ", 2);
final String[] restrictions = k[1].split(",");
if (blocker.isValid(restrictions, attacker.getController(), attacker, null)) {
//Dragon Hunter check
if (!k[1].contains("withoutReach") || !attacker.getType().hasCreatureType("Dragon")
|| !blocker.hasKeyword("CARDNAME can block Dragons as though it had reach.")) {
return false;
}
for (String k : attacker.getKeywords()) {
if (k.startsWith("CantBeBlockedBy ")) {
final String[] n = k.split(" ", 2);
final String[] restrictions = n[1].split(",");
if (blocker.isValid(restrictions, attacker.getController(), attacker, null)) {
boolean stillblock = false;
//Dragon Hunter check
if (n[1].contains("withoutReach") && blocker.hasStartOfKeyword("IfReach")) {
for (String k2 : blocker.getKeywords()) {
if (k2.startsWith("IfReach")) {
String n2[] = k2.split(":");
if (attacker.getType().hasCreatureType(n2[1])) {
stillblock = true;
break;
}
}
}
}
if (!stillblock) {
return false;
}
}
}
}
if (blocker.hasStartOfKeyword("CantBlock")) {
final int keywordPosition = blocker.getKeywordPosition("CantBlock");
final String parse = blocker.getKeywords().get(keywordPosition).toString();
if (parse.startsWith("CantBlockCardUID")) {
final String[] k = parse.split("_", 2);
for (String keyword : attacker.getKeywords()) {
if (keyword.startsWith("CantBlockCardUID")) {
final String[] k = keyword.split("_", 2);
if (attacker.getId() == Integer.parseInt(k[1])) {
return false;
}
} else {
final String[] parse0 = parse.split(":");
} else if (keyword.startsWith("CantBlock")) {
final String[] parse0 = keyword.split(":");
final String[] k = parse0[0].split(" ", 2);
final String[] restrictions = k[1].split(",");
if (attacker.isValid(restrictions, blocker.getController(), blocker, null)) {
@@ -1005,9 +1013,19 @@ public class CombatUtil {
}
if (attacker.hasKeyword("Flying") && !blocker.hasKeyword("Flying") && !blocker.hasKeyword("Reach")) {
if (!attacker.getType().hasCreatureType("Dragon") || !blocker.hasKeyword("CARDNAME can block Dragons as though it had reach.")) {
return false;
}
boolean stillblock = false;
for (String k : blocker.getKeywords()) {
if (k.startsWith("IfReach")) {
String n[] = k.split(":");
if (attacker.getType().hasCreatureType(n[1])) {
stillblock = true;
break;
}
}
}
if (!stillblock) {
return false;
}
}
if (attacker.hasKeyword("Horsemanship") && !blocker.hasKeyword("Horsemanship")) {

View File

@@ -3,6 +3,6 @@ ManaCost:W
Types:Creature Human Warrior
PT:2/1
K:Protection from Dragons
K:CARDNAME can block Dragons as though it had reach.
K:IfReach:Dragon
SVar:Picture:http://www.wizards.com/global/images/magic/general/dragon_hunter.jpg
Oracle:Protection from Dragons\nDragon Hunter can block Dragons as though it had reach.