mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Actually fix the crash in TokenAI.spawnToken for Attacking tokens
This commit is contained in:
@@ -8,7 +8,6 @@ import forge.game.GameEntity;
|
|||||||
import forge.game.ability.AbilityFactory;
|
import forge.game.ability.AbilityFactory;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.ability.ApiType;
|
import forge.game.ability.ApiType;
|
||||||
import forge.game.ability.effects.TokenEffect;
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardCollection;
|
import forge.game.card.CardCollection;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -61,9 +60,7 @@ public class TokenAi extends SpellAbilityAi {
|
|||||||
private void readParameters(final SpellAbility mapParams) {
|
private void readParameters(final SpellAbility mapParams) {
|
||||||
this.tokenAmount = mapParams.getParamOrDefault("TokenAmount", "1");
|
this.tokenAmount = mapParams.getParamOrDefault("TokenAmount", "1");
|
||||||
|
|
||||||
TokenEffect effect = new TokenEffect();
|
this.actualToken = TokenInfo.getProtoType(mapParams.getParam("TokenScript"), mapParams);
|
||||||
|
|
||||||
this.actualToken = effect.loadTokenPrototype(mapParams);
|
|
||||||
|
|
||||||
if (actualToken == null) {
|
if (actualToken == null) {
|
||||||
String[] keywords;
|
String[] keywords;
|
||||||
@@ -394,6 +391,7 @@ public class TokenAi extends SpellAbilityAi {
|
|||||||
* @param sa Token SpellAbility
|
* @param sa Token SpellAbility
|
||||||
* @return token creature created by ability
|
* @return token creature created by ability
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static Card spawnToken(Player ai, SpellAbility sa) {
|
public static Card spawnToken(Player ai, SpellAbility sa) {
|
||||||
return spawnToken(ai, sa, false);
|
return spawnToken(ai, sa, false);
|
||||||
}
|
}
|
||||||
@@ -406,9 +404,17 @@ public class TokenAi extends SpellAbilityAi {
|
|||||||
* @return token creature created by ability
|
* @return token creature created by ability
|
||||||
*/
|
*/
|
||||||
// TODO Is this just completely copied from TokenEffect? Let's just call that thing
|
// TODO Is this just completely copied from TokenEffect? Let's just call that thing
|
||||||
|
@Deprecated
|
||||||
public static Card spawnToken(Player ai, SpellAbility sa, boolean notNull) {
|
public static Card spawnToken(Player ai, SpellAbility sa, boolean notNull) {
|
||||||
final Card host = sa.getHostCard();
|
final Card host = sa.getHostCard();
|
||||||
|
|
||||||
|
Card result = TokenInfo.getProtoType(sa.getParam("TokenScript"), sa);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
result.setController(ai, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
String[] tokenKeywords = sa.hasParam("TokenKeywords") ? sa.getParam("TokenKeywords").split("<>") : new String[0];
|
String[] tokenKeywords = sa.hasParam("TokenKeywords") ? sa.getParam("TokenKeywords").split("<>") : new String[0];
|
||||||
String tokenPower = sa.getParam("TokenPower");
|
String tokenPower = sa.getParam("TokenPower");
|
||||||
String tokenToughness = sa.getParam("TokenToughness");
|
String tokenToughness = sa.getParam("TokenToughness");
|
||||||
|
|||||||
Reference in New Issue
Block a user