mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Get rid of global static Card cache and hang it off the Game instead.
This paves the way for having multiple simulataneous game objects (e.g. for simulation).
This commit is contained in:
@@ -171,7 +171,7 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!SpellAbilityAi.isSorcerySpeed(sa)) {
|
if (!SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||||
Card animatedCopy = CardFactory.getCard(c.getPaperCard(), aiPlayer);
|
Card animatedCopy = CardFactory.getCard(c.getPaperCard(), aiPlayer, c.getGame());
|
||||||
AnimateAi.becomeAnimated(animatedCopy, c.hasSickness(), sa);
|
AnimateAi.becomeAnimated(animatedCopy, c.hasSickness(), sa);
|
||||||
if (ph.isPlayerTurn(aiPlayer) && !ComputerUtilCard.doesSpecifiedCreatureAttackAI(aiPlayer, animatedCopy)) {
|
if (ph.isPlayerTurn(aiPlayer) && !ComputerUtilCard.doesSpecifiedCreatureAttackAI(aiPlayer, animatedCopy)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import forge.game.card.CardCollection;
|
|||||||
import forge.game.card.CardCollectionView;
|
import forge.game.card.CardCollectionView;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
import forge.game.card.CardPredicates;
|
import forge.game.card.CardPredicates;
|
||||||
|
import forge.game.card.CardView;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
import forge.game.event.GameEvent;
|
import forge.game.event.GameEvent;
|
||||||
import forge.game.event.GameEventGameOutcome;
|
import forge.game.event.GameEventGameOutcome;
|
||||||
@@ -110,9 +111,20 @@ public class Game {
|
|||||||
playerCache.put(id, player);
|
playerCache.put(id, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game(List<RegisteredPlayer> players0, GameRules rules0, Match match0) { /* no more zones to map here */
|
public GameEntityCache<Card, CardView> cardCache = new GameEntityCache<>();
|
||||||
Card.clearCache();
|
public Card getCard(CardView cardView) {
|
||||||
|
return cardCache.get(cardView);
|
||||||
|
}
|
||||||
|
public void addCard(Integer id, Card card) {
|
||||||
|
cardCache.put(id, card);
|
||||||
|
}
|
||||||
|
public CardCollection getCardList(Iterable<CardView> cardViews) {
|
||||||
|
CardCollection list = new CardCollection();
|
||||||
|
cardCache.addToList(cardViews, list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Game(List<RegisteredPlayer> players0, GameRules rules0, Match match0) { /* no more zones to map here */
|
||||||
rules = rules0;
|
rules = rules0;
|
||||||
match = match0;
|
match = match0;
|
||||||
|
|
||||||
@@ -127,7 +139,7 @@ public class Game {
|
|||||||
|
|
||||||
int plId = 0;
|
int plId = 0;
|
||||||
for (RegisteredPlayer psc : players0) {
|
for (RegisteredPlayer psc : players0) {
|
||||||
IGameEntitiesFactory factory = (IGameEntitiesFactory)psc.getPlayer();
|
IGameEntitiesFactory factory = (IGameEntitiesFactory)psc.getPlayer();
|
||||||
Player pl = factory.createIngamePlayer(this, plId++);
|
Player pl = factory.createIngamePlayer(this, plId++);
|
||||||
allPlayers.add(pl);
|
allPlayers.add(pl);
|
||||||
ingamePlayers.add(pl);
|
ingamePlayers.add(pl);
|
||||||
|
|||||||
@@ -97,13 +97,13 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
|
|||||||
commandZoneSources = CardLists.filterControlledBy(commandZoneSources, tgtPlayers.get(0));
|
commandZoneSources = CardLists.filterControlledBy(commandZoneSources, tgtPlayers.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Card divPermanentSources = new Card(-1);
|
Card divPermanentSources = new Card(-1, game);
|
||||||
divPermanentSources.setName("--PERMANENTS:--");
|
divPermanentSources.setName("--PERMANENTS:--");
|
||||||
Card divStackSources = new Card(-2);
|
Card divStackSources = new Card(-2, game);
|
||||||
divStackSources.setName("--SPELLS ON THE STACK:--");
|
divStackSources.setName("--SPELLS ON THE STACK:--");
|
||||||
Card divReferencedSources = new Card(-3);
|
Card divReferencedSources = new Card(-3, game);
|
||||||
divReferencedSources.setName("--OBJECTS REFERRED TO ON THE STACK:--");
|
divReferencedSources.setName("--OBJECTS REFERRED TO ON THE STACK:--");
|
||||||
Card divCommandZoneSources = new Card(-4);
|
Card divCommandZoneSources = new Card(-4, game);
|
||||||
divCommandZoneSources.setName("--CARDS IN THE COMMAND ZONE:--");
|
divCommandZoneSources.setName("--CARDS IN THE COMMAND ZONE:--");
|
||||||
|
|
||||||
if (permanentSources.size() > 0) {
|
if (permanentSources.size() > 0) {
|
||||||
|
|||||||
@@ -27,13 +27,12 @@ public class DamageDealEffect extends SpellAbilityEffect {
|
|||||||
final String damage = sa.getParam("NumDmg");
|
final String damage = sa.getParam("NumDmg");
|
||||||
final int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
final int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
|
||||||
|
|
||||||
|
|
||||||
List<GameObject> tgts = getTargets(sa);
|
List<GameObject> tgts = getTargets(sa);
|
||||||
if (tgts.isEmpty())
|
if (tgts.isEmpty())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
final List<Card> definedSources = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DamageSource"), sa);
|
final List<Card> definedSources = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DamageSource"), sa);
|
||||||
Card source = definedSources.isEmpty() ? new Card(-1) : definedSources.get(0);
|
Card source = definedSources.isEmpty() ? new Card(-1, sa.getHostCard().getGame()) : definedSources.get(0);
|
||||||
|
|
||||||
if (source != sa.getHostCard()) {
|
if (source != sa.getHostCard()) {
|
||||||
sb.append(source.toString()).append(" deals");
|
sb.append(source.toString()).append(" deals");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class DetachedCardEffect extends Card {
|
|||||||
private Card card; //card linked to effect
|
private Card card; //card linked to effect
|
||||||
|
|
||||||
public DetachedCardEffect(Card card0, String name0) {
|
public DetachedCardEffect(Card card0, String name0) {
|
||||||
super(card0.getOwner().getGame().nextCardId(), card0.getPaperCard());
|
super(card0.getOwner().getGame().nextCardId(), card0.getPaperCard(), card0.getOwner().getGame());
|
||||||
card = card0;
|
card = card0;
|
||||||
|
|
||||||
setName(name0);
|
setName(name0);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class EffectEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Player controller = sa.hasParam("EffectOwner") ? ownerEff : sa.getActivatingPlayer();
|
final Player controller = sa.hasParam("EffectOwner") ? ownerEff : sa.getActivatingPlayer();
|
||||||
final Card eff = new Card(controller.getGame().nextCardId());
|
final Card eff = new Card(game.nextCardId(), game);
|
||||||
eff.setName(name);
|
eff.setName(name);
|
||||||
eff.addType("Effect"); // Or Emblem
|
eff.addType("Effect"); // Or Emblem
|
||||||
eff.setToken(true); // Set token to true, so when leaving play it gets nuked
|
eff.setToken(true); // Set token to true, so when leaving play it gets nuked
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ public class PlayLandVariantEffect extends SpellAbilityEffect {
|
|||||||
cards = Lists.newArrayList(Iterables.filter(cards, cp));
|
cards = Lists.newArrayList(Iterables.filter(cards, cp));
|
||||||
// get a random basic land
|
// get a random basic land
|
||||||
PaperCard ran = Aggregates.random(cards);
|
PaperCard ran = Aggregates.random(cards);
|
||||||
Card random = CardFactory.getCard(ran, activator);
|
Card random = CardFactory.getCard(ran, activator, source.getGame());
|
||||||
// if activator cannot play the random land, loop
|
// if activator cannot play the random land, loop
|
||||||
while (!activator.canPlayLand(random, false) && !cards.isEmpty()) {
|
while (!activator.canPlayLand(random, false) && !cards.isEmpty()) {
|
||||||
cards.remove(ran);
|
cards.remove(ran);
|
||||||
if (cards.isEmpty()) return;
|
if (cards.isEmpty()) return;
|
||||||
ran = Aggregates.random(cards);
|
ran = Aggregates.random(cards);
|
||||||
random = CardFactory.getCard(ran, activator);
|
random = CardFactory.getCard(ran, activator, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
String imageFileName = game.getRules().canCloneUseTargetsImage ? source.getImageKey() : random.getImageKey();
|
String imageFileName = game.getRules().canCloneUseTargetsImage ? source.getImageKey() : random.getImageKey();
|
||||||
|
|||||||
@@ -90,25 +90,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class Card extends GameEntity implements Comparable<Card> {
|
public class Card extends GameEntity implements Comparable<Card> {
|
||||||
private static HashMap<Integer, Card> cardCache = new HashMap<Integer, Card>();
|
private final Game game;
|
||||||
public static Card get(CardView cardView) {
|
|
||||||
if (cardView == null) { return null; }
|
|
||||||
return cardCache.get(cardView.getId());
|
|
||||||
}
|
|
||||||
public static CardCollection getList(Iterable<CardView> cardViews) {
|
|
||||||
CardCollection list = new CardCollection();
|
|
||||||
for (CardView cv : cardViews) {
|
|
||||||
Card c = get(cv);
|
|
||||||
if (c != null) {
|
|
||||||
list.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public static void clearCache() {
|
|
||||||
cardCache.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final IPaperCard paperCard;
|
private final IPaperCard paperCard;
|
||||||
|
|
||||||
private final Map<CardStateName, CardState> states = new EnumMap<CardStateName, CardState>(CardStateName.class);
|
private final Map<CardStateName, CardState> states = new EnumMap<CardStateName, CardState>(CardStateName.class);
|
||||||
@@ -264,8 +246,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* Instantiates a new card not associated to any paper card.
|
* Instantiates a new card not associated to any paper card.
|
||||||
* @param id the unique id of the new card.
|
* @param id the unique id of the new card.
|
||||||
*/
|
*/
|
||||||
public Card(final int id0) {
|
public Card(final int id0, final Game game0) {
|
||||||
this(id0, null, true);
|
this(id0, null, true, game0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -276,18 +258,19 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* card.
|
* card.
|
||||||
* @see IPaperCard
|
* @see IPaperCard
|
||||||
*/
|
*/
|
||||||
public Card(final int id0, final IPaperCard paperCard0) {
|
public Card(final int id0, final IPaperCard paperCard0, final Game game0) {
|
||||||
this(id0, paperCard0, true);
|
this(id0, paperCard0, true, game0);
|
||||||
}
|
}
|
||||||
public Card(final int id0, final IPaperCard paperCard0, final boolean allowCache) {
|
public Card(final int id0, final IPaperCard paperCard0, final boolean allowCache, final Game game0) {
|
||||||
super(id0);
|
super(id0);
|
||||||
|
|
||||||
if (id0 >= 0 && allowCache) {
|
game = game0;
|
||||||
cardCache.put(id0, this);
|
if (id0 >= 0 && allowCache && game != null) {
|
||||||
|
game.addCard(id0, this);
|
||||||
}
|
}
|
||||||
paperCard = paperCard0;
|
paperCard = paperCard0;
|
||||||
view = new CardView(id0);
|
view = new CardView(id0);
|
||||||
currentState = new CardState(view.getCurrentState());
|
currentState = new CardState(view.getCurrentState(), this);
|
||||||
states.put(CardStateName.Original, currentState);
|
states.put(CardStateName.Original, currentState);
|
||||||
states.put(CardStateName.FaceDown, CardUtil.getFaceDownCharacteristic(this));
|
states.put(CardStateName.FaceDown, CardUtil.getFaceDownCharacteristic(this));
|
||||||
view.updateChangedColorWords(this);
|
view.updateChangedColorWords(this);
|
||||||
@@ -399,7 +382,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void addAlternateState(final CardStateName state, final boolean updateView) {
|
public final void addAlternateState(final CardStateName state, final boolean updateView) {
|
||||||
states.put(state, new CardState(view.createAlternateState(state)));
|
states.put(state, new CardState(view.createAlternateState(state), this));
|
||||||
if (updateView) {
|
if (updateView) {
|
||||||
view.updateState(this);
|
view.updateState(this);
|
||||||
}
|
}
|
||||||
@@ -2103,6 +2086,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
public final void setOwner(final Player owner0) {
|
public final void setOwner(final Player owner0) {
|
||||||
if (owner == owner0) { return; }
|
if (owner == owner0) { return; }
|
||||||
|
if (owner != null && owner.getGame() != this.getGame()) {
|
||||||
|
// Sanity check.
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
owner = owner0;
|
owner = owner0;
|
||||||
view.updateOwner(this);
|
view.updateOwner(this);
|
||||||
view.updateController(this);
|
view.updateController(this);
|
||||||
@@ -6258,20 +6245,9 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public Iterable<OptionalCost> getOptionalCostsPaid() { return costsPaid; }
|
public Iterable<OptionalCost> getOptionalCostsPaid() { return costsPaid; }
|
||||||
public boolean isOptionalCostPaid(OptionalCost cost) { return costsPaid.contains(cost); }
|
public boolean isOptionalCostPaid(OptionalCost cost) { return costsPaid.contains(cost); }
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch GameState for this card from references to players who may own or control this card.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Game getGame() {
|
public Game getGame() {
|
||||||
Player controller = getController();
|
return game;
|
||||||
if (controller != null) {
|
|
||||||
return controller.getGame();
|
|
||||||
}
|
|
||||||
Player owner = getOwner();
|
|
||||||
if (owner != null) {
|
|
||||||
return owner.getGame();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SpellAbility> getAllPossibleAbilities(final Player player, final boolean removeUnplayable) {
|
public List<SpellAbility> getAllPossibleAbilities(final Player player, final boolean removeUnplayable) {
|
||||||
@@ -6308,7 +6284,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Card fromPaperCard(IPaperCard pc, Player owner) {
|
public static Card fromPaperCard(IPaperCard pc, Player owner) {
|
||||||
return CardFactory.getCard(pc, owner);
|
return CardFactory.getCard(pc, owner, owner == null ? null : owner.getGame());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<PaperCard, Card> cp2card = new HashMap<PaperCard, Card>();
|
private static final Map<PaperCard, Card> cp2card = new HashMap<PaperCard, Card>();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import forge.card.CardSplitType;
|
|||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.card.ICardFace;
|
import forge.card.ICardFace;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
|
import forge.game.Game;
|
||||||
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;
|
||||||
@@ -75,10 +76,11 @@ public class CardFactory {
|
|||||||
public final static Card copyCard(final Card in, boolean assignNewId) {
|
public final static Card copyCard(final Card in, boolean assignNewId) {
|
||||||
Card out;
|
Card out;
|
||||||
if (!(in.isToken() || in.getCopiedPermanent() != null)) {
|
if (!(in.isToken() || in.getCopiedPermanent() != null)) {
|
||||||
out = assignNewId ? getCard(in.getPaperCard(), in.getOwner())
|
out = assignNewId ? getCard(in.getPaperCard(), in.getOwner(), in.getGame())
|
||||||
: getCard(in.getPaperCard(), in.getOwner(), in.getId());
|
: getCard(in.getPaperCard(), in.getOwner(), in.getId(), in.getGame());
|
||||||
} else { // token
|
} else { // token
|
||||||
out = assignNewId ? new Card(in.getGame().nextCardId(), in.getPaperCard()) : new Card(in.getId(), in.getPaperCard());
|
int id = assignNewId ? in.getGame().nextCardId() : in.getId();
|
||||||
|
out = new Card(id, in.getPaperCard(), in.getGame());
|
||||||
out = CardFactory.copyStats(in, in.getController());
|
out = CardFactory.copyStats(in, in.getController());
|
||||||
out.setToken(true);
|
out.setToken(true);
|
||||||
|
|
||||||
@@ -89,7 +91,7 @@ public class CardFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final CardStateName state : in.getStates()) {
|
for (final CardStateName state : in.getStates()) {
|
||||||
CardFactory.copyState(in, state, out, state);
|
CardFactory.copyState(in, state, out, state);
|
||||||
}
|
}
|
||||||
out.setState(in.getCurrentStateName(), true);
|
out.setState(in.getCurrentStateName(), true);
|
||||||
|
|
||||||
@@ -210,13 +212,13 @@ public class CardFactory {
|
|||||||
return copySA;
|
return copySA;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static Card getCard(final IPaperCard cp, final Player owner) {
|
public final static Card getCard(final IPaperCard cp, final Player owner, final Game game) {
|
||||||
return getCard(cp, owner, owner == null ? -1 : owner.getGame().nextCardId());
|
return getCard(cp, owner, owner == null ? -1 : owner.getGame().nextCardId(), game);
|
||||||
}
|
}
|
||||||
public final static Card getCard(final IPaperCard cp, final Player owner, final int cardId) {
|
public final static Card getCard(final IPaperCard cp, final Player owner, final int cardId, final Game game) {
|
||||||
//System.out.println(cardName);
|
//System.out.println(cardName);
|
||||||
CardRules cardRules = cp.getRules();
|
CardRules cardRules = cp.getRules();
|
||||||
final Card c = readCard(cardRules, cp, cardId);
|
final Card c = readCard(cardRules, cp, cardId, game);
|
||||||
c.setRules(cardRules);
|
c.setRules(cardRules);
|
||||||
c.setOwner(owner);
|
c.setOwner(owner);
|
||||||
buildAbilities(c);
|
buildAbilities(c);
|
||||||
@@ -341,8 +343,8 @@ public class CardFactory {
|
|||||||
card.setSVar("DamagePWY", "Count$YourLifeTotal");
|
card.setSVar("DamagePWY", "Count$YourLifeTotal");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Card readCard(final CardRules rules, final IPaperCard paperCard, int cardId) {
|
private static Card readCard(final CardRules rules, final IPaperCard paperCard, int cardId, Game game) {
|
||||||
final Card card = new Card(cardId, paperCard);
|
final Card card = new Card(cardId, paperCard, game);
|
||||||
|
|
||||||
// 1. The states we may have:
|
// 1. The states we may have:
|
||||||
CardSplitType st = rules.getSplitType();
|
CardSplitType st = rules.getSplitType();
|
||||||
@@ -428,7 +430,7 @@ public class CardFactory {
|
|||||||
*/
|
*/
|
||||||
public static Card copyCopiableCharacteristics(final Card from, final Player newOwner) {
|
public static Card copyCopiableCharacteristics(final Card from, final Player newOwner) {
|
||||||
int id = newOwner == null ? 0 : newOwner.getGame().nextCardId();
|
int id = newOwner == null ? 0 : newOwner.getGame().nextCardId();
|
||||||
final Card c = new Card(id, from.getPaperCard());
|
final Card c = new Card(id, from.getPaperCard(), from.getGame());
|
||||||
c.setOwner(newOwner);
|
c.setOwner(newOwner);
|
||||||
c.setSetCode(from.getSetCode());
|
c.setSetCode(from.getSetCode());
|
||||||
|
|
||||||
@@ -511,7 +513,7 @@ public class CardFactory {
|
|||||||
*/
|
*/
|
||||||
public static Card copyStats(final Card in, final Player newOwner) {
|
public static Card copyStats(final Card in, final Player newOwner) {
|
||||||
int id = newOwner == null ? 0 : newOwner.getGame().nextCardId();
|
int id = newOwner == null ? 0 : newOwner.getGame().nextCardId();
|
||||||
final Card c = new Card(id, in.getPaperCard());
|
final Card c = new Card(id, in.getPaperCard(), in.getGame());
|
||||||
|
|
||||||
c.setOwner(newOwner);
|
c.setOwner(newOwner);
|
||||||
c.setSetCode(in.getSetCode());
|
c.setSetCode(in.getSetCode());
|
||||||
@@ -607,7 +609,7 @@ public class CardFactory {
|
|||||||
final String manaCost, final String[] types, final int basePower, final int baseToughness,
|
final String manaCost, final String[] types, final int basePower, final int baseToughness,
|
||||||
final String[] intrinsicKeywords) {
|
final String[] intrinsicKeywords) {
|
||||||
final List<Card> list = new ArrayList<Card>();
|
final List<Card> list = new ArrayList<Card>();
|
||||||
final Card c = new Card(controller.getGame().nextCardId());
|
final Card c = new Card(controller.getGame().nextCardId(), controller.getGame());
|
||||||
c.setName(name);
|
c.setName(name);
|
||||||
c.setImageKey(ImageKeys.getTokenKey(imageName));
|
c.setImageKey(ImageKeys.getTokenKey(imageName));
|
||||||
|
|
||||||
|
|||||||
@@ -64,9 +64,11 @@ public class CardState {
|
|||||||
private String setCode = CardEdition.UNKNOWN.getCode();
|
private String setCode = CardEdition.UNKNOWN.getCode();
|
||||||
|
|
||||||
private final CardStateView view;
|
private final CardStateView view;
|
||||||
|
private final Card card;
|
||||||
|
|
||||||
public CardState(CardStateView view0) {
|
public CardState(CardStateView view0, Card card0) {
|
||||||
view = view0;
|
view = view0;
|
||||||
|
card = card0;
|
||||||
view.updateRarity(this);
|
view.updateRarity(this);
|
||||||
view.updateSetCode(this);
|
view.updateSetCode(this);
|
||||||
}
|
}
|
||||||
@@ -75,6 +77,10 @@ public class CardState {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Card getCard() {
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
|
||||||
public final String getName() {
|
public final String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ public final class CardUtil {
|
|||||||
* @return a copy of C with LastKnownInfo stuff retained.
|
* @return a copy of C with LastKnownInfo stuff retained.
|
||||||
*/
|
*/
|
||||||
public static Card getLKICopy(final Card in) {
|
public static Card getLKICopy(final Card in) {
|
||||||
final Card newCopy = new Card(in.getId(), in.getPaperCard(), false);
|
final Card newCopy = new Card(in.getId(), in.getPaperCard(), false, in.getGame());
|
||||||
newCopy.setSetCode(in.getSetCode());
|
newCopy.setSetCode(in.getSetCode());
|
||||||
newCopy.setOwner(in.getOwner());
|
newCopy.setOwner(in.getOwner());
|
||||||
newCopy.setController(in.getController(), 0);
|
newCopy.setController(in.getController(), 0);
|
||||||
@@ -285,7 +285,7 @@ public final class CardUtil {
|
|||||||
final CardType type = new CardType();
|
final CardType type = new CardType();
|
||||||
type.add("Creature");
|
type.add("Creature");
|
||||||
|
|
||||||
final CardState ret = new CardState(c.getView().createAlternateState(CardStateName.FaceDown));
|
final CardState ret = new CardState(c.getView().createAlternateState(CardStateName.FaceDown), c);
|
||||||
ret.setBasePower(2);
|
ret.setBasePower(2);
|
||||||
ret.setBaseToughness(2);
|
ret.setBaseToughness(2);
|
||||||
|
|
||||||
|
|||||||
@@ -752,7 +752,7 @@ public class CardView extends GameEntityView {
|
|||||||
setName(c.getName());
|
setName(c.getName());
|
||||||
|
|
||||||
if (CardView.this.getCurrentState() == this) {
|
if (CardView.this.getCurrentState() == this) {
|
||||||
Card card = Card.get(CardView.this);
|
Card card = c.getCard();
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
CardView.this.updateName(card);
|
CardView.this.updateName(card);
|
||||||
}
|
}
|
||||||
@@ -794,7 +794,7 @@ public class CardView extends GameEntityView {
|
|||||||
void updateType(CardState c) {
|
void updateType(CardState c) {
|
||||||
CardTypeView type = c.getType();
|
CardTypeView type = c.getType();
|
||||||
if (CardView.this.getCurrentState() == this) {
|
if (CardView.this.getCurrentState() == this) {
|
||||||
Card card = Card.get(CardView.this);
|
Card card = c.getCard();
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
type = type.getTypeWithChanges(card.getChangedCardTypes()); //TODO: find a better way to do this
|
type = type.getTypeWithChanges(card.getChangedCardTypes()); //TODO: find a better way to do this
|
||||||
updateRulesText(card.getRules(), type);
|
updateRulesText(card.getRules(), type);
|
||||||
@@ -842,7 +842,7 @@ public class CardView extends GameEntityView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void updatePower(CardState c) {
|
void updatePower(CardState c) {
|
||||||
Card card = Card.get(CardView.this);
|
Card card = c.getCard();
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
updatePower(card); //TODO: find a better way to do this
|
updatePower(card); //TODO: find a better way to do this
|
||||||
return;
|
return;
|
||||||
@@ -862,7 +862,7 @@ public class CardView extends GameEntityView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void updateToughness(CardState c) {
|
void updateToughness(CardState c) {
|
||||||
Card card = Card.get(CardView.this);
|
Card card = c.getCard();
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
updateToughness(card); //TODO: find a better way to do this
|
updateToughness(card); //TODO: find a better way to do this
|
||||||
return;
|
return;
|
||||||
@@ -878,7 +878,7 @@ public class CardView extends GameEntityView {
|
|||||||
}
|
}
|
||||||
void updateLoyalty(CardState c) {
|
void updateLoyalty(CardState c) {
|
||||||
if (CardView.this.getCurrentState() == this) {
|
if (CardView.this.getCurrentState() == this) {
|
||||||
Card card = Card.get(CardView.this);
|
Card card = c.getCard();
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
updateLoyalty(card); //TODO: find a better way to do this
|
updateLoyalty(card); //TODO: find a better way to do this
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -234,15 +234,15 @@ public class RunTest {
|
|||||||
* false);
|
* false);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
c = new Card(1);
|
c = new Card(1, null);
|
||||||
Card c2 = new Card(2);
|
Card c2 = new Card(2, null);
|
||||||
c.addIntrinsicKeyword("Flying");
|
c.addIntrinsicKeyword("Flying");
|
||||||
c2.addIntrinsicKeyword("Flying");
|
c2.addIntrinsicKeyword("Flying");
|
||||||
// check("107", CombatUtil.canBlock(c, c2));
|
// check("107", CombatUtil.canBlock(c, c2));
|
||||||
// check("108", CombatUtil.canBlock(c2, c));
|
// check("108", CombatUtil.canBlock(c2, c));
|
||||||
|
|
||||||
c = new Card(1);
|
c = new Card(1, null);
|
||||||
c2 = new Card(2);
|
c2 = new Card(2, null);
|
||||||
c2.addIntrinsicKeyword("Flying");
|
c2.addIntrinsicKeyword("Flying");
|
||||||
this.check("109", CombatUtil.canBlock(c, c2));
|
this.check("109", CombatUtil.canBlock(c, c2));
|
||||||
this.check("110", !CombatUtil.canBlock(c2, c));
|
this.check("110", !CombatUtil.canBlock(c2, c));
|
||||||
|
|||||||
@@ -107,10 +107,14 @@ public class InputProxy implements Observer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Card getCard(final CardView cardView) {
|
||||||
|
return controller.getGame().getCard(cardView);
|
||||||
|
}
|
||||||
|
|
||||||
public final String getActivateAction(final CardView cardView) {
|
public final String getActivateAction(final CardView cardView) {
|
||||||
final Input inp = getInput();
|
final Input inp = getInput();
|
||||||
if (inp != null) {
|
if (inp != null) {
|
||||||
final Card card = Card.get(cardView);
|
final Card card = getCard(cardView);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
return inp.getActivateAction(card);
|
return inp.getActivateAction(card);
|
||||||
}
|
}
|
||||||
@@ -120,13 +124,14 @@ public class InputProxy implements Observer {
|
|||||||
|
|
||||||
public final boolean selectCard(final CardView cardView, final List<CardView> otherCardViewsToSelect, final ITriggerEvent triggerEvent) {
|
public final boolean selectCard(final CardView cardView, final List<CardView> otherCardViewsToSelect, final ITriggerEvent triggerEvent) {
|
||||||
final Input inp = getInput();
|
final Input inp = getInput();
|
||||||
|
System.out.println("Selectcard " +cardView + " input: " +inp);
|
||||||
if (inp != null) {
|
if (inp != null) {
|
||||||
final Card card = Card.get(cardView);
|
final Card card = getCard(cardView);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
List<Card> otherCardsToSelect = null;
|
List<Card> otherCardsToSelect = null;
|
||||||
if (otherCardViewsToSelect != null) {
|
if (otherCardViewsToSelect != null) {
|
||||||
for (CardView cv : otherCardViewsToSelect) {
|
for (CardView cv : otherCardViewsToSelect) {
|
||||||
final Card c = Card.get(cv);
|
final Card c = getCard(cv);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
if (otherCardsToSelect == null) {
|
if (otherCardsToSelect == null) {
|
||||||
otherCardsToSelect = new ArrayList<Card>();
|
otherCardsToSelect = new ArrayList<Card>();
|
||||||
|
|||||||
@@ -297,7 +297,8 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
if (nNeeded == 0) {
|
if (nNeeded == 0) {
|
||||||
return PaymentDecision.number(0);
|
return PaymentDecision.number(0);
|
||||||
}
|
}
|
||||||
final Player p = controller.getGame().getPlayer(SGuiChoose.oneOrNone(String.format("Exile from whose %s?", cost.getFrom()), PlayerView.getCollection(payableZone)));
|
final Game game = controller.getGame();
|
||||||
|
final Player p = game.getPlayer(SGuiChoose.oneOrNone(String.format("Exile from whose %s?", cost.getFrom()), PlayerView.getCollection(payableZone)));
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -308,7 +309,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardCollection toExile = Card.getList(SGuiChoose.many("Exile from " + cost.getFrom(), "To be exiled", nNeeded, CardView.getCollection(typeList), null));
|
CardCollection toExile = game.getCardList(SGuiChoose.many("Exile from " + cost.getFrom(), "To be exiled", nNeeded, CardView.getCollection(typeList), null));
|
||||||
return PaymentDecision.card(toExile);
|
return PaymentDecision.card(toExile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,12 +384,16 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
return PaymentDecision.card(list);
|
return PaymentDecision.card(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Card getCard(CardView cardView) {
|
||||||
|
return controller.getGame().getCard(cardView);
|
||||||
|
}
|
||||||
|
|
||||||
private PaymentDecision exileFromMiscZone(CostExile cost, SpellAbility sa, int nNeeded, CardCollection typeList) {
|
private PaymentDecision exileFromMiscZone(CostExile cost, SpellAbility sa, int nNeeded, CardCollection typeList) {
|
||||||
if (typeList.size() < nNeeded) { return null; }
|
if (typeList.size() < nNeeded) { return null; }
|
||||||
|
|
||||||
CardCollection exiled = new CardCollection();
|
CardCollection exiled = new CardCollection();
|
||||||
for (int i = 0; i < nNeeded; i++) {
|
for (int i = 0; i < nNeeded; i++) {
|
||||||
final Card c = Card.get(SGuiChoose.oneOrNone("Exile from " + cost.getFrom(), CardView.getCollection(typeList)));
|
final Card c = getCard(SGuiChoose.oneOrNone("Exile from " + cost.getFrom(), CardView.getCollection(typeList)));
|
||||||
if (c == null) { return null; }
|
if (c == null) { return null; }
|
||||||
|
|
||||||
typeList.remove(c);
|
typeList.remove(c);
|
||||||
@@ -417,7 +422,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
if (list.size() < c) {
|
if (list.size() < c) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final CardCollection choice = Card.getList(SGuiChoose.many("Choose an exiled card to put into graveyard", "To graveyard", c, CardView.getCollection(list), CardView.get(source)));
|
final CardCollection choice = controller.getGame().getCardList(SGuiChoose.many("Choose an exiled card to put into graveyard", "To graveyard", c, CardView.getCollection(list), CardView.get(source)));
|
||||||
return PaymentDecision.card(choice);
|
return PaymentDecision.card(choice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,7 +604,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
|
|
||||||
CardCollection chosen = new CardCollection();
|
CardCollection chosen = new CardCollection();
|
||||||
for (int i = 0; i < nNeeded; i++) {
|
for (int i = 0; i < nNeeded; i++) {
|
||||||
final Card c = Card.get(SGuiChoose.oneOrNone("Put from " + fromZone + " to library", CardView.getCollection(typeList)));
|
final Card c = getCard(SGuiChoose.oneOrNone("Put from " + fromZone + " to library", CardView.getCollection(typeList)));
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -626,7 +631,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
|
|
||||||
CardCollection chosen = new CardCollection();
|
CardCollection chosen = new CardCollection();
|
||||||
for (int i = 0; i < nNeeded; i++) {
|
for (int i = 0; i < nNeeded; i++) {
|
||||||
final Card c = Card.get(SGuiChoose.oneOrNone("Put cards from " + fromZone + " to Library", CardView.getCollection(typeList)));
|
final Card c = getCard(SGuiChoose.oneOrNone("Put cards from " + fromZone + " to Library", CardView.getCollection(typeList)));
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -954,7 +959,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Card card = Card.get(SGuiChoose.oneOrNone("Remove counter(s) from a card in " + cost.zone, suspended));
|
final Card card = getCard(SGuiChoose.oneOrNone("Remove counter(s) from a card in " + cost.zone, suspended));
|
||||||
return null == card ? null : PaymentDecision.card(card, c);
|
return null == card ? null : PaymentDecision.card(card, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
// replace this with input
|
// replace this with input
|
||||||
for (int i = 0; i < nNeeded; i++) {
|
for (int i = 0; i < nNeeded; i++) {
|
||||||
final Card c = Card.get(SGuiChoose.oneOrNone("Exile from " + from, CardView.getCollection(list)));
|
final Card c = p.getGame().getCard(SGuiChoose.oneOrNone("Exile from " + from, CardView.getCollection(list)));
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -536,7 +536,7 @@ public class HumanPlay {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Card c = Card.get(SGuiChoose.oneOrNone("Put cards to Library", CardView.getCollection(typeList)));
|
final Card c = p.getGame().getCard(SGuiChoose.oneOrNone("Put cards to Library", CardView.getCollection(typeList)));
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
typeList.remove(c);
|
typeList.remove(c);
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
final GameEntityView vDefender = GameEntityView.get(defender);
|
final GameEntityView vDefender = GameEntityView.get(defender);
|
||||||
final Map<CardView, Integer> result = MatchUtil.getDamageToAssign(vAttacker, vBlockers, damageDealt, vDefender, overrideOrder);
|
final Map<CardView, Integer> result = MatchUtil.getDamageToAssign(vAttacker, vBlockers, damageDealt, vDefender, overrideOrder);
|
||||||
for (final Entry<CardView, Integer> e : result.entrySet()) {
|
for (final Entry<CardView, Integer> e : result.entrySet()) {
|
||||||
map.put(Card.get(e.getKey()), e.getValue());
|
map.put(game.getCard(e.getKey()), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -369,7 +369,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tempShowCards(sourceList);
|
tempShowCards(sourceList);
|
||||||
final CardCollection choices = Card.getList(SGuiChoose.many(title, "Chosen Cards", min, max, CardView.getCollection(sourceList), CardView.get(sa.getHostCard())));
|
final CardCollection choices = getGame().getCardList(SGuiChoose.many(title, "Chosen Cards", min, max, CardView.getCollection(sourceList), CardView.get(sa.getHostCard())));
|
||||||
endTempShowCards();
|
endTempShowCards();
|
||||||
|
|
||||||
return choices;
|
return choices;
|
||||||
@@ -420,7 +420,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
final GameEntityView result = GuiBase.getInterface().chooseSingleEntityForEffect(title, optionList, delayedReveal, isOptional, this);
|
final GameEntityView result = GuiBase.getInterface().chooseSingleEntityForEffect(title, optionList, delayedReveal, isOptional, this);
|
||||||
endTempShowCards(); //assume tempShow called by GuiBase.getInterface().chooseSingleEntityForEffect
|
endTempShowCards(); //assume tempShow called by GuiBase.getInterface().chooseSingleEntityForEffect
|
||||||
if (result instanceof CardView) {
|
if (result instanceof CardView) {
|
||||||
return (T) Card.get((CardView)result);
|
return (T) game.getCard((CardView)result);
|
||||||
}
|
}
|
||||||
if (result instanceof PlayerView) {
|
if (result instanceof PlayerView) {
|
||||||
return (T) game.getPlayer((PlayerView)result);
|
return (T) game.getPlayer((PlayerView)result);
|
||||||
@@ -536,21 +536,21 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
public CardCollection orderBlockers(final Card attacker, final CardCollection blockers) {
|
public CardCollection orderBlockers(final Card attacker, final CardCollection blockers) {
|
||||||
final CardView vAttacker = CardView.get(attacker);
|
final CardView vAttacker = CardView.get(attacker);
|
||||||
MatchUtil.getController().setPanelSelection(vAttacker);
|
MatchUtil.getController().setPanelSelection(vAttacker);
|
||||||
return Card.getList(SGuiChoose.order("Choose Damage Order for " + vAttacker, "Damaged First", CardView.getCollection(blockers), vAttacker));
|
return game.getCardList(SGuiChoose.order("Choose Damage Order for " + vAttacker, "Damaged First", CardView.getCollection(blockers), vAttacker));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CardCollection orderBlocker(final Card attacker, final Card blocker, final CardCollection oldBlockers) {
|
public CardCollection orderBlocker(final Card attacker, final Card blocker, final CardCollection oldBlockers) {
|
||||||
final CardView vAttacker = CardView.get(attacker);
|
final CardView vAttacker = CardView.get(attacker);
|
||||||
MatchUtil.getController().setPanelSelection(vAttacker);
|
MatchUtil.getController().setPanelSelection(vAttacker);
|
||||||
return Card.getList(SGuiChoose.insertInList("Choose blocker after which to place " + vAttacker + " in damage order; cancel to place it first", CardView.get(blocker), CardView.getCollection(oldBlockers)));
|
return game.getCardList(SGuiChoose.insertInList("Choose blocker after which to place " + vAttacker + " in damage order; cancel to place it first", CardView.get(blocker), CardView.getCollection(oldBlockers)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CardCollection orderAttackers(final Card blocker, final CardCollection attackers) {
|
public CardCollection orderAttackers(final Card blocker, final CardCollection attackers) {
|
||||||
final CardView vBlocker = CardView.get(blocker);
|
final CardView vBlocker = CardView.get(blocker);
|
||||||
MatchUtil.getController().setPanelSelection(vBlocker);
|
MatchUtil.getController().setPanelSelection(vBlocker);
|
||||||
return Card.getList(SGuiChoose.order("Choose Damage Order for " + vBlocker, "Damaged First", CardView.getCollection(attackers), vBlocker));
|
return game.getCardList(SGuiChoose.order("Choose Damage Order for " + vBlocker, "Damaged First", CardView.getCollection(attackers), vBlocker));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -588,7 +588,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toBottom = Card.getList(SGuiChoose.many("Select cards to be put on the bottom of your library", "Cards to put on the bottom", -1, CardView.getCollection(topN), null));
|
toBottom = game.getCardList(SGuiChoose.many("Select cards to be put on the bottom of your library", "Cards to put on the bottom", -1, CardView.getCollection(topN), null));
|
||||||
topN.removeAll((Collection<?>)toBottom);
|
topN.removeAll((Collection<?>)toBottom);
|
||||||
if (topN.isEmpty()) {
|
if (topN.isEmpty()) {
|
||||||
toTop = null;
|
toTop = null;
|
||||||
@@ -597,7 +597,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
toTop = topN;
|
toTop = topN;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toTop = Card.getList(SGuiChoose.order("Arrange cards to be put on top of your library", "Top of Library", CardView.getCollection(topN), null));
|
toTop = game.getCardList(SGuiChoose.order("Arrange cards to be put on top of your library", "Top of Library", CardView.getCollection(topN), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endTempShowCards();
|
endTempShowCards();
|
||||||
@@ -639,14 +639,14 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
return cards;
|
return cards;
|
||||||
}
|
}
|
||||||
endTempShowCards();
|
endTempShowCards();
|
||||||
return Card.getList(choices);
|
return game.getCardList(choices);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CardCollectionView chooseCardsToDiscardFrom(Player p, SpellAbility sa, CardCollection valid, int min, int max) {
|
public CardCollectionView chooseCardsToDiscardFrom(Player p, SpellAbility sa, CardCollection valid, int min, int max) {
|
||||||
if (p != player) {
|
if (p != player) {
|
||||||
tempShowCards(valid);
|
tempShowCards(valid);
|
||||||
final CardCollection choices = Card.getList(SGuiChoose.many("Choose " + min + " card" + (min != 1 ? "s" : "") + " to discard",
|
final CardCollection choices = game.getCardList(SGuiChoose.many("Choose " + min + " card" + (min != 1 ? "s" : "") + " to discard",
|
||||||
"Discarded", min, min, CardView.getCollection(valid), null));
|
"Discarded", min, min, CardView.getCollection(valid), null));
|
||||||
endTempShowCards();
|
endTempShowCards();
|
||||||
return choices;
|
return choices;
|
||||||
@@ -687,8 +687,9 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
grave.remove(Card.get(nowChosen));
|
Card card = game.getCard(nowChosen);
|
||||||
toExile.add(Card.get(nowChosen));
|
grave.remove(card);
|
||||||
|
toExile.add(card);
|
||||||
}
|
}
|
||||||
return toExile;
|
return toExile;
|
||||||
}
|
}
|
||||||
@@ -941,7 +942,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
final List<CardView> chosen = SGuiChoose.many("Choose cards to activate from opening hand and their order", "Activate first", -1, CardView.getCollection(srcCards), null);
|
final List<CardView> chosen = SGuiChoose.many("Choose cards to activate from opening hand and their order", "Activate first", -1, CardView.getCollection(srcCards), null);
|
||||||
for (final CardView view : chosen) {
|
for (final CardView view : chosen) {
|
||||||
final Card c = Card.get(view);
|
final Card c = game.getCard(view);
|
||||||
for (SpellAbility sa : usableFromOpeningHand) {
|
for (SpellAbility sa : usableFromOpeningHand) {
|
||||||
if (sa.getHostCard() == c) {
|
if (sa.getHostCard() == c) {
|
||||||
result.add(sa);
|
result.add(sa);
|
||||||
@@ -1418,7 +1419,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Card dummy = new Card(-777777);
|
final Card dummy = new Card(-777777, game);
|
||||||
dummy.setOwner(pPriority);
|
dummy.setOwner(pPriority);
|
||||||
Map<String, String> produced = new HashMap<String, String>();
|
Map<String, String> produced = new HashMap<String, String>();
|
||||||
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
||||||
@@ -1500,7 +1501,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
final CardCollection lib = (CardCollection)pPriority.getCardsIn(ZoneType.Library);
|
final CardCollection lib = (CardCollection)pPriority.getCardsIn(ZoneType.Library);
|
||||||
final List<ZoneType> origin = new ArrayList<ZoneType>();
|
final List<ZoneType> origin = new ArrayList<ZoneType>();
|
||||||
origin.add(ZoneType.Library);
|
origin.add(ZoneType.Library);
|
||||||
SpellAbility sa = new SpellAbility.EmptySa(new Card(-1));
|
SpellAbility sa = new SpellAbility.EmptySa(new Card(-1, game));
|
||||||
final Card card = chooseSingleCardForZoneChange(ZoneType.Hand, origin, sa, lib, null, "Choose a card", true, pPriority);
|
final Card card = chooseSingleCardForZoneChange(ZoneType.Hand, origin, sa, lib, null, "Choose a card", true, pPriority);
|
||||||
if (card == null) { return; }
|
if (card == null) { return; }
|
||||||
|
|
||||||
@@ -1514,7 +1515,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
public void addCountersToPermanent() {
|
public void addCountersToPermanent() {
|
||||||
final CardCollectionView cards = game.getCardsIn(ZoneType.Battlefield);
|
final CardCollectionView cards = game.getCardsIn(ZoneType.Battlefield);
|
||||||
final Card card = Card.get(SGuiChoose.oneOrNone("Add counters to which card?", CardView.getCollection(cards)));
|
final Card card = game.getCard(SGuiChoose.oneOrNone("Add counters to which card?", CardView.getCollection(cards)));
|
||||||
if (card == null) { return; }
|
if (card == null) { return; }
|
||||||
|
|
||||||
final CounterType counter = SGuiChoose.oneOrNone("Which type of counter?", CounterType.values());
|
final CounterType counter = SGuiChoose.oneOrNone("Which type of counter?", CounterType.values());
|
||||||
|
|||||||
Reference in New Issue
Block a user