mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
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:
@@ -1508,6 +1508,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
sbLong.append(getName()).append(" can't be blocked.\r\n");
|
sbLong.append(getName()).append(" can't be blocked.\r\n");
|
||||||
} else if (keyword.equals("AllNonLegendaryCreatureNames")) {
|
} else if (keyword.equals("AllNonLegendaryCreatureNames")) {
|
||||||
sbLong.append(getName()).append(" has all names of nonlegendary creature cards.\r\n");
|
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 {
|
else {
|
||||||
if ((i != 0) && (sb.length() != 0)) {
|
if ((i != 0) && (sb.length() != 0)) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public final class CardUtil {
|
|||||||
"Cycling", "Echo", "Kicker", "Flashback", "Madness", "Morph",
|
"Cycling", "Echo", "Kicker", "Flashback", "Madness", "Morph",
|
||||||
"Affinity", "Entwine", "Splice", "Ninjutsu", "Presence",
|
"Affinity", "Entwine", "Splice", "Ninjutsu", "Presence",
|
||||||
"Transmute", "Replicate", "Recover", "Suspend", "Aura swap",
|
"Transmute", "Replicate", "Recover", "Suspend", "Aura swap",
|
||||||
"Fortify", "Transfigure", "Champion", "Evoke", "Prowl",
|
"Fortify", "Transfigure", "Champion", "Evoke", "Prowl", "IfReach",
|
||||||
"Reinforce", "Unearth", "Level up", "Miracle", "Overload",
|
"Reinforce", "Unearth", "Level up", "Miracle", "Overload",
|
||||||
"Scavenge", "Bestow", "Outlast", "Dash", "Renown", "Surge", "Emerge").build();
|
"Scavenge", "Bestow", "Outlast", "Dash", "Renown", "Surge", "Emerge").build();
|
||||||
/** List of keyword endings of keywords that could be modified by text changes. */
|
/** List of keyword endings of keywords that could be modified by text changes. */
|
||||||
|
|||||||
@@ -968,30 +968,38 @@ public class CombatUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attacker.hasStartOfKeyword("CantBeBlockedBy ")) {
|
for (String k : attacker.getKeywords()) {
|
||||||
final int keywordPosition = attacker.getKeywordPosition("CantBeBlockedBy ");
|
if (k.startsWith("CantBeBlockedBy ")) {
|
||||||
final String parse = attacker.getKeywords().get(keywordPosition).toString();
|
final String[] n = k.split(" ", 2);
|
||||||
final String[] k = parse.split(" ", 2);
|
final String[] restrictions = n[1].split(",");
|
||||||
final String[] restrictions = k[1].split(",");
|
|
||||||
if (blocker.isValid(restrictions, attacker.getController(), attacker, null)) {
|
if (blocker.isValid(restrictions, attacker.getController(), attacker, null)) {
|
||||||
|
boolean stillblock = false;
|
||||||
//Dragon Hunter check
|
//Dragon Hunter check
|
||||||
if (!k[1].contains("withoutReach") || !attacker.getType().hasCreatureType("Dragon")
|
if (n[1].contains("withoutReach") && blocker.hasStartOfKeyword("IfReach")) {
|
||||||
|| !blocker.hasKeyword("CARDNAME can block Dragons as though it had reach.")) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (blocker.hasStartOfKeyword("CantBlock")) {
|
for (String keyword : attacker.getKeywords()) {
|
||||||
final int keywordPosition = blocker.getKeywordPosition("CantBlock");
|
if (keyword.startsWith("CantBlockCardUID")) {
|
||||||
final String parse = blocker.getKeywords().get(keywordPosition).toString();
|
final String[] k = keyword.split("_", 2);
|
||||||
if (parse.startsWith("CantBlockCardUID")) {
|
|
||||||
final String[] k = parse.split("_", 2);
|
|
||||||
if (attacker.getId() == Integer.parseInt(k[1])) {
|
if (attacker.getId() == Integer.parseInt(k[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (keyword.startsWith("CantBlock")) {
|
||||||
final String[] parse0 = parse.split(":");
|
final String[] parse0 = keyword.split(":");
|
||||||
final String[] k = parse0[0].split(" ", 2);
|
final String[] k = parse0[0].split(" ", 2);
|
||||||
final String[] restrictions = k[1].split(",");
|
final String[] restrictions = k[1].split(",");
|
||||||
if (attacker.isValid(restrictions, blocker.getController(), blocker, null)) {
|
if (attacker.isValid(restrictions, blocker.getController(), blocker, null)) {
|
||||||
@@ -1005,7 +1013,17 @@ public class CombatUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attacker.hasKeyword("Flying") && !blocker.hasKeyword("Flying") && !blocker.hasKeyword("Reach")) {
|
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.")) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ ManaCost:W
|
|||||||
Types:Creature Human Warrior
|
Types:Creature Human Warrior
|
||||||
PT:2/1
|
PT:2/1
|
||||||
K:Protection from Dragons
|
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
|
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.
|
Oracle:Protection from Dragons\nDragon Hunter can block Dragons as though it had reach.
|
||||||
|
|||||||
Reference in New Issue
Block a user