mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- 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:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user