mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Merge branch 'fixnpe' into 'master'
Fix NPE See merge request core-developers/forge!5141
This commit is contained in:
@@ -407,6 +407,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
if (num.contains("X") && sa.getSVar("X").equals("Count$xPaid")) {
|
if (num.contains("X") && sa.getSVar("X").equals("Count$xPaid")) {
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
int xPay = ComputerUtilCost.getMaxXValue(sa, ai);
|
int xPay = ComputerUtilCost.getMaxXValue(sa, ai);
|
||||||
|
if (xPay == 0) return false;
|
||||||
xPay = Math.min(xPay, list.size());
|
xPay = Math.min(xPay, list.size());
|
||||||
sa.setXManaCostPaid(xPay);
|
sa.setXManaCostPaid(xPay);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ public final class CardRules implements ICardCharacteristics {
|
|||||||
String key = colonPos > 0 ? line.substring(0, colonPos) : line;
|
String key = colonPos > 0 ? line.substring(0, colonPos) : line;
|
||||||
String value = colonPos > 0 ? line.substring(1+colonPos).trim() : null;
|
String value = colonPos > 0 ? line.substring(1+colonPos).trim() : null;
|
||||||
|
|
||||||
switch(key.charAt(0)) {
|
switch (key.charAt(0)) {
|
||||||
case 'A':
|
case 'A':
|
||||||
if ("A".equals(key)) {
|
if ("A".equals(key)) {
|
||||||
this.faces[curFace].addAbility(value);
|
this.faces[curFace].addAbility(value);
|
||||||
|
|||||||
@@ -759,7 +759,6 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////// Utility methods
|
///////// Utility methods
|
||||||
public static boolean isACardType(final String cardType) {
|
public static boolean isACardType(final String cardType) {
|
||||||
return CoreType.isValidEnum(cardType);
|
return CoreType.isValidEnum(cardType);
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ public class PrintSheet {
|
|||||||
|
|
||||||
private final ItemPool<PaperCard> cardsWithWeights;
|
private final ItemPool<PaperCard> cardsWithWeights;
|
||||||
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
public PrintSheet(String name0) {
|
public PrintSheet(String name0) {
|
||||||
this(name0, null);
|
this(name0, null);
|
||||||
|
|||||||
@@ -43,9 +43,8 @@ public class DeckGenPool implements IDeckGenPool {
|
|||||||
Iterable<PaperCard> editionCards=Iterables.filter(cards.values(), filter);
|
Iterable<PaperCard> editionCards=Iterables.filter(cards.values(), filter);
|
||||||
if (editionCards.iterator().hasNext()){
|
if (editionCards.iterator().hasNext()){
|
||||||
return editionCards.iterator().next();
|
return editionCards.iterator().next();
|
||||||
}else {
|
|
||||||
return getCard(name);
|
|
||||||
}
|
}
|
||||||
|
return getCard(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ package forge.item;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filtering conditions for miscellaneous InventoryItems.
|
* Filtering conditions for miscellaneous InventoryItems.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -349,4 +349,3 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
|
|||||||
|| (this.getName().equals("Mountain"));
|
|| (this.getName().equals("Mountain"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class PaperToken implements InventoryItemFromSet, IPaperCard {
|
|||||||
build.add(subtypes);
|
build.add(subtypes);
|
||||||
|
|
||||||
// Are these keywords sorted?
|
// Are these keywords sorted?
|
||||||
for(String keyword : rules.getMainPart().getKeywords()) {
|
for (String keyword : rules.getMainPart().getKeywords()) {
|
||||||
build.add(keyword);
|
build.add(keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -366,7 +366,6 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
|
|||||||
if (!Expressions.compare(left, presentCompare, right)) {
|
if (!Expressions.compare(left, presentCompare, right)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("IsPresent2")) {
|
if (params.containsKey("IsPresent2")) {
|
||||||
|
|||||||
@@ -1905,7 +1905,6 @@ public class GameAction {
|
|||||||
game.getTriggerHandler().runTrigger(TriggerType.NewGame, AbilityKey.newMap(), true);
|
game.getTriggerHandler().runTrigger(TriggerType.NewGame, AbilityKey.newMap(), true);
|
||||||
//</THIS CODE WILL WORK WITH PHASE = NULL>
|
//</THIS CODE WILL WORK WITH PHASE = NULL>
|
||||||
|
|
||||||
|
|
||||||
game.getPhaseHandler().startFirstTurn(first, startGameHook);
|
game.getPhaseHandler().startFirstTurn(first, startGameHook);
|
||||||
//after game ends, ensure Auto-Pass canceled for all players so it doesn't apply to next game
|
//after game ends, ensure Auto-Pass canceled for all players so it doesn't apply to next game
|
||||||
for (Player p : game.getRegisteredPlayers()) {
|
for (Player p : game.getRegisteredPlayers()) {
|
||||||
@@ -1980,7 +1979,6 @@ public class GameAction {
|
|||||||
private void runPreOpeningHandActions(final Player first) {
|
private void runPreOpeningHandActions(final Player first) {
|
||||||
Player takesAction = first;
|
Player takesAction = first;
|
||||||
do {
|
do {
|
||||||
//
|
|
||||||
List<Card> ploys = CardLists.filter(takesAction.getCardsIn(ZoneType.Command), new Predicate<Card>() {
|
List<Card> ploys = CardLists.filter(takesAction.getCardsIn(ZoneType.Command), new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Card input) {
|
public boolean apply(Card input) {
|
||||||
@@ -2054,8 +2052,7 @@ public class GameAction {
|
|||||||
public void invoke(final Runnable proc) {
|
public void invoke(final Runnable proc) {
|
||||||
if (ThreadUtil.isGameThread()) {
|
if (ThreadUtil.isGameThread()) {
|
||||||
proc.run();
|
proc.run();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ThreadUtil.invokeInGameThread(proc);
|
ThreadUtil.invokeInGameThread(proc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1282,7 +1282,8 @@ public class AbilityUtils {
|
|||||||
}
|
}
|
||||||
else if (defined.equals("Opponent")) {
|
else if (defined.equals("Opponent")) {
|
||||||
players.addAll(player.getOpponents());
|
players.addAll(player.getOpponents());
|
||||||
} else if (defined.startsWith("NextPlayerToYour")) {
|
}
|
||||||
|
else if (defined.startsWith("NextPlayerToYour")) {
|
||||||
Direction dir = defined.substring(16).equals("Left") ? Direction.Left : Direction.Right;
|
Direction dir = defined.substring(16).equals("Left") ? Direction.Left : Direction.Right;
|
||||||
players.add(game.getNextPlayerAfter(player, dir));
|
players.add(game.getNextPlayerAfter(player, dir));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,15 @@
|
|||||||
package forge.game.ability.effects;
|
package forge.game.ability.effects;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import forge.StaticData;
|
import forge.StaticData;
|
||||||
import forge.card.CardFacePredicates;
|
import forge.card.CardFacePredicates;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
import forge.card.CardRulesPredicates;
|
|
||||||
import forge.card.CardSplitType;
|
import forge.card.CardSplitType;
|
||||||
import forge.card.ICardFace;
|
import forge.card.ICardFace;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
@@ -26,9 +20,7 @@ import forge.game.card.CardLists;
|
|||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.TargetRestrictions;
|
import forge.game.spellability.TargetRestrictions;
|
||||||
import forge.item.PaperCard;
|
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
import forge.util.ComparableOp;
|
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
|
|
||||||
public class ChooseCardNameEffect extends SpellAbilityEffect {
|
public class ChooseCardNameEffect extends SpellAbilityEffect {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import com.google.common.collect.Sets;
|
|||||||
|
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.GameEntity;
|
import forge.game.GameEntity;
|
||||||
|
import forge.game.GameStage;
|
||||||
import forge.game.IHasSVars;
|
import forge.game.IHasSVars;
|
||||||
import forge.game.TriggerReplacementBase;
|
import forge.game.TriggerReplacementBase;
|
||||||
import forge.game.ability.AbilityFactory;
|
import forge.game.ability.AbilityFactory;
|
||||||
@@ -347,8 +348,9 @@ public abstract class Trigger extends TriggerReplacementBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// host controller will be null when adding card in a simulation game
|
// host controller will be null when adding card in a simulation game
|
||||||
if (this.getHostCard().getController() == null || !meetsCommonRequirements(this.mapParams))
|
if (this.getHostCard().getController() == null || game.getAge() != GameStage.Play || !meetsCommonRequirements(this.mapParams)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user