mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Swap out old GameView structure for new one
This commit is contained in:
@@ -100,6 +100,9 @@ public class Game {
|
||||
private final GameView view;
|
||||
|
||||
public Game(List<RegisteredPlayer> players0, GameRules rules0, Match match0) { /* no more zones to map here */
|
||||
Card.clearCache();
|
||||
Player.clearCache();
|
||||
|
||||
rules = rules0;
|
||||
match = match0;
|
||||
List<Player> players = new ArrayList<Player>();
|
||||
|
||||
@@ -19,15 +19,28 @@ package forge.game;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardCollection.CardCollectionView;
|
||||
import forge.game.event.GameEventCardAttachment;
|
||||
import forge.game.event.GameEventCardAttachment.AttachMethod;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
||||
public abstract class GameEntity extends GameObject implements IIdentifiable {
|
||||
public static GameEntity get(GameEntityView gameEntityView) {
|
||||
if (gameEntityView instanceof CardView) {
|
||||
return Card.get((CardView)gameEntityView);
|
||||
}
|
||||
if (gameEntityView instanceof PlayerView) {
|
||||
return Player.get((PlayerView)gameEntityView);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected final int id;
|
||||
private String name = "";
|
||||
private int preventNextDamage = 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.game;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.trackable.TrackableCollection;
|
||||
import forge.trackable.TrackableObject;
|
||||
import forge.trackable.TrackableProperty;
|
||||
|
||||
@@ -9,6 +10,17 @@ public abstract class GameEntityView extends TrackableObject {
|
||||
return e == null ? null : e.getView();
|
||||
}
|
||||
|
||||
public static TrackableCollection<GameEntityView> getEntityCollection(Iterable<? extends GameEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
TrackableCollection<GameEntityView> collection = new TrackableCollection<GameEntityView>();
|
||||
for (GameEntity e : entities) {
|
||||
collection.add(e.getView());
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
protected GameEntityView(int id0) {
|
||||
super(id0);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package forge.game;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.GameOutcome.AnteResult;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.combat.AttackingBand;
|
||||
@@ -9,23 +12,27 @@ import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatView;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.SpellAbilityView;
|
||||
import forge.game.spellability.StackItemView;
|
||||
import forge.game.zone.MagicStack;
|
||||
import forge.trackable.TrackableIndex;
|
||||
import forge.trackable.TrackableCollection;
|
||||
import forge.trackable.TrackableObject;
|
||||
import forge.trackable.TrackableProperty;
|
||||
import forge.util.FCollection;
|
||||
|
||||
public class GameView extends TrackableObject {
|
||||
private final TrackableIndex<CardView> cards = new TrackableIndex<CardView>();
|
||||
/*private final TrackableIndex<CardView> cards = new TrackableIndex<CardView>();
|
||||
private final TrackableIndex<PlayerView> players = new TrackableIndex<PlayerView>();
|
||||
private final TrackableIndex<SpellAbilityView> spellAbilities = new TrackableIndex<SpellAbilityView>();
|
||||
private final TrackableIndex<StackItemView> stackItems = new TrackableIndex<StackItemView>();
|
||||
private final TrackableIndex<StackItemView> stackItems = new TrackableIndex<StackItemView>();*/
|
||||
private final TrackableCollection<PlayerView> players;
|
||||
private CombatView combatView;
|
||||
private final Game game; //TODO: Remove this when possible before network support added
|
||||
|
||||
public GameView(Game game) {
|
||||
public GameView(Game game0) {
|
||||
super(-1); //ID not needed
|
||||
game = game0;
|
||||
set(TrackableProperty.WinningTeam, -1);
|
||||
|
||||
GameRules rules = game.getRules();
|
||||
@@ -36,6 +43,12 @@ public class GameView extends TrackableObject {
|
||||
|
||||
set(TrackableProperty.GameLog, game.getGameLog());
|
||||
set(TrackableProperty.NumPlayedGamesInMatch, game.getMatch().getPlayedGames().size());
|
||||
|
||||
players = PlayerView.getCollection(game.getPlayers());
|
||||
}
|
||||
|
||||
public FCollection<PlayerView>.FCollectionView getPlayers() {
|
||||
return players.getView();
|
||||
}
|
||||
|
||||
public boolean isCommander() {
|
||||
@@ -145,4 +158,47 @@ public class GameView extends TrackableObject {
|
||||
/*GameStateDeserializer deserializer = new GameStateDeserializer();
|
||||
deserializer.readObject();*/
|
||||
}
|
||||
|
||||
//TODO: Find better ways to make this information available to all GUIs without using the Game class
|
||||
|
||||
public FCollection<StackItemView>.FCollectionView getStack() {
|
||||
return StackItemView.getCollection(game.getStack()).getView();
|
||||
}
|
||||
|
||||
public boolean isMatchWonBy(LobbyPlayer questPlayer) {
|
||||
return game.getMatch().isWonBy(questPlayer);
|
||||
}
|
||||
|
||||
public Iterable<GameOutcome> getOutcomesOfMatch() {
|
||||
return game.getMatch().getOutcomes();
|
||||
}
|
||||
|
||||
public LobbyPlayer getWinningPlayer() {
|
||||
return game.getOutcome().getWinningLobbyPlayer();
|
||||
}
|
||||
|
||||
public StackItemView peekStack() {
|
||||
return StackItemView.get(game.getStack().peek());
|
||||
}
|
||||
|
||||
public boolean isWinner(LobbyPlayer guiPlayer) {
|
||||
return game.getOutcome().isWinner(guiPlayer);
|
||||
}
|
||||
|
||||
public int getGamesWonBy(LobbyPlayer questPlayer) {
|
||||
return game.getMatch().getGamesWonBy(questPlayer);
|
||||
}
|
||||
|
||||
public Deck getDeck(LobbyPlayer guiPlayer) {
|
||||
for (Player p : game.getRegisteredPlayers()) {
|
||||
if (p.getLobbyPlayer().equals(guiPlayer)) {
|
||||
return p.getRegisteredPlayer().getDeck();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public AnteResult getAnteResult(PlayerView player) {
|
||||
return game.getOutcome().anteResult.get(Player.get(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ public class ControlSpellEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!c.canBeControlledBy(si.getActivator())) {
|
||||
if (!c.canBeControlledBy(si.getActivatingPlayer())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c.getController().equals(si.getActivator())) {
|
||||
if (c.getController().equals(si.getActivatingPlayer())) {
|
||||
// Controllers are already the same, no exchange needed
|
||||
continue;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class ControlSpellEffect extends SpellAbilityEffect {
|
||||
if (remember) {
|
||||
source.addRemembered(c);
|
||||
}
|
||||
c.setController(si.getActivator(), tStamp);
|
||||
c.setController(si.getActivatingPlayer(), tStamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ControlSpellEffect extends SpellAbilityEffect {
|
||||
source.addRemembered(tgtC);
|
||||
}
|
||||
tgtC.setController(newController, tStamp);
|
||||
si.setActivator(newController);
|
||||
si.setActivatingPlayer(newController);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,21 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Card extends GameEntity implements Comparable<Card>, IIdentifiable {
|
||||
private static HashMap<Integer, Card> cardCache = new HashMap<Integer, Card>();
|
||||
public static Card get(CardView cardView) {
|
||||
return cardCache.get(cardView.getId());
|
||||
}
|
||||
public static List<Card> getList(Iterable<CardView> cardViews) {
|
||||
List<Card> list = new ArrayList<Card>();
|
||||
for (CardView cv : cardViews) {
|
||||
list.add(get(cv));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static void clearCache() {
|
||||
cardCache.clear();
|
||||
}
|
||||
|
||||
private final IPaperCard paperCard;
|
||||
|
||||
private final Map<CardCharacteristicName, CardCharacteristics> characteristicsMap
|
||||
@@ -254,10 +269,15 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
||||
public Card(final int id0, final IPaperCard paperCard0) {
|
||||
super(id0);
|
||||
|
||||
if (id0 >= 0) {
|
||||
cardCache.put(id0, this);
|
||||
}
|
||||
paperCard = paperCard0;
|
||||
characteristicsMap.put(CardCharacteristicName.Original, new CardCharacteristics());
|
||||
characteristicsMap.put(CardCharacteristicName.FaceDown, CardUtil.getFaceDownCharacteristic());
|
||||
view = new CardView(id0);
|
||||
characteristicsMap.put(CardCharacteristicName.Original, new CardCharacteristics(view.getOriginal()));
|
||||
characteristicsMap.put(CardCharacteristicName.FaceDown, CardUtil.getFaceDownCharacteristic(this));
|
||||
view.updateChangedColorWords(this);
|
||||
view.updateChangedTypes(this);
|
||||
}
|
||||
|
||||
public boolean changeToState(final CardCharacteristicName state) {
|
||||
@@ -337,7 +357,6 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
||||
preTFDCharacteristic = curCharacteristics;
|
||||
return setState(CardCharacteristicName.FaceDown);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -359,7 +378,6 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -372,12 +390,19 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
||||
}
|
||||
|
||||
public final void addAlternateState(final CardCharacteristicName state, final boolean updateView) {
|
||||
characteristicsMap.put(state, new CardCharacteristics());
|
||||
characteristicsMap.put(state, new CardCharacteristics(view.createAlternateState()));
|
||||
if (updateView) {
|
||||
view.updateState(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAttackingForView() {
|
||||
view.updateAttacking(this);
|
||||
}
|
||||
public void updateBlockingForView() {
|
||||
view.updateBlocking(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getName() {
|
||||
return getCharacteristics().getName();
|
||||
@@ -2363,7 +2388,7 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
||||
}
|
||||
|
||||
public final void setType(final List<String> a) {
|
||||
getCharacteristics().setType(new ArrayList<String>(a));
|
||||
getCharacteristics().setType(new HashSet<String>(a));
|
||||
}
|
||||
|
||||
public final void addType(final String a) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import forge.card.CardEdition;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
@@ -36,10 +37,7 @@ import java.util.TreeMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
|
||||
public class CardCharacteristics {
|
||||
private String name = "";
|
||||
private Set<String> type = new CopyOnWriteArraySet<String>();
|
||||
@@ -61,439 +59,57 @@ public class CardCharacteristics {
|
||||
|
||||
private CardRarity rarity = CardRarity.Unknown;
|
||||
private String curSetCode = CardEdition.UNKNOWN.getCode();
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public final String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name0
|
||||
* the name to set
|
||||
*/
|
||||
public final void setName(final String name0) {
|
||||
this.name = name0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public final Set<String> getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type.
|
||||
*
|
||||
* @param type0
|
||||
* the type to set
|
||||
*/
|
||||
public final void setType(final ArrayList<String> type0) {
|
||||
this.type.clear();
|
||||
this.type.addAll(type0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mana cost.
|
||||
*
|
||||
* @return the manaCost
|
||||
*/
|
||||
public final ManaCost getManaCost() {
|
||||
return this.manaCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mana cost.
|
||||
*
|
||||
* @param manaCost0
|
||||
* the manaCost to set
|
||||
*/
|
||||
public final void setManaCost(final ManaCost manaCost0) {
|
||||
this.manaCost = manaCost0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the card color.
|
||||
*
|
||||
* @return the cardColor
|
||||
*/
|
||||
public final List<CardColor> getCardColor() {
|
||||
return this.cardColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the card color.
|
||||
*
|
||||
* @param cardColor0
|
||||
* the cardColor to set
|
||||
*/
|
||||
public final void setCardColor(final Iterable<CardColor> cardColor0) {
|
||||
this.cardColor = Lists.newArrayList(cardColor0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the card color.
|
||||
*/
|
||||
private final CardStateView view;
|
||||
|
||||
public CardCharacteristics(CardStateView view0) {
|
||||
view = view0;
|
||||
}
|
||||
|
||||
public CardStateView getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
public final void setName(final String name0) {
|
||||
name = name0;
|
||||
view.updateName(this);
|
||||
}
|
||||
|
||||
public final Set<String> getType() {
|
||||
return type;
|
||||
}
|
||||
public final void setType(final Set<String> type0) {
|
||||
type.clear();
|
||||
type.addAll(type0);
|
||||
view.updateType(this);
|
||||
}
|
||||
|
||||
public final ManaCost getManaCost() {
|
||||
return manaCost;
|
||||
}
|
||||
public final void setManaCost(final ManaCost manaCost0) {
|
||||
manaCost = manaCost0;
|
||||
view.updateManaCost(this);
|
||||
}
|
||||
|
||||
public final List<CardColor> getCardColor() {
|
||||
return cardColor;
|
||||
}
|
||||
public final void setCardColor(final Iterable<CardColor> cardColor0) {
|
||||
cardColor = Lists.newArrayList(cardColor0);
|
||||
view.updateColors(this);
|
||||
}
|
||||
public final void resetCardColor() {
|
||||
if (!this.cardColor.isEmpty()) {
|
||||
this.cardColor = Lists.newArrayList(this.cardColor.subList(0, 1));
|
||||
}
|
||||
if (cardColor.isEmpty()) { return; }
|
||||
|
||||
cardColor = Lists.newArrayList(cardColor.subList(0, 1));
|
||||
view.updateColors(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the oracleText
|
||||
*/
|
||||
public String getOracleText() {
|
||||
return oracleText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param oracleText the oracleText to set
|
||||
*/
|
||||
public void setOracleText(final String oracleText) {
|
||||
this.oracleText = oracleText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base attack.
|
||||
*
|
||||
* @return the baseAttack
|
||||
*/
|
||||
public final int getBaseAttack() {
|
||||
return this.baseAttack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base attack.
|
||||
*
|
||||
* @param baseAttack0
|
||||
* the baseAttack to set
|
||||
*/
|
||||
public final void setBaseAttack(final int baseAttack0) {
|
||||
this.baseAttack = baseAttack0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base defense.
|
||||
*
|
||||
* @return the baseDefense
|
||||
*/
|
||||
public final int getBaseDefense() {
|
||||
return this.baseDefense;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base defense.
|
||||
*
|
||||
* @param baseDefense0
|
||||
* the baseDefense to set
|
||||
*/
|
||||
public final void setBaseDefense(final int baseDefense0) {
|
||||
this.baseDefense = baseDefense0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the intrinsic keyword.
|
||||
*
|
||||
* @return the intrinsicKeyword
|
||||
*/
|
||||
public final List<String> getIntrinsicKeyword() {
|
||||
return this.intrinsicKeyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the intrinsic keyword.
|
||||
*
|
||||
* @param intrinsicKeyword0
|
||||
* the intrinsicKeyword to set
|
||||
*/
|
||||
public final void setIntrinsicKeyword(final ArrayList<String> intrinsicKeyword0) {
|
||||
this.intrinsicKeyword = intrinsicKeyword0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the spell ability.
|
||||
*
|
||||
* @return the spellAbility
|
||||
*/
|
||||
public final List<SpellAbility> getSpellAbility() {
|
||||
return this.spellAbility;
|
||||
}
|
||||
|
||||
public final void setSpellAbility(SpellAbility sa) {
|
||||
this.spellAbility.clear();
|
||||
if (sa != null) {
|
||||
this.spellAbility.add(sa);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the intrinsic ability.
|
||||
*
|
||||
* @return the intrinsicAbility
|
||||
*/
|
||||
public final List<String> getUnparsedAbilities() {
|
||||
return this.unparsedAbilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the intrinsic ability.
|
||||
*
|
||||
* @param list
|
||||
* the intrinsicAbility to set
|
||||
*/
|
||||
public final void setUnparsedAbilities(final List<String> list) {
|
||||
this.unparsedAbilities = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mana ability.
|
||||
*
|
||||
* @return the manaAbility
|
||||
*/
|
||||
public final List<SpellAbility> getManaAbility() {
|
||||
return this.manaAbility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the triggers.
|
||||
*
|
||||
* @return the triggers
|
||||
*/
|
||||
public final List<Trigger> getTriggers() {
|
||||
return this.triggers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the triggers.
|
||||
*
|
||||
* @param triggers0
|
||||
* the triggers to set
|
||||
*/
|
||||
public final void setTriggers(final List<Trigger> triggers0) {
|
||||
this.triggers = triggers0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the static abilities.
|
||||
*
|
||||
* @return the staticAbilities
|
||||
*/
|
||||
public final List<StaticAbility> getStaticAbilities() {
|
||||
return this.staticAbilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the static abilities.
|
||||
*
|
||||
* @param staticAbilities0
|
||||
* the staticAbilities to set
|
||||
*/
|
||||
public final void setStaticAbilities(final ArrayList<StaticAbility> staticAbilities0) {
|
||||
this.staticAbilities = new ArrayList<StaticAbility>(staticAbilities0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the image filename.
|
||||
*
|
||||
* @return the imageFilename
|
||||
*/
|
||||
public final String getImageKey() {
|
||||
return this.imageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image filename.
|
||||
*
|
||||
* @param imageFilename0
|
||||
* the imageFilename to set
|
||||
*/
|
||||
public final void setImageKey(final String imageFilename0) {
|
||||
this.imageKey = imageFilename0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the static ability strings.
|
||||
*
|
||||
* @return the staticAbilityStrings
|
||||
*/
|
||||
public final List<String> getStaticAbilityStrings() {
|
||||
return this.staticAbilityStrings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the static ability strings.
|
||||
*
|
||||
* @param staticAbilityStrings0
|
||||
* the staticAbilityStrings to set
|
||||
*/
|
||||
public final void setStaticAbilityStrings(final ArrayList<String> staticAbilityStrings0) {
|
||||
this.staticAbilityStrings = staticAbilityStrings0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the replacementEffects
|
||||
*/
|
||||
public List<ReplacementEffect> getReplacementEffects() {
|
||||
return replacementEffects;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getSVar.
|
||||
* </p>
|
||||
*
|
||||
* @param var
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getSVar(final String var) {
|
||||
if (this.sVars.containsKey(var)) {
|
||||
return this.sVars.get(var);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* hasSVar.
|
||||
* </p>
|
||||
*
|
||||
* @param var
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public final boolean hasSVar(final String var) {
|
||||
return this.sVars.containsKey(var);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setSVar.
|
||||
* </p>
|
||||
*
|
||||
* @param var
|
||||
* a {@link java.lang.String} object.
|
||||
* @param str
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void setSVar(final String var, final String str) {
|
||||
this.sVars.put(var, str);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getSVars.
|
||||
* </p>
|
||||
*
|
||||
* @return a Map object.
|
||||
*/
|
||||
public final Map<String, String> getSVars() {
|
||||
return this.sVars;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setSVars.
|
||||
* </p>
|
||||
*
|
||||
* @param newSVars
|
||||
* a Map object.
|
||||
*/
|
||||
public final void setSVars(final Map<String, String> newSVars) {
|
||||
this.sVars = newSVars;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
*
|
||||
* @return an int
|
||||
*/
|
||||
public final int getFoil() {
|
||||
final String foil = this.getSVar("Foil");
|
||||
if (!foil.isEmpty()) {
|
||||
return Integer.parseInt(foil);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* copy.
|
||||
* </p>
|
||||
*
|
||||
* @param source
|
||||
* a Map object.
|
||||
*/
|
||||
public final void copyFrom(final CardCharacteristics source) {
|
||||
// Makes a "deeper" copy of a CardCharacteristics object
|
||||
|
||||
// String name : just copy reference
|
||||
this.name = source.getName();
|
||||
// ArrayList<String> type : list of String objects so use copy constructor
|
||||
this.type = new CopyOnWriteArraySet<String>(source.getType());
|
||||
// CardManaCost manaCost : not sure if a deep copy is needed
|
||||
this.manaCost = source.getManaCost();
|
||||
// ArrayList<CardColor> cardColor : not sure if a deep copy is needed
|
||||
this.cardColor = new ArrayList<CardColor>(source.getCardColor());
|
||||
// int baseAttack : set value
|
||||
this.baseAttack = source.getBaseAttack();
|
||||
// int baseDefense : set value
|
||||
this.baseDefense = source.getBaseDefense();
|
||||
// ArrayList<String> intrinsicKeyword : list of String objects so use copy constructor
|
||||
this.intrinsicKeyword = new ArrayList<String>(source.getIntrinsicKeyword());
|
||||
// ArrayList<String> intrinsicAbility : list of String objects so use copy constructor
|
||||
this.unparsedAbilities = new ArrayList<String>(source.getUnparsedAbilities());
|
||||
// ArrayList<String> staticAbilityStrings : list of String objects so use copy constructor
|
||||
this.staticAbilityStrings = new ArrayList<String>(source.getStaticAbilityStrings());
|
||||
// String imageFilename = copy reference
|
||||
this.imageKey = source.getImageKey();
|
||||
this.rarity = source.rarity;
|
||||
this.curSetCode = source.curSetCode;
|
||||
// Map<String, String> sVars
|
||||
this.sVars = new TreeMap<String, String>(source.getSVars());
|
||||
this.replacementEffects = new ArrayList<ReplacementEffect>();
|
||||
for (ReplacementEffect RE : source.getReplacementEffects()) {
|
||||
this.replacementEffects.add(RE.getCopy());
|
||||
}
|
||||
}
|
||||
|
||||
public CardRarity getRarity() {
|
||||
return rarity;
|
||||
}
|
||||
|
||||
|
||||
public void setRarity(CardRarity rarity) {
|
||||
this.rarity = rarity;
|
||||
}
|
||||
|
||||
|
||||
public String getCurSetCode() {
|
||||
return curSetCode;
|
||||
}
|
||||
|
||||
|
||||
public void setCurSetCode(String curSetCode) {
|
||||
this.curSetCode = curSetCode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the colors.
|
||||
*
|
||||
* @return a {@link ColorSet}.
|
||||
*/
|
||||
public final ColorSet determineColor() {
|
||||
final List<CardColor> colorList = this.getCardColor();
|
||||
final List<CardColor> colorList = getCardColor();
|
||||
byte colors = 0;
|
||||
for (int i = colorList.size() - 1;i >= 0;i--) {
|
||||
final CardColor cc = colorList.get(i);
|
||||
@@ -504,4 +120,157 @@ public class CardCharacteristics {
|
||||
}
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
|
||||
public String getOracleText() {
|
||||
return oracleText;
|
||||
}
|
||||
public void setOracleText(final String oracleText0) {
|
||||
oracleText = oracleText0;
|
||||
view.updateText(this);
|
||||
}
|
||||
|
||||
public final int getBaseAttack() {
|
||||
return baseAttack;
|
||||
}
|
||||
public final void setBaseAttack(final int baseAttack0) {
|
||||
if (baseAttack == baseAttack0) { return; }
|
||||
baseAttack = baseAttack0;
|
||||
view.updatePower(this);
|
||||
}
|
||||
|
||||
public final int getBaseDefense() {
|
||||
return baseDefense;
|
||||
}
|
||||
public final void setBaseDefense(final int baseDefense0) {
|
||||
if (baseDefense == baseDefense0) { return; }
|
||||
baseDefense = baseDefense0;
|
||||
view.updateToughness(this);
|
||||
}
|
||||
|
||||
public final List<String> getIntrinsicKeyword() {
|
||||
return intrinsicKeyword;
|
||||
}
|
||||
public final void setIntrinsicKeyword(final ArrayList<String> intrinsicKeyword0) {
|
||||
intrinsicKeyword = intrinsicKeyword0;
|
||||
}
|
||||
|
||||
public final List<SpellAbility> getSpellAbility() {
|
||||
return spellAbility;
|
||||
}
|
||||
public final void setSpellAbility(SpellAbility sa) {
|
||||
spellAbility.clear();
|
||||
if (sa != null) {
|
||||
spellAbility.add(sa);
|
||||
}
|
||||
}
|
||||
|
||||
public final List<String> getUnparsedAbilities() {
|
||||
return unparsedAbilities;
|
||||
}
|
||||
public final void setUnparsedAbilities(final List<String> list) {
|
||||
unparsedAbilities = list;
|
||||
}
|
||||
|
||||
public final List<SpellAbility> getManaAbility() {
|
||||
return manaAbility;
|
||||
}
|
||||
|
||||
public final List<Trigger> getTriggers() {
|
||||
return triggers;
|
||||
}
|
||||
public final void setTriggers(final List<Trigger> triggers0) {
|
||||
triggers = triggers0;
|
||||
}
|
||||
|
||||
public final List<StaticAbility> getStaticAbilities() {
|
||||
return staticAbilities;
|
||||
}
|
||||
public final void setStaticAbilities(final ArrayList<StaticAbility> staticAbilities0) {
|
||||
staticAbilities = new ArrayList<StaticAbility>(staticAbilities0);
|
||||
}
|
||||
|
||||
public final String getImageKey() {
|
||||
return imageKey;
|
||||
}
|
||||
public final void setImageKey(final String imageFilename0) {
|
||||
imageKey = imageFilename0;
|
||||
view.updateImageKey(this);
|
||||
}
|
||||
|
||||
public final List<String> getStaticAbilityStrings() {
|
||||
return staticAbilityStrings;
|
||||
}
|
||||
public final void setStaticAbilityStrings(final ArrayList<String> staticAbilityStrings0) {
|
||||
staticAbilityStrings = staticAbilityStrings0;
|
||||
}
|
||||
|
||||
public List<ReplacementEffect> getReplacementEffects() {
|
||||
return replacementEffects;
|
||||
}
|
||||
|
||||
public final Map<String, String> getSVars() {
|
||||
return sVars;
|
||||
}
|
||||
public final String getSVar(final String var) {
|
||||
if (sVars.containsKey(var)) {
|
||||
return sVars.get(var);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public final boolean hasSVar(final String var) {
|
||||
return sVars.containsKey(var);
|
||||
}
|
||||
public final void setSVar(final String var, final String str) {
|
||||
sVars.put(var, str);
|
||||
view.updateFoilIndex(this);
|
||||
}
|
||||
public final void setSVars(final Map<String, String> newSVars) {
|
||||
sVars = newSVars;
|
||||
view.updateFoilIndex(this);
|
||||
}
|
||||
|
||||
public final int getFoil() {
|
||||
final String foil = getSVar("Foil");
|
||||
if (!foil.isEmpty()) {
|
||||
return Integer.parseInt(foil);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final void copyFrom(final CardCharacteristics source) {
|
||||
// Makes a "deeper" copy of a CardCharacteristics object
|
||||
|
||||
setName(source.getName());
|
||||
setType(source.getType());
|
||||
setManaCost(source.getManaCost());
|
||||
setCardColor(source.getCardColor());
|
||||
setBaseAttack(source.getBaseAttack());
|
||||
setBaseDefense(source.getBaseDefense());
|
||||
intrinsicKeyword = new ArrayList<String>(source.getIntrinsicKeyword());
|
||||
unparsedAbilities = new ArrayList<String>(source.getUnparsedAbilities());
|
||||
staticAbilityStrings = new ArrayList<String>(source.getStaticAbilityStrings());
|
||||
setImageKey(source.getImageKey());
|
||||
setRarity(source.rarity);
|
||||
setCurSetCode(source.curSetCode);
|
||||
setSVars(new TreeMap<String, String>(source.getSVars()));
|
||||
replacementEffects = new ArrayList<ReplacementEffect>();
|
||||
for (ReplacementEffect RE : source.getReplacementEffects()) {
|
||||
replacementEffects.add(RE.getCopy());
|
||||
}
|
||||
}
|
||||
|
||||
public CardRarity getRarity() {
|
||||
return rarity;
|
||||
}
|
||||
public void setRarity(CardRarity rarity0) {
|
||||
rarity = rarity0;
|
||||
}
|
||||
|
||||
public String getCurSetCode() {
|
||||
return curSetCode;
|
||||
}
|
||||
public void setCurSetCode(String curSetCode0) {
|
||||
curSetCode = curSetCode0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,11 +281,11 @@ public final class CardUtil {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static CardCharacteristics getFaceDownCharacteristic() {
|
||||
final ArrayList<String> types = new ArrayList<String>();
|
||||
public static CardCharacteristics getFaceDownCharacteristic(Card c) {
|
||||
final HashSet<String> types = new HashSet<String>();
|
||||
types.add("Creature");
|
||||
|
||||
final CardCharacteristics ret = new CardCharacteristics();
|
||||
final CardCharacteristics ret = new CardCharacteristics(c.getView().createAlternateState());
|
||||
ret.setBaseAttack(2);
|
||||
ret.setBaseDefense(2);
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@ package forge.game.card;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.ImageKeys;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ColorSet;
|
||||
@@ -17,6 +18,7 @@ import forge.card.mana.ManaCost;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.trackable.TrackableCollection;
|
||||
import forge.trackable.TrackableObject;
|
||||
import forge.trackable.TrackableProperty;
|
||||
@@ -27,6 +29,10 @@ public class CardView extends GameEntityView {
|
||||
return c == null ? null : c.getView();
|
||||
}
|
||||
|
||||
public static CardView getCardForUi(IPaperCard pc) {
|
||||
return Card.getCardForUi(pc).getView();
|
||||
}
|
||||
|
||||
public static TrackableCollection<CardView> getCollection(Iterable<Card> cards) {
|
||||
if (cards == null) {
|
||||
return null;
|
||||
@@ -38,10 +44,30 @@ public class CardView extends GameEntityView {
|
||||
return collection;
|
||||
}
|
||||
|
||||
public static boolean mayViewAny(Iterable<CardView> cards) {
|
||||
if (cards == null) { return false; }
|
||||
|
||||
for (CardView cv : cards) {
|
||||
if (cv.mayBeShown) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CardView(int id0) {
|
||||
super(id0);
|
||||
set(TrackableProperty.Original, new CardStateView(id0));
|
||||
}
|
||||
public CardView(int id0, String name0) {
|
||||
this(id0);
|
||||
getOriginal().setName(name0);
|
||||
}
|
||||
public CardView(int id0, String name0, PlayerView ownerAndController, String imageKey) {
|
||||
this(id0, name0);
|
||||
set(TrackableProperty.Owner, ownerAndController);
|
||||
set(TrackableProperty.Controller, ownerAndController);
|
||||
}
|
||||
|
||||
public PlayerView getOwner() {
|
||||
return get(TrackableProperty.Owner);
|
||||
@@ -153,8 +179,19 @@ public class CardView extends GameEntityView {
|
||||
public Map<CounterType, Integer> getCounters() {
|
||||
return get(TrackableProperty.Counters);
|
||||
}
|
||||
public boolean hasSameCounters(CardView otherCard) {
|
||||
Map<CounterType, Integer> counters = getCounters();
|
||||
if (counters == null) {
|
||||
return otherCard.getCounters() == null;
|
||||
}
|
||||
return counters.equals(otherCard.getCounters());
|
||||
}
|
||||
void updateCounters(Card c) {
|
||||
set(TrackableProperty.Counters, c.getCounters());
|
||||
CardStateView state = getOriginal();
|
||||
state.updatePower(c);
|
||||
state.updateToughness(c);
|
||||
state.updateLoyalty(c);
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
@@ -284,13 +321,33 @@ public class CardView extends GameEntityView {
|
||||
return get(TrackableProperty.PairedWith);
|
||||
}
|
||||
|
||||
public Map<String, String> getChangedColorWords() {
|
||||
return get(TrackableProperty.ChangedColorWords);
|
||||
}
|
||||
void updateChangedColorWords(Card c) {
|
||||
set(TrackableProperty.ChangedColorWords, c.getChangedTextColorWords());
|
||||
}
|
||||
|
||||
public Map<String, String> getChangedTypes() {
|
||||
return get(TrackableProperty.ChangedTypes);
|
||||
}
|
||||
void updateChangedTypes(Card c) {
|
||||
set(TrackableProperty.ChangedTypes, c.getChangedTextTypeWords());
|
||||
}
|
||||
|
||||
public CardStateView getOriginal() {
|
||||
return get(TrackableProperty.Original);
|
||||
}
|
||||
|
||||
public boolean hasAltState() {
|
||||
return getAlternate() != null;
|
||||
}
|
||||
public CardStateView getAlternate() {
|
||||
return get(TrackableProperty.Alternate);
|
||||
}
|
||||
CardStateView createAlternateState() {
|
||||
return new CardStateView(getId());
|
||||
}
|
||||
|
||||
public CardStateView getState(final boolean alternate0) {
|
||||
return alternate0 ? getAlternate() : getOriginal();
|
||||
@@ -304,7 +361,6 @@ public class CardView extends GameEntityView {
|
||||
boolean isTransformed = c.getCurState() == CardCharacteristicName.Transformed;
|
||||
boolean hasAltState = isDoubleFaced || isFlipCard || isSplitCard || (isFaceDown/* && mayShowCardFace*/);
|
||||
|
||||
set(TrackableProperty.Alternate, hasAltState ? new CardStateView(getId()) : null);
|
||||
set(TrackableProperty.Cloned, c.isCloned());
|
||||
set(TrackableProperty.FaceDown, isFaceDown);
|
||||
set(TrackableProperty.SplitCard, isSplitCard);
|
||||
@@ -328,53 +384,23 @@ public class CardView extends GameEntityView {
|
||||
orig = CardCharacteristicName.LeftSplit;
|
||||
alt = CardCharacteristicName.RightSplit;
|
||||
}
|
||||
updateState(c, getOriginal(), orig);
|
||||
updateState(c, getAlternate(), alt);
|
||||
return;
|
||||
set(TrackableProperty.Original, c.getState(orig).getView());
|
||||
set(TrackableProperty.Alternate, c.getState(alt).getView());
|
||||
}
|
||||
|
||||
final CardStateView origView = getOriginal();
|
||||
origView.updateName(c);
|
||||
origView.updateColors(c);
|
||||
origView.updateImageKey(c);
|
||||
origView.updateType(c);
|
||||
origView.updateManaCost(c);
|
||||
origView.updatePower(c);
|
||||
origView.updateToughness(c);
|
||||
origView.updateLoyalty(c);
|
||||
origView.updateText(c);
|
||||
origView.updateChangedColorWords(c);
|
||||
origView.updateChangedTypes(c);
|
||||
origView.updateManaCost(c);
|
||||
origView.updateKeywords(c);
|
||||
origView.updateFoilIndex(c);
|
||||
|
||||
if (hasAltState) {
|
||||
else if (hasAltState) {
|
||||
if (isFlipCard && !isFlipped) {
|
||||
updateState(c, getAlternate(), CardCharacteristicName.Flipped);
|
||||
set(TrackableProperty.Alternate, c.getState(CardCharacteristicName.Flipped).getView());
|
||||
}
|
||||
else if (isDoubleFaced && !isTransformed) {
|
||||
updateState(c, getAlternate(), CardCharacteristicName.Transformed);
|
||||
set(TrackableProperty.Alternate, c.getState(CardCharacteristicName.Transformed).getView());
|
||||
}
|
||||
else {
|
||||
updateState(c, getAlternate(), CardCharacteristicName.Original);
|
||||
set(TrackableProperty.Alternate, c.getState(CardCharacteristicName.Original).getView());
|
||||
}
|
||||
}
|
||||
}
|
||||
private void updateState(Card c, CardStateView view, CardCharacteristicName state) {
|
||||
final CardCharacteristics chars = c.getState(state);
|
||||
if (chars == null) { return; } //can happen when split card initialized before both sides have been initialized
|
||||
|
||||
view.updateName(chars);
|
||||
view.updateColors(chars);
|
||||
view.updateImageKey(chars);
|
||||
view.updateType(chars);
|
||||
view.updateManaCost(chars);
|
||||
view.updatePower(chars);
|
||||
view.updateToughness(chars);
|
||||
view.updateLoyalty(chars);
|
||||
view.updateText(chars);
|
||||
view.updateFoilIndex(chars);
|
||||
else {
|
||||
set(TrackableProperty.Alternate, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -422,10 +448,13 @@ public class CardView extends GameEntityView {
|
||||
return get(TrackableProperty.Name);
|
||||
}
|
||||
void updateName(Card c) {
|
||||
set(TrackableProperty.Name, c.getName());
|
||||
setName(c.getName());
|
||||
}
|
||||
void updateName(CardCharacteristics c) {
|
||||
set(TrackableProperty.Name, c.getName());
|
||||
setName(c.getName());
|
||||
}
|
||||
private void setName(String name0) {
|
||||
set(TrackableProperty.Name, name0);
|
||||
}
|
||||
|
||||
public ColorSet getColors() {
|
||||
@@ -438,8 +467,11 @@ public class CardView extends GameEntityView {
|
||||
set(TrackableProperty.Colors, c.determineColor());
|
||||
}
|
||||
|
||||
public String getImageKey() {
|
||||
return get(TrackableProperty.ImageKey);
|
||||
public String getImageKey(boolean ignoreMayBeShown) {
|
||||
if (mayBeShown || ignoreMayBeShown) {
|
||||
return get(TrackableProperty.ImageKey);
|
||||
}
|
||||
return ImageKeys.HIDDEN_CARD;
|
||||
}
|
||||
void updateImageKey(Card c) {
|
||||
set(TrackableProperty.ImageKey, c.getImageKey());
|
||||
@@ -451,9 +483,6 @@ public class CardView extends GameEntityView {
|
||||
public Set<String> getType() {
|
||||
return get(TrackableProperty.Type);
|
||||
}
|
||||
void updateType(Card c) {
|
||||
set(TrackableProperty.Type, c.getType());
|
||||
}
|
||||
void updateType(CardCharacteristics c) {
|
||||
set(TrackableProperty.Type, c.getType());
|
||||
}
|
||||
@@ -461,9 +490,6 @@ public class CardView extends GameEntityView {
|
||||
public ManaCost getManaCost() {
|
||||
return get(TrackableProperty.ManaCost);
|
||||
}
|
||||
void updateManaCost(Card c) {
|
||||
set(TrackableProperty.ManaCost, c.getManaCost());
|
||||
}
|
||||
void updateManaCost(CardCharacteristics c) {
|
||||
set(TrackableProperty.ManaCost, c.getManaCost());
|
||||
}
|
||||
@@ -475,7 +501,13 @@ public class CardView extends GameEntityView {
|
||||
set(TrackableProperty.Power, c.getNetAttack());
|
||||
}
|
||||
void updatePower(CardCharacteristics c) {
|
||||
set(TrackableProperty.Power, c.getBaseAttack());
|
||||
Card card = Card.get(CardView.this);
|
||||
if (card != null) {
|
||||
updatePower(card); //TODO: find a better way to do this
|
||||
}
|
||||
else {
|
||||
set(TrackableProperty.Power, c.getBaseAttack());
|
||||
}
|
||||
}
|
||||
|
||||
public int getToughness() {
|
||||
@@ -485,7 +517,13 @@ public class CardView extends GameEntityView {
|
||||
set(TrackableProperty.Toughness, c.getNetDefense());
|
||||
}
|
||||
void updateToughness(CardCharacteristics c) {
|
||||
set(TrackableProperty.Toughness, c.getBaseDefense());
|
||||
Card card = Card.get(CardView.this);
|
||||
if (card != null) {
|
||||
updateToughness(card); //TODO: find a better way to do this
|
||||
}
|
||||
else {
|
||||
set(TrackableProperty.Toughness, c.getBaseDefense());
|
||||
}
|
||||
}
|
||||
|
||||
public int getLoyalty() {
|
||||
@@ -495,7 +533,13 @@ public class CardView extends GameEntityView {
|
||||
set(TrackableProperty.Loyalty, c.getCurrentLoyalty());
|
||||
}
|
||||
void updateLoyalty(CardCharacteristics c) {
|
||||
set(TrackableProperty.Loyalty, 0); // Q why is loyalty not a property of CardCharacteristic? A: because no alt states have a base loyalty (only candidate is Garruk Relentless).
|
||||
Card card = Card.get(CardView.this);
|
||||
if (card != null) {
|
||||
updateLoyalty(card); //TODO: find a better way to do this
|
||||
}
|
||||
else {
|
||||
set(TrackableProperty.Loyalty, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
@@ -505,31 +549,33 @@ public class CardView extends GameEntityView {
|
||||
set(TrackableProperty.Text, c.getText());
|
||||
}
|
||||
void updateText(CardCharacteristics c) {
|
||||
set(TrackableProperty.Text, c.getOracleText());
|
||||
Card card = Card.get(CardView.this);
|
||||
if (card != null) {
|
||||
updateText(card); //TODO: find a better way to do this
|
||||
}
|
||||
else {
|
||||
set(TrackableProperty.Text, c.getOracleText());
|
||||
}
|
||||
}
|
||||
|
||||
private int foilIndexOverride = -1;
|
||||
public int getFoilIndex() {
|
||||
if (foilIndexOverride >= 0) {
|
||||
return foilIndexOverride;
|
||||
}
|
||||
return get(TrackableProperty.FoilIndex);
|
||||
}
|
||||
void updateFoilIndex(Card c) {
|
||||
set(TrackableProperty.FoilIndex, c.getCharacteristics().getFoil());
|
||||
updateFoilIndex(c.getCharacteristics());
|
||||
}
|
||||
void updateFoilIndex(CardCharacteristics c) {
|
||||
set(TrackableProperty.FoilIndex, c.getFoil());
|
||||
}
|
||||
|
||||
public Map<String, String> getChangedColorWords() {
|
||||
return get(TrackableProperty.ChangedColorWords);
|
||||
}
|
||||
void updateChangedColorWords(Card c) {
|
||||
set(TrackableProperty.ChangedColorWords, c.getChangedTextColorWords());
|
||||
}
|
||||
|
||||
public Map<String, String> getChangedTypes() {
|
||||
return get(TrackableProperty.ChangedTypes);
|
||||
}
|
||||
void updateChangedTypes(Card c) {
|
||||
set(TrackableProperty.ChangedTypes, c.getChangedTextTypeWords());
|
||||
public void setFoilIndexOverride(int index0) {
|
||||
if (index0 < 0) {
|
||||
index0 = CardEdition.getRandomFoil(getSetCode());
|
||||
}
|
||||
foilIndexOverride = index0;
|
||||
}
|
||||
|
||||
public boolean hasDeathtouch() {
|
||||
@@ -690,4 +736,13 @@ public class CardView extends GameEntityView {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//below are properties not shared across game instances
|
||||
private boolean mayBeShown = true; //TODO: Make may be shown get updated
|
||||
public boolean mayBeShown() {
|
||||
return mayBeShown;
|
||||
}
|
||||
public void setMayBeShown(boolean mayBeShown0) {
|
||||
//mayBeShown = mayBeShown0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
@@ -28,6 +29,7 @@ import forge.game.card.CardPredicates;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.*;
|
||||
@@ -72,6 +74,30 @@ public class Combat {
|
||||
}
|
||||
}
|
||||
|
||||
public void endCombat() {
|
||||
//backup attackers and blockers
|
||||
List<Card> attackers = Lists.newArrayList(getAttackers());
|
||||
List<Card> blockers = Lists.newArrayList(getAllBlockers());
|
||||
|
||||
//clear all combat-related collections
|
||||
attackableEntries.clear();
|
||||
attackedByBands.clear();
|
||||
blockedBands.clear();
|
||||
defendingDamageMap.clear();
|
||||
attackersOrderedForDamageAssignment.clear();
|
||||
blockersOrderedForDamageAssignment.clear();
|
||||
lkiCache.clear();
|
||||
combatantsThatDealtFirstStrikeDamage.clear();
|
||||
|
||||
//update view for all attackers and blockers
|
||||
for (Card c : attackers) {
|
||||
c.updateAttackingForView();
|
||||
}
|
||||
for (Card c : blockers) {
|
||||
c.updateBlockingForView();
|
||||
}
|
||||
}
|
||||
|
||||
public final Player getAttackingPlayer() {
|
||||
return this.playerWhoAttacks;
|
||||
}
|
||||
@@ -136,6 +162,7 @@ public class Combat {
|
||||
else {
|
||||
band.addAttacker(c);
|
||||
}
|
||||
c.updateAttackingForView();
|
||||
}
|
||||
|
||||
public final GameEntity getDefenderByAttacker(final Card c) {
|
||||
@@ -213,7 +240,6 @@ public class Combat {
|
||||
public final boolean isBlocked(final Card attacker) {
|
||||
AttackingBand band = getBandOfAttacker(attacker);
|
||||
return band == null ? false : Boolean.TRUE.equals(band.isBlocked());
|
||||
|
||||
}
|
||||
|
||||
// Some cards in Alpha may UNBLOCK an attacker, so second parameter is not always-true
|
||||
@@ -228,27 +254,32 @@ public class Combat {
|
||||
if (blockersOrderedForDamageAssignment.containsKey(attacker)) {
|
||||
addBlockerToDamageAssignmentOrder(attacker, blocker);
|
||||
}
|
||||
blocker.updateBlockingForView();
|
||||
}
|
||||
|
||||
// remove blocked from specific attacker
|
||||
public final void removeBlockAssignment(final Card attacker, final Card blocker) {
|
||||
AttackingBand band = getBandOfAttacker(attacker);
|
||||
Collection<Card> cc = blockedBands.get(band);
|
||||
if (cc != null)
|
||||
if (cc != null) {
|
||||
cc.remove(blocker);
|
||||
}
|
||||
blocker.updateBlockingForView();
|
||||
}
|
||||
|
||||
// remove blocker from everywhere
|
||||
public final void undoBlockingAssignment(final Card blocker) {
|
||||
List<Card> toRemove = Lists.newArrayList(blocker);
|
||||
blockedBands.values().removeAll(toRemove);
|
||||
blocker.updateBlockingForView();
|
||||
}
|
||||
|
||||
public final List<Card> getAllBlockers() {
|
||||
List<Card> result = new ArrayList<Card>();
|
||||
for (Card blocker : blockedBands.values()) {
|
||||
if (!result.contains(blocker))
|
||||
if (!result.contains(blocker)) {
|
||||
result.add(blocker);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -267,7 +298,7 @@ public class Combat {
|
||||
}
|
||||
return blocked;
|
||||
}
|
||||
|
||||
|
||||
public final List<AttackingBand> getAttackingBandsBlockedBy(Card blocker) {
|
||||
List<AttackingBand> bands = Lists.newArrayList();
|
||||
for (Entry<AttackingBand, Card> kv : blockedBands.entries()) {
|
||||
@@ -372,7 +403,6 @@ public class Combat {
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// removes references to this defender from all indices and orders
|
||||
@@ -391,6 +421,8 @@ public class Combat {
|
||||
if (ab != null) {
|
||||
unregisterAttacker(c, ab);
|
||||
ab.removeAttacker(c);
|
||||
c.updateAttackingForView();
|
||||
return;
|
||||
}
|
||||
|
||||
// if not found in attackers, look for this card in blockers
|
||||
@@ -402,7 +434,8 @@ public class Combat {
|
||||
|
||||
// remove card from map
|
||||
while(blockedBands.values().remove(c));
|
||||
} // removeFromCombat()
|
||||
c.updateBlockingForView();
|
||||
}
|
||||
|
||||
public final boolean removeAbsentCombatants() {
|
||||
// iterate all attackers and remove them
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package forge.game.combat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.trackable.TrackableObject;
|
||||
@@ -18,6 +17,12 @@ import forge.trackable.TrackableProperty;
|
||||
public class CombatView extends TrackableObject {
|
||||
public CombatView() {
|
||||
super(-1); //ID not needed
|
||||
set(TrackableProperty.AttackersWithDefenders, new HashMap<CardView, GameEntityView>());
|
||||
set(TrackableProperty.AttackersWithBlockers, new HashMap<CardView, Iterable<CardView>>());
|
||||
set(TrackableProperty.BandsWithDefenders, new HashMap<Iterable<CardView>, GameEntityView>());
|
||||
set(TrackableProperty.BandsWithBlockers, new HashMap<Iterable<CardView>, Iterable<CardView>>());
|
||||
set(TrackableProperty.AttackersWithPlannedBlockers, new HashMap<CardView, Iterable<CardView>>());
|
||||
set(TrackableProperty.BandsWithPlannedBlockers, new HashMap<Iterable<CardView>, Iterable<CardView>>());
|
||||
}
|
||||
private Map<CardView, GameEntityView> getAttackersWithDefenders() {
|
||||
return get(TrackableProperty.AttackersWithDefenders);
|
||||
@@ -51,7 +56,7 @@ public class CombatView extends TrackableObject {
|
||||
}
|
||||
|
||||
public Iterable<GameEntityView> getDefenders() {
|
||||
return Sets.newHashSet(getAttackersWithDefenders().values());
|
||||
return getAttackersWithDefenders().values();
|
||||
}
|
||||
|
||||
public GameEntityView getDefender(final CardView attacker) {
|
||||
@@ -132,11 +137,9 @@ public class CombatView extends TrackableObject {
|
||||
}
|
||||
|
||||
public void addAttackingBand(final Iterable<CardView> attackingBand, final GameEntityView defender, final Iterable<CardView> blockers, final Iterable<CardView> plannedBlockers) {
|
||||
final List<CardView> attackingBandCopy = Lists.newArrayList(attackingBand),
|
||||
blockersCopy, plannedBlockersCopy;
|
||||
|
||||
blockersCopy = blockers == null ? null : Lists.newArrayList(blockers);
|
||||
plannedBlockersCopy = plannedBlockers == null ? null : Lists.newArrayList(plannedBlockers);
|
||||
final List<CardView> attackingBandCopy = Lists.newArrayList(attackingBand);
|
||||
final List<CardView> blockersCopy = blockers == null ? null : Lists.newArrayList(blockers);
|
||||
final List<CardView> plannedBlockersCopy = plannedBlockers == null ? null : Lists.newArrayList(plannedBlockers);
|
||||
|
||||
for (final CardView attacker : attackingBandCopy) {
|
||||
this.getAttackersWithDefenders().put(attacker, defender);
|
||||
|
||||
@@ -311,6 +311,9 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
game.getEndOfCombat().executeUntil();
|
||||
game.getEndOfCombat().executeAt();
|
||||
|
||||
if (combat != null) {
|
||||
combat.endCombat();
|
||||
}
|
||||
//SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
||||
break;
|
||||
|
||||
|
||||
@@ -78,6 +78,21 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command, ZoneType.Ante,
|
||||
ZoneType.Sideboard, ZoneType.PlanarDeck, ZoneType.SchemeDeck));
|
||||
|
||||
private static HashMap<Integer, Player> playerCache = new HashMap<Integer, Player>();
|
||||
public static Player get(PlayerView playerView) {
|
||||
return playerCache.get(playerView.getId());
|
||||
}
|
||||
public static List<Player> getList(Iterable<PlayerView> playerViews) {
|
||||
List<Player> list = new ArrayList<Player>();
|
||||
for (PlayerView pv : playerViews) {
|
||||
list.add(get(pv));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static void clearCache() {
|
||||
playerCache.clear();
|
||||
}
|
||||
|
||||
private final Map<Card, Integer> commanderDamage = new HashMap<Card, Integer>();
|
||||
|
||||
private int poisonCounters = 0;
|
||||
@@ -146,9 +161,12 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
zones.put(z, toPut);
|
||||
}
|
||||
|
||||
view = new PlayerView(id);
|
||||
view = new PlayerView(id0);
|
||||
view.updateMaxHandSize(this);
|
||||
setName(chooseName(name0));
|
||||
if (id0 >= 0) {
|
||||
playerCache.put(id0, this);
|
||||
}
|
||||
}
|
||||
|
||||
public final AchievementTracker getAchievementTracker() {
|
||||
|
||||
@@ -13,6 +13,7 @@ import forge.deck.Deck;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.GameOutcome.AnteResult;
|
||||
import forge.game.GameType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardShields;
|
||||
@@ -136,13 +137,13 @@ public abstract class PlayerController {
|
||||
// Triggers preliminary choice: ask, decline or play
|
||||
private Map<Integer, Boolean> triggersAlwaysAccept = new HashMap<Integer, Boolean>();
|
||||
|
||||
public final boolean shouldAlwaysAcceptTrigger(Integer trigger) { return Boolean.TRUE.equals(triggersAlwaysAccept.get(trigger)); }
|
||||
public final boolean shouldAlwaysDeclineTrigger(Integer trigger) { return Boolean.FALSE.equals(triggersAlwaysAccept.get(trigger)); }
|
||||
public final boolean shouldAlwaysAskTrigger(Integer trigger) { return !triggersAlwaysAccept.containsKey(trigger); }
|
||||
public boolean shouldAlwaysAcceptTrigger(Integer trigger) { return Boolean.TRUE.equals(triggersAlwaysAccept.get(trigger)); }
|
||||
public boolean shouldAlwaysDeclineTrigger(Integer trigger) { return Boolean.FALSE.equals(triggersAlwaysAccept.get(trigger)); }
|
||||
public boolean shouldAlwaysAskTrigger(Integer trigger) { return !triggersAlwaysAccept.containsKey(trigger); }
|
||||
|
||||
public final void setShouldAlwaysAcceptTrigger(Integer trigger) { triggersAlwaysAccept.put(trigger, true); }
|
||||
public final void setShouldAlwaysDeclineTrigger(Integer trigger) { triggersAlwaysAccept.put(trigger, false); }
|
||||
public final void setShouldAlwaysAskTrigger(Integer trigger) { triggersAlwaysAccept.remove(trigger); }
|
||||
public void setShouldAlwaysAcceptTrigger(Integer trigger) { triggersAlwaysAccept.put(trigger, true); }
|
||||
public void setShouldAlwaysDeclineTrigger(Integer trigger) { triggersAlwaysAccept.put(trigger, false); }
|
||||
public void setShouldAlwaysAskTrigger(Integer trigger) { triggersAlwaysAccept.remove(trigger); }
|
||||
|
||||
// End of Triggers preliminary choice
|
||||
|
||||
@@ -293,4 +294,8 @@ public abstract class PlayerController {
|
||||
public boolean canPlayUnlimitedLands() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public AnteResult getAnteResult() {
|
||||
return game.getOutcome().anteResult.get(player);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
package forge.game.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.card.MagicColor;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.Card;
|
||||
@@ -97,7 +101,7 @@ public class PlayerView extends GameEntityView {
|
||||
set(TrackableProperty.NumDrawnThisTurn, p.getNumDrawnThisTurn());
|
||||
}
|
||||
|
||||
public Iterable<String> getKeywords() {
|
||||
public List<String> getKeywords() {
|
||||
return get(TrackableProperty.Keywords);
|
||||
}
|
||||
void updateKeywords(Player p) {
|
||||
@@ -122,37 +126,65 @@ public class PlayerView extends GameEntityView {
|
||||
set(TrackableProperty.CommanderDamage, map);
|
||||
}
|
||||
|
||||
public String getCommanderInfo() {
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
public Iterable<CardView> getAnte() {
|
||||
return get(TrackableProperty.Ante);
|
||||
}
|
||||
public int getAnteSize() {
|
||||
return getZoneSize(TrackableProperty.Ante);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getBattlefield() {
|
||||
return get(TrackableProperty.Battlefield);
|
||||
}
|
||||
public int getBattlefieldSize() {
|
||||
return getZoneSize(TrackableProperty.Battlefield);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getCommand() {
|
||||
return get(TrackableProperty.Command);
|
||||
}
|
||||
public int getCommandSize() {
|
||||
return getZoneSize(TrackableProperty.Command);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getExile() {
|
||||
return get(TrackableProperty.Exile);
|
||||
}
|
||||
public int getExileSize() {
|
||||
return getZoneSize(TrackableProperty.Exile);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getFlashback() {
|
||||
return get(TrackableProperty.Flashback);
|
||||
}
|
||||
public int getFlashbackSize() {
|
||||
return getZoneSize(TrackableProperty.Flashback);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getGraveyard() {
|
||||
return get(TrackableProperty.Graveyard);
|
||||
}
|
||||
public int getGraveyardSize() {
|
||||
return getZoneSize(TrackableProperty.Graveyard);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getHand() {
|
||||
return get(TrackableProperty.Hand);
|
||||
}
|
||||
public int getHandSize() {
|
||||
return getZoneSize(TrackableProperty.Hand);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getLibrary() {
|
||||
return get(TrackableProperty.Library);
|
||||
}
|
||||
public int getLibrarySize() {
|
||||
return getZoneSize(TrackableProperty.Library);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getCards(final ZoneType zone) {
|
||||
TrackableProperty prop = getZoneProp(zone);
|
||||
@@ -161,6 +193,10 @@ public class PlayerView extends GameEntityView {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private int getZoneSize(TrackableProperty zoneProp) {
|
||||
TrackableCollection<CardView> cards = get(zoneProp);
|
||||
return cards == null ? 0 : cards.size();
|
||||
}
|
||||
private TrackableProperty getZoneProp(final ZoneType zone) {
|
||||
switch (zone) {
|
||||
case Ante:
|
||||
@@ -201,4 +237,9 @@ public class PlayerView extends GameEntityView {
|
||||
}
|
||||
set(TrackableProperty.Mana, mana);
|
||||
}
|
||||
|
||||
//TODO: Find better way to do this
|
||||
public LobbyPlayer getLobbyPlayer() {
|
||||
return Player.get(this).getLobbyPlayer();
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,6 @@ import java.util.Map;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SpellAbilityStackInstance implements IIdentifiable {
|
||||
|
||||
private static int maxId = 0;
|
||||
private static int nextId() { return ++maxId; }
|
||||
|
||||
@@ -55,7 +54,7 @@ public class SpellAbilityStackInstance implements IIdentifiable {
|
||||
private final SpellAbility ability;
|
||||
|
||||
private final SpellAbilityStackInstance subInstance;
|
||||
private Player activator;
|
||||
private Player activatingPlayer;
|
||||
|
||||
// When going to a SubAbility that SA has a Instance Choice object
|
||||
private TargetChoices tc = new TargetChoices();
|
||||
@@ -94,7 +93,7 @@ public class SpellAbilityStackInstance implements IIdentifiable {
|
||||
id = nextId();
|
||||
ability = sa;
|
||||
stackDescription = sa.getStackDescription();
|
||||
activator = sa.getActivatingPlayer();
|
||||
activatingPlayer = sa.getActivatingPlayer();
|
||||
|
||||
// Payment info
|
||||
paidHash = ability.getPaidHash();
|
||||
@@ -162,7 +161,7 @@ public class SpellAbilityStackInstance implements IIdentifiable {
|
||||
if (refresh) {
|
||||
ability.resetTargets();
|
||||
ability.setTargets(tc);
|
||||
ability.setActivatingPlayer(activator);
|
||||
ability.setActivatingPlayer(activatingPlayer);
|
||||
|
||||
// Saved sub-SA needs to be reset on the way out
|
||||
if (subInstance != null) {
|
||||
@@ -287,14 +286,14 @@ public class SpellAbilityStackInstance implements IIdentifiable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Player getActivator() {
|
||||
return activator;
|
||||
public Player getActivatingPlayer() {
|
||||
return activatingPlayer;
|
||||
}
|
||||
|
||||
public void setActivator(Player activator0) {
|
||||
if (activator == activator0) { return; }
|
||||
activator = activator0;
|
||||
view.updateActivator(this);
|
||||
public void setActivatingPlayer(Player activatingPlayer0) {
|
||||
if (activatingPlayer == activatingPlayer0) { return; }
|
||||
activatingPlayer = activatingPlayer0;
|
||||
view.updateActivatingPlayer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,18 +2,34 @@ package forge.game.spellability;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.trackable.TrackableCollection;
|
||||
import forge.trackable.TrackableObject;
|
||||
import forge.trackable.TrackableProperty;
|
||||
|
||||
|
||||
public class StackItemView extends TrackableObject {
|
||||
public static StackItemView get(SpellAbilityStackInstance si) {
|
||||
return si == null ? null : si.getView();
|
||||
}
|
||||
|
||||
public static TrackableCollection<StackItemView> getCollection(Iterable<SpellAbilityStackInstance> instances) {
|
||||
if (instances == null) {
|
||||
return null;
|
||||
}
|
||||
TrackableCollection<StackItemView> collection = new TrackableCollection<StackItemView>();
|
||||
for (SpellAbilityStackInstance si : instances) {
|
||||
collection.add(si.getView());
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
public StackItemView(SpellAbilityStackInstance si) {
|
||||
super(si.getId());
|
||||
updateKey(si);
|
||||
updateSourceTrigger(si);
|
||||
updateText(si);
|
||||
updateSourceCard(si);
|
||||
updateActivator(si);
|
||||
updateActivatingPlayer(si);
|
||||
updateTargetCards(si);
|
||||
updateTargetPlayers(si);
|
||||
updateAbility(si);
|
||||
@@ -46,14 +62,14 @@ public class StackItemView extends TrackableObject {
|
||||
return get(TrackableProperty.SourceCard);
|
||||
}
|
||||
void updateSourceCard(SpellAbilityStackInstance si) {
|
||||
set(TrackableProperty.SourceCard, si.getSourceCard());
|
||||
set(TrackableProperty.SourceCard, CardView.get(si.getSourceCard()));
|
||||
}
|
||||
|
||||
public PlayerView getActivator() {
|
||||
return get(TrackableProperty.Activator);
|
||||
public PlayerView getActivatingPlayer() {
|
||||
return get(TrackableProperty.ActivatingPlayer);
|
||||
}
|
||||
void updateActivator(SpellAbilityStackInstance si) {
|
||||
set(TrackableProperty.Activator, PlayerView.get(si.getActivator()));
|
||||
void updateActivatingPlayer(SpellAbilityStackInstance si) {
|
||||
set(TrackableProperty.ActivatingPlayer, PlayerView.get(si.getActivatingPlayer()));
|
||||
}
|
||||
|
||||
public Iterable<CardView> getTargetCards() {
|
||||
|
||||
@@ -103,7 +103,7 @@ public enum TrackableProperty {
|
||||
Key(TrackableTypes.StringType),
|
||||
SourceTrigger(TrackableTypes.IntegerType),
|
||||
SourceCard(TrackableTypes.CardViewType),
|
||||
Activator(TrackableTypes.PlayerViewType),
|
||||
ActivatingPlayer(TrackableTypes.PlayerViewType),
|
||||
TargetCards(TrackableTypes.CardViewCollectionType),
|
||||
TargetPlayers(TrackableTypes.PlayerViewCollectionType),
|
||||
SubInstance(TrackableTypes.StackItemViewType),
|
||||
@@ -111,13 +111,14 @@ public enum TrackableProperty {
|
||||
OptionalTrigger(TrackableTypes.BooleanType),
|
||||
|
||||
//Combat
|
||||
AttackersWithDefenders(null), //TODO
|
||||
AttackersWithBlockers(null),
|
||||
BandsWithDefenders(null),
|
||||
BandsWithBlockers(null),
|
||||
AttackersWithPlannedBlockers(null),
|
||||
BandsWithPlannedBlockers(null),
|
||||
AttackersWithDefenders(TrackableTypes.CardViewCollectionType), //TODO: change out for proper types when serialization needed
|
||||
AttackersWithBlockers(TrackableTypes.CardViewCollectionType),
|
||||
BandsWithDefenders(TrackableTypes.CardViewCollectionType),
|
||||
BandsWithBlockers(TrackableTypes.CardViewCollectionType),
|
||||
AttackersWithPlannedBlockers(TrackableTypes.CardViewCollectionType),
|
||||
BandsWithPlannedBlockers(TrackableTypes.CardViewCollectionType),
|
||||
|
||||
//Game
|
||||
GameType(TrackableTypes.EnumType(GameType.class)),
|
||||
Turn(TrackableTypes.IntegerType),
|
||||
WinningTeam(TrackableTypes.IntegerType),
|
||||
|
||||
@@ -212,10 +212,10 @@ public class TrackableTypes {
|
||||
protected GameEntityView deserialize(TrackableDeserializer td, GameEntityView oldValue) {
|
||||
switch (td.readInt()) {
|
||||
case 0:
|
||||
int cardId = td.readInt();
|
||||
//int cardId = td.readInt();
|
||||
return oldValue; //TODO: lookup card by ID
|
||||
case 1:
|
||||
int playerId = td.readInt();
|
||||
//int playerId = td.readInt();
|
||||
return oldValue; //TODO: lookup player by ID
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user