mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Merge branch 'NPE' into 'master'
Fix some NPE from token table See merge request core-developers/forge!5089
This commit is contained in:
@@ -358,7 +358,8 @@ public class TokenAi extends SpellAbilityAi {
|
|||||||
if (!sa.hasParam("TokenScript")) {
|
if (!sa.hasParam("TokenScript")) {
|
||||||
throw new RuntimeException("Spell Ability has no TokenScript: " + sa);
|
throw new RuntimeException("Spell Ability has no TokenScript: " + sa);
|
||||||
}
|
}
|
||||||
Card result = TokenInfo.getProtoType(sa.getParam("TokenScript"), sa, ai);
|
// TODO for now, only checking the first token is good enough
|
||||||
|
Card result = TokenInfo.getProtoType(sa.getParam("TokenScript").split(",")[0], sa, ai);
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throw new RuntimeException("don't find Token for TokenScript: " + sa.getParam("TokenScript"));
|
throw new RuntimeException("don't find Token for TokenScript: " + sa.getParam("TokenScript"));
|
||||||
|
|||||||
@@ -1319,14 +1319,17 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
}
|
}
|
||||||
if (sa.hasParam("TokenScript")) {
|
if (sa.hasParam("TokenScript")) {
|
||||||
sa.setActivatingPlayer(player);
|
sa.setActivatingPlayer(player);
|
||||||
Card protoType = TokenInfo.getProtoType(sa.getParam("TokenScript"), sa, null);
|
for (String token : sa.getParam("TokenScript").split(",")) {
|
||||||
for (String type : protoType.getType().getCreatureTypes()) {
|
Card protoType = TokenInfo.getProtoType(token, sa, null);
|
||||||
Integer count = typesInDeck.get(type);
|
for (String type : protoType.getType().getCreatureTypes()) {
|
||||||
if (count == null) {
|
Integer count = typesInDeck.get(type);
|
||||||
count = 0;
|
if (count == null) {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
typesInDeck.put(type, count + 1);
|
||||||
}
|
}
|
||||||
typesInDeck.put(type, count + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// same for Trigger that does make Tokens
|
// same for Trigger that does make Tokens
|
||||||
@@ -1335,13 +1338,15 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
if (sa != null) {
|
if (sa != null) {
|
||||||
if (sa.hasParam("TokenScript")) {
|
if (sa.hasParam("TokenScript")) {
|
||||||
sa.setActivatingPlayer(player);
|
sa.setActivatingPlayer(player);
|
||||||
Card protoType = TokenInfo.getProtoType(sa.getParam("TokenScript"), sa, null);
|
for (String token : sa.getParam("TokenScript").split(",")) {
|
||||||
for (String type : protoType.getType().getCreatureTypes()) {
|
Card protoType = TokenInfo.getProtoType(token, sa, null);
|
||||||
Integer count = typesInDeck.get(type);
|
for (String type : protoType.getType().getCreatureTypes()) {
|
||||||
if (count == null) {
|
Integer count = typesInDeck.get(type);
|
||||||
count = 0;
|
if (count == null) {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
typesInDeck.put(type, count + 1);
|
||||||
}
|
}
|
||||||
typesInDeck.put(type, count + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user