- Improved handling of script execution in GameState to support subabilities and KW Awaken (other keywords with mana cost might need similar treatment later).

This commit is contained in:
Agetian
2017-08-21 04:50:49 +00:00
parent 1aa8475295
commit 13376d0ced

View File

@@ -652,6 +652,28 @@ public abstract class GameState {
System.err.println("ERROR: Unable to find SA with index " + numSA + " on card " + c + " to execute!"); System.err.println("ERROR: Unable to find SA with index " + numSA + " on card " + c + " to execute!");
} }
} else { } else {
// Special handling for keyworded abilities
if (sPtr.startsWith("KW#")) {
String kwName = sPtr.substring(3);
FCollectionView<SpellAbility> saList = c.getSpellAbilities();
if (kwName.equals("Awaken")) {
for (SpellAbility ab : saList) {
if (ab.getDescription().startsWith("Awaken")) {
ab.setActivatingPlayer(c.getController());
ab.getSubAbility().setActivatingPlayer(c.getController());
sa = ab;
// target for Awaken is set in its first subability
handleScriptedTargetingForSA(game, sa.getSubAbility(), tgtID);
}
}
if (sa == null) {
System.err.println("ERROR: Could not locate keyworded ability Awaken in card " + c + " to execute!");
return;
}
}
} else {
// SVar-based script execution
if (!c.hasSVar(sPtr)) { if (!c.hasSVar(sPtr)) {
System.err.println("ERROR: Unable to find SVar " + sPtr + " on card " + c + " + to execute!"); System.err.println("ERROR: Unable to find SVar " + sPtr + " on card " + c + " + to execute!");
return; return;
@@ -663,11 +685,19 @@ public abstract class GameState {
System.err.println("ERROR: Unable to generate ability for SVar " + svarValue); System.err.println("ERROR: Unable to generate ability for SVar " + svarValue);
} }
} }
}
sa.setActivatingPlayer(c.getController()); sa.setActivatingPlayer(c.getController());
handleScriptedTargetingForSA(game, sa, tgtID); handleScriptedTargetingForSA(game, sa, tgtID);
sa.resolve(); sa.resolve();
// resolve subabilities
SpellAbility subSa = sa.getSubAbility();
while (subSa != null) {
subSa.resolve();
subSa = subSa.getSubAbility();
}
} }
private void handlePrecastSpells(final Game game) { private void handlePrecastSpells(final Game game) {