mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Swap out old GameView structure for new one
This commit is contained in:
12
.gitattributes
vendored
12
.gitattributes
vendored
@@ -16962,6 +16962,7 @@ forge-gui/src/main/java/forge/card/CardScriptInfo.java -text
|
||||
forge-gui/src/main/java/forge/control/ChatArea.java -text
|
||||
forge-gui/src/main/java/forge/control/FControlGameEventHandler.java -text
|
||||
forge-gui/src/main/java/forge/control/FControlGamePlayback.java -text
|
||||
forge-gui/src/main/java/forge/control/WatchLocalGame.java -text
|
||||
forge-gui/src/main/java/forge/control/package-info.java -text
|
||||
forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java -text
|
||||
forge-gui/src/main/java/forge/deck/DeckGeneratorTheme.java -text
|
||||
@@ -17151,17 +17152,6 @@ forge-gui/src/main/java/forge/util/gui/SGuiChoose.java -text
|
||||
forge-gui/src/main/java/forge/util/gui/SGuiDialog.java -text
|
||||
forge-gui/src/main/java/forge/util/gui/SOptionPane.java -text
|
||||
forge-gui/src/main/java/forge/util/package-info.java -text
|
||||
forge-gui/src/main/java/forge/view/Cache.java -text
|
||||
forge-gui/src/main/java/forge/view/CardView.java -text
|
||||
forge-gui/src/main/java/forge/view/CombatView.java -text
|
||||
forge-gui/src/main/java/forge/view/GameEntityView.java -text
|
||||
forge-gui/src/main/java/forge/view/IGameView.java -text
|
||||
forge-gui/src/main/java/forge/view/LocalGameView.java -text
|
||||
forge-gui/src/main/java/forge/view/PlayerView.java -text
|
||||
forge-gui/src/main/java/forge/view/SpellAbilityView.java -text
|
||||
forge-gui/src/main/java/forge/view/StackItemView.java -text
|
||||
forge-gui/src/main/java/forge/view/ViewUtil.java -text
|
||||
forge-gui/src/main/java/forge/view/WatchLocalGame.java -text
|
||||
forge-gui/src/main/resources/proxy-template.ftl -text
|
||||
forge-gui/src/site/apt/index.apt -text
|
||||
forge-gui/tools/PerSetTracking.py svneol=native#text/x-python
|
||||
|
||||
@@ -47,7 +47,7 @@ public class LobbyPlayerAi extends LobbyPlayer implements IGameEntitiesFactory {
|
||||
Player ai = new Player(getName(), game, id);
|
||||
ai.setFirstController(createControllerFor(ai));
|
||||
|
||||
if( rotateProfileEachGame ) {
|
||||
if (rotateProfileEachGame) {
|
||||
setAiProfile(AiProfileUtil.getRandomProfile());
|
||||
System.out.println(String.format("AI profile %s was chosen for the lobby player %s.", getAiProfile(), getName()));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -25,7 +25,9 @@ import forge.control.GuiTimer;
|
||||
import forge.deck.CardPool;
|
||||
import forge.error.BugReportDialog;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.DelayedReveal;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.gui.BoxedProductCardListViewer;
|
||||
@@ -51,8 +53,6 @@ import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.util.BuildInfo;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
import forge.view.CardView;
|
||||
import forge.view.GameEntityView;
|
||||
|
||||
public class GuiDesktop implements IGuiBase {
|
||||
@Override
|
||||
@@ -194,7 +194,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
delayedReveal.reveal(controller); //TODO: Merge this into search dialog
|
||||
}
|
||||
controller.tempShow(optionList);
|
||||
List<GameEntityView> gameEntityViews = controller.getGameView().getGameEntityViews(optionList, false);
|
||||
List<GameEntityView> gameEntityViews = GameEntityView.getEntityCollection(optionList);
|
||||
if (isOptional) {
|
||||
return SGuiChoose.oneOrNone(title, gameEntityViews);
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ import com.mortennobel.imagescaling.ResampleOp;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ImageUtil;
|
||||
import forge.game.card.CardView;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinIcon;
|
||||
import forge.view.CardView;
|
||||
|
||||
/**
|
||||
* This class stores ALL card images in a cache with soft values. this means
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.miginfocom.swing.MigLayout;
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.item.IPaperCard;
|
||||
@@ -28,9 +29,7 @@ import forge.itemmanager.ItemManagerModel;
|
||||
import forge.itemmanager.views.ImageView;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FDeckViewer extends FDialog {
|
||||
@@ -62,7 +61,7 @@ public class FDeckViewer extends FDialog {
|
||||
return new ImageView<PaperCard>(this, model0) {
|
||||
@Override
|
||||
protected void showHoveredItem(PaperCard item) {
|
||||
final CardView card = ViewUtil.getCardForUi(item);
|
||||
final CardView card = CardView.getCardForUi(item);
|
||||
if (card == null) { return; }
|
||||
|
||||
cardDetail.setCard(card);
|
||||
@@ -78,7 +77,7 @@ public class FDeckViewer extends FDialog {
|
||||
final IPaperCard paperCard = cardManager.getSelectedItem();
|
||||
if (paperCard == null) { return; }
|
||||
|
||||
final CardView card = ViewUtil.getCardForUi(paperCard);
|
||||
final CardView card = CardView.getCardForUi(paperCard);
|
||||
if (card == null) { return; }
|
||||
|
||||
cardDetail.setCard(card);
|
||||
|
||||
@@ -31,6 +31,7 @@ import javax.swing.JList;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -38,7 +39,6 @@ import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple class that shows a list of cards in a dialog with preview in its
|
||||
@@ -189,7 +189,7 @@ public class BoxedProductCardListViewer extends FDialog {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < BoxedProductCardListViewer.this.list.size())) {
|
||||
final PaperCard cp = BoxedProductCardListViewer.this.list.get(row);
|
||||
BoxedProductCardListViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
BoxedProductCardListViewer.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
BoxedProductCardListViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
package forge.gui;
|
||||
|
||||
import forge.view.CardView;
|
||||
import forge.game.card.CardView;
|
||||
|
||||
|
||||
/**
|
||||
* The class CardContainer. A card container is an object that references a
|
||||
@@ -28,23 +29,6 @@ import forge.view.CardView;
|
||||
* @version V0.0 17.02.2010
|
||||
*/
|
||||
public interface CardContainer {
|
||||
/**
|
||||
* <p>
|
||||
* setCard.
|
||||
* </p>
|
||||
*
|
||||
* @param card
|
||||
* a {@link CardView} object.
|
||||
*/
|
||||
void setCard(CardView card);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getCard.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link CardView} object.
|
||||
*/
|
||||
CardView getCard();
|
||||
|
||||
void setCard(CardView card);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.CardEdition;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.model.FModel;
|
||||
@@ -41,9 +44,6 @@ import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* The class CardDetailPanel. Shows the details of a card.
|
||||
@@ -130,7 +130,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
powerToughnessLabel.setVisible(false);
|
||||
idLabel.setText("");
|
||||
cdArea.setText(CardDetailUtil.getItemDescription(item));
|
||||
this.updateBorder(item instanceof IPaperCard ? ViewUtil.getCardForUi((IPaperCard)item).getOriginal() : null);
|
||||
this.updateBorder(item instanceof IPaperCard ? Card.getCardForUi((IPaperCard)item).getView().getOriginal() : null);
|
||||
|
||||
String set = item.getEdition();
|
||||
setInfoLabel.setText(set);
|
||||
@@ -185,7 +185,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.nameCostLabel.setText(CardDetailUtil.formatCardName(state));
|
||||
} else {
|
||||
final String manaCost;
|
||||
if (card.isSplitCard() && card.hasAltState()) {
|
||||
if (card.isSplitCard() && card.getAlternate() != null) {
|
||||
manaCost = card.getOriginal().getManaCost() + " // " + card.getAlternate().getManaCost();
|
||||
} else {
|
||||
manaCost = state.getManaCost().toString();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package forge.gui;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -26,7 +27,6 @@ import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
@@ -173,7 +173,7 @@ public class CardListChooser extends FDialog {
|
||||
final int row = CardListChooser.this.jList.getSelectedIndex();
|
||||
if ((row >= 0) && (row < CardListChooser.this.list.size())) {
|
||||
final PaperCard cp = CardListChooser.this.list.get(row);
|
||||
CardListChooser.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
CardListChooser.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
CardListChooser.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import javax.swing.JList;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -38,7 +39,6 @@ import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple class that shows a list of cards in a dialog with preview in its
|
||||
@@ -172,7 +172,7 @@ public class CardListViewer extends FDialog {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < CardListViewer.this.list.size())) {
|
||||
final PaperCard cp = CardListViewer.this.list.get(row);
|
||||
CardListViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
CardListViewer.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
CardListViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ import javax.swing.JPanel;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.ImageKeys;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.toolbox.imaging.FImagePanel;
|
||||
import forge.toolbox.imaging.FImagePanel.AutoSizeImageMode;
|
||||
import forge.toolbox.imaging.FImageUtil;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
/**
|
||||
* Displays image associated with a card or inventory item.
|
||||
|
||||
@@ -21,6 +21,10 @@ import javax.swing.event.ListDataListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.game.spellability.SpellAbilityView;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.screens.match.CMatchUI;
|
||||
@@ -29,11 +33,7 @@ import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FPanel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.SpellAbilityView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
// An input box for handling the order of choices.
|
||||
// Left box has the original choices
|
||||
@@ -334,7 +334,7 @@ public class DualListBox<T> extends FDialog {
|
||||
} else if (obj instanceof SpellAbilityView) {
|
||||
card = ((SpellAbilityView) obj).getHostCard();
|
||||
} else if (obj instanceof PaperCard) {
|
||||
card = ViewUtil.getCardForUi((IPaperCard) obj);
|
||||
card = Card.getCardForUi((IPaperCard) obj).getView();
|
||||
}
|
||||
|
||||
GuiUtils.clearPanelSelections();
|
||||
|
||||
@@ -20,16 +20,13 @@ import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
|
||||
public class GuiChoose {
|
||||
|
||||
/**
|
||||
@@ -210,9 +207,11 @@ public class GuiChoose {
|
||||
final CardView card;
|
||||
if (sel instanceof CardStateView) {
|
||||
card = ((CardStateView) sel).getCard();
|
||||
} else if (sel instanceof CardView) {
|
||||
}
|
||||
else if (sel instanceof CardView) {
|
||||
card = (CardView) sel;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
card = null;
|
||||
}
|
||||
if (card != null) {
|
||||
|
||||
@@ -8,9 +8,9 @@ import javax.swing.UIManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.card.CardView;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.view.CardView;
|
||||
|
||||
/**
|
||||
* Holds player interactions using standard windows
|
||||
|
||||
@@ -32,9 +32,9 @@ import javax.swing.JPopupMenu;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.screens.match.VMatchUI;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.view.CardView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import forge.ImageCache;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.framework.ILocalRepaint;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
@@ -20,8 +21,6 @@ import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinFont;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -234,7 +233,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
ItemInfo item = getItemAtPoint(e.getPoint());
|
||||
if (item != null && item.item instanceof IPaperCard) {
|
||||
setLockHoveredItem(true); //lock hoveredItem while zoomer open
|
||||
final CardView card = ViewUtil.getCardForUi((IPaperCard) item.item);
|
||||
final CardView card = CardView.getCardForUi((IPaperCard) item.item);
|
||||
CardZoomer.SINGLETON_INSTANCE.doMouseButtonZoom(card);
|
||||
}
|
||||
}
|
||||
@@ -1101,14 +1100,14 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
if (item instanceof IPaperCard) {
|
||||
IPaperCard paperCard = (IPaperCard)item;
|
||||
if (paperCard.isFoil()) {
|
||||
final CardView card = ViewUtil.getCardForUi(paperCard);
|
||||
final CardView card = CardView.getCardForUi(paperCard);
|
||||
if (card.getOriginal().getFoilIndex() == 0) { //if foil finish not yet established, assign a random one
|
||||
// FIXME should assign a random foil here in all cases
|
||||
// (currently assigns 1 for the deck editors where foils "flicker" otherwise)
|
||||
if (item instanceof Card) {
|
||||
card.getOriginal().setRandomFoil();
|
||||
card.getOriginal().setFoilIndexOverride(-1); //-1 to set random foil
|
||||
} else if (item instanceof IPaperCard) {
|
||||
card.getOriginal().setFoilIndex(1);
|
||||
card.getOriginal().setFoilIndexOverride(1);
|
||||
}
|
||||
}
|
||||
CardPanel.drawFoilEffect(g, card, bounds.x, bounds.y, bounds.width, bounds.height, borderSize);
|
||||
|
||||
@@ -40,6 +40,7 @@ import forge.deckchooser.DecksComboBoxEvent;
|
||||
import forge.deckchooser.FDeckChooser;
|
||||
import forge.deckchooser.IDecksComboBoxListener;
|
||||
import forge.game.GameType;
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
@@ -75,7 +76,6 @@ import forge.toolbox.FTextField;
|
||||
import forge.util.Lang;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.NameGenerator;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of constructed submenu singleton.
|
||||
@@ -1243,7 +1243,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
|
||||
if (obj instanceof PaperCard) {
|
||||
pp.setVanguardButtonText(((PaperCard) obj).getName());
|
||||
cdp.setCard(ViewUtil.getCardForUi((PaperCard) obj));
|
||||
cdp.setCard(CardView.getCardForUi((PaperCard) obj));
|
||||
cdp.setVisible(true);
|
||||
refreshPanels(false, true);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.awt.event.MouseMotionListener;
|
||||
import forge.achievement.Achievement;
|
||||
import forge.achievement.AchievementCollection;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -30,7 +31,6 @@ import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinFont;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.ViewUtil;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -104,7 +104,7 @@ public enum VSubmenuAchievements implements IVSubmenu<CSubmenuAchievements> {
|
||||
IPaperCard pc = achievement.getPaperCard();
|
||||
if (pc != null) {
|
||||
preventMouseOut = true;
|
||||
CardZoomer.SINGLETON_INSTANCE.doMouseButtonZoom(ViewUtil.getCardForUi(pc));
|
||||
CardZoomer.SINGLETON_INSTANCE.doMouseButtonZoom(CardView.getCardForUi(pc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,9 +39,15 @@ import forge.ImageCache;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.GameView;
|
||||
import forge.game.Match;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.combat.CombatView;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.FNetOverlay;
|
||||
import forge.gui.GuiChoose;
|
||||
@@ -82,13 +88,6 @@ import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.special.PhaseIndicator;
|
||||
import forge.toolbox.special.PhaseLabel;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.LocalGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.SpellAbilityView;
|
||||
import forge.view.ViewUtil;
|
||||
import forge.view.arcane.CardPanel;
|
||||
import forge.view.arcane.PlayArea;
|
||||
|
||||
@@ -169,7 +168,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
int i = 0;
|
||||
for (final PlayerView p : sortedPlayers) {
|
||||
if (allHands || p.getLobbyPlayer() instanceof LobbyPlayerHuman || ViewUtil.mayViewAny(p.getHandCards())) {
|
||||
if (allHands || p.getLobbyPlayer() instanceof LobbyPlayerHuman || CardView.mayViewAny(p.getHand())) {
|
||||
VHand newHand = new VHand(EDocID.Hands[i], p);
|
||||
newHand.getLayoutControl().initialize();
|
||||
hands.add(newHand);
|
||||
@@ -247,7 +246,9 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
return sortedPlayers.indexOf(player);
|
||||
}
|
||||
|
||||
public void showCombat(final CombatView combat) {
|
||||
@Override
|
||||
public void showCombat() {
|
||||
CombatView combat = MatchUtil.getGameView().getCombat();
|
||||
if (combat != null && combat.getNumAttackers() > 0 && MatchUtil.getGameView().peekStack() == null) {
|
||||
if (selectedDocBeforeCombat == null) {
|
||||
IVDoc<? extends ICDoc> combatDoc = EDocID.REPORT_COMBAT.getDoc();
|
||||
@@ -427,7 +428,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
LocalGameView gameView = MatchUtil.getGameView();
|
||||
GameView gameView = MatchUtil.getGameView();
|
||||
final PlayerView p = gameView.getPlayerTurn();
|
||||
final PhaseType ph = gameView.getPhase();
|
||||
final CMatchUI matchUi = CMatchUI.SINGLETON_INSTANCE;
|
||||
@@ -486,26 +487,25 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAbilityToPlay(List<SpellAbilityView> abilities, ITriggerEvent triggerEvent) {
|
||||
public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, ITriggerEvent triggerEvent) {
|
||||
if (triggerEvent == null) {
|
||||
if (abilities.isEmpty()) {
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
if (abilities.size() == 1) {
|
||||
return abilities.get(0).getId();
|
||||
return abilities.get(0);
|
||||
}
|
||||
final SpellAbilityView choice = GuiChoose.oneOrNone("Choose ability to play", abilities);
|
||||
return choice == null ? -1 : choice.getId();
|
||||
return GuiChoose.oneOrNone("Choose ability to play", abilities);
|
||||
}
|
||||
|
||||
if (abilities.isEmpty()) {
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
if (abilities.size() == 1 && !abilities.get(0).isPromptIfOnlyPossibleAbility()) {
|
||||
if (abilities.size() == 1 && !abilities.get(0).promptIfOnlyPossibleAbility()) {
|
||||
if (abilities.get(0).canPlay()) {
|
||||
return abilities.get(0).getId(); //only return ability if it's playable, otherwise return null
|
||||
return abilities.get(0); //only return ability if it's playable, otherwise return null
|
||||
}
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
|
||||
//show menu if mouse was trigger for ability
|
||||
@@ -514,7 +514,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
boolean enabled;
|
||||
boolean hasEnabled = false;
|
||||
int shortcut = KeyEvent.VK_1; //use number keys as shortcuts for abilities 1-9
|
||||
for (final SpellAbilityView ab : abilities) {
|
||||
for (final SpellAbility ab : abilities) {
|
||||
enabled = ab.canPlay();
|
||||
if (enabled) {
|
||||
hasEnabled = true;
|
||||
@@ -544,7 +544,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
menu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
|
||||
}
|
||||
|
||||
return -1; //delay ability until choice made
|
||||
return null; //delay ability until choice made
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -615,7 +615,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
public void openView(List<Player> sortedPlayers) {
|
||||
List<PlayerView> sortedPlayerViews = new ArrayList<PlayerView>();
|
||||
for (Player p : sortedPlayers) {
|
||||
sortedPlayerViews.add(MatchUtil.getGameView().getPlayerView(p, false));
|
||||
sortedPlayerViews.add(PlayerView.get(p));
|
||||
}
|
||||
CMatchUI.SINGLETON_INSTANCE.initMatch(sortedPlayerViews, MatchUtil.getHumanCount() != 1);
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import java.awt.event.ActionListener;
|
||||
import javax.swing.JButton;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.GameView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* Default controller for a ViewWinLose object. This class can
|
||||
@@ -19,11 +19,11 @@ import forge.view.IGameView;
|
||||
*/
|
||||
public class ControlWinLose {
|
||||
private final ViewWinLose view;
|
||||
protected final IGameView lastGame;
|
||||
protected final GameView lastGame;
|
||||
|
||||
/** @param v   ViewWinLose
|
||||
* @param match */
|
||||
public ControlWinLose(final ViewWinLose v, final IGameView game0) {
|
||||
public ControlWinLose(final ViewWinLose v, final GameView game0) {
|
||||
this.view = v;
|
||||
this.lastGame = game0;
|
||||
addListeners();
|
||||
|
||||
@@ -26,11 +26,11 @@ import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.GameView;
|
||||
import forge.gauntlet.GauntletWinLoseController;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* The Win/Lose handler for 'gauntlet' type tournament
|
||||
@@ -45,7 +45,7 @@ public class GauntletWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match
|
||||
*/
|
||||
public GauntletWinLose(final ViewWinLose view0, final IGameView game0) {
|
||||
public GauntletWinLose(final ViewWinLose view0, final GameView game0) {
|
||||
super(view0, game0);
|
||||
controller = new GauntletWinLoseController(view0, game0) {
|
||||
@Override
|
||||
|
||||
@@ -21,12 +21,12 @@ import java.awt.Dimension;
|
||||
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import forge.game.GameView;
|
||||
import forge.limited.LimitedWinLoseController;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.Colors;
|
||||
import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* The Win/Lose handler for 'gauntlet' type tournament
|
||||
@@ -46,7 +46,7 @@ public class LimitedWinLose extends ControlWinLose {
|
||||
* @param view0 {@link forge.screens.match.ViewWinLose}
|
||||
* @param match {@link forge.game.Match}
|
||||
*/
|
||||
public LimitedWinLose(final ViewWinLose view0, final IGameView game0) {
|
||||
public LimitedWinLose(final ViewWinLose view0, final GameView game0) {
|
||||
super(view0, game0);
|
||||
controller = new LimitedWinLoseController(view0, game0) {
|
||||
@Override
|
||||
|
||||
@@ -18,11 +18,11 @@ package forge.screens.match;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.GameView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.match.MatchUtil;
|
||||
@@ -36,8 +36,6 @@ import forge.screens.home.quest.CSubmenuQuestDraft;
|
||||
import forge.screens.home.quest.VSubmenuQuestDraft;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -59,7 +57,7 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestDraftWinLose(final ViewWinLose view0, final IGameView game0) {
|
||||
public QuestDraftWinLose(final ViewWinLose view0, final GameView game0) {
|
||||
super(view0, game0);
|
||||
this.view = view0;
|
||||
qData = FModel.getQuest();
|
||||
@@ -79,7 +77,7 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
QuestController quest = FModel.getQuest();
|
||||
|
||||
final LobbyPlayer questLobbyPlayer = GamePlayerUtil.getQuestPlayer();
|
||||
final List<PlayerView> players = lastGame.getPlayers();
|
||||
final Iterable<PlayerView> players = lastGame.getPlayers();
|
||||
boolean gameHadHumanPlayer = false;
|
||||
for (final PlayerView p : players) {
|
||||
if (p.getLobbyPlayer().equals(questLobbyPlayer)) {
|
||||
@@ -87,33 +85,30 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastGame.isMatchOver()) {
|
||||
|
||||
if (lastGame.isMatchOver()) {
|
||||
String winner = lastGame.getWinningPlayer().getName();
|
||||
|
||||
quest.getAchievements().getCurrentDraft().setWinner(winner);
|
||||
quest.save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!gameHadHumanPlayer) {
|
||||
|
||||
if (lastGame.isMatchOver()) {
|
||||
this.actionOnQuitMatch();
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.update();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.actionOnContinue();
|
||||
QuestDraftUtils.update();
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
view.getBtnRestart().setEnabled(false);
|
||||
view.getBtnRestart().setVisible(false);
|
||||
|
||||
|
||||
if (lastGame.isMatchOver()) {
|
||||
view.getBtnQuit().setEnabled(true);
|
||||
view.getBtnContinue().setEnabled(false);
|
||||
@@ -129,7 +124,8 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
QuestDraftUtils.continueMatches();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
view.getBtnQuit().setEnabled(true);
|
||||
for (ActionListener listener : view.getBtnQuit().getActionListeners()) {
|
||||
view.getBtnQuit().removeActionListener(listener);
|
||||
@@ -146,13 +142,13 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
CSubmenuQuestDraft.SINGLETON_INSTANCE.update();
|
||||
VSubmenuQuestDraft.SINGLETON_INSTANCE.populate();
|
||||
|
||||
|
||||
return false; //We're not awarding anything, so never display the custom panel.
|
||||
}
|
||||
|
||||
|
||||
public final void actionOnQuitMatch() {
|
||||
CSubmenuDuels.SINGLETON_INSTANCE.update();
|
||||
CSubmenuChallenges.SINGLETON_INSTANCE.update();
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.GameView;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -33,7 +34,6 @@ import forge.toolbox.FSkin.Colors;
|
||||
import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinIcon;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -61,7 +61,7 @@ public class QuestWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestWinLose(final ViewWinLose view0, final IGameView game0) {
|
||||
public QuestWinLose(final ViewWinLose view0, final GameView game0) {
|
||||
super(view0, game0);
|
||||
view = view0;
|
||||
controller = new QuestWinLoseController(game0) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.item.PaperCard;
|
||||
@@ -35,7 +36,6 @@ import forge.toolbox.FList;
|
||||
import forge.toolbox.FPanel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple JPanel that shows three columns: card list, pic, and description..
|
||||
@@ -112,10 +112,9 @@ public class QuestWinLoseCardViewer extends FPanel {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < QuestWinLoseCardViewer.this.list.size())) {
|
||||
final PaperCard cp = QuestWinLoseCardViewer.this.list.get(row);
|
||||
QuestWinLoseCardViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
QuestWinLoseCardViewer.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
QuestWinLoseCardViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,24 +35,23 @@ import javax.swing.JPanel;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.GameView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.combat.CombatView;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.FView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
* Semi-transparent overlay panel. Should be used with layered panes.
|
||||
*
|
||||
*/
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public enum TargetingOverlay {
|
||||
/** */
|
||||
@@ -365,7 +364,7 @@ public enum TargetingOverlay {
|
||||
if (overlaystate == 0) { return; }
|
||||
|
||||
// Arc drawing
|
||||
final IGameView gameView = MatchUtil.getGameView();
|
||||
final GameView gameView = MatchUtil.getGameView();
|
||||
if (gameView != null) {
|
||||
assembleArcs(gameView.getCombat());
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ import net.miginfocom.swing.MigLayout;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.toolbox.FButton;
|
||||
@@ -44,10 +47,7 @@ import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
@@ -145,16 +145,16 @@ public class VAssignDamage {
|
||||
* @param overrideOrder override combatant order
|
||||
|
||||
*/
|
||||
public VAssignDamage(final CardView attacker, final List<CardView> blockers, final int damage0, final GameEntityView defender, boolean overrideOrder) {
|
||||
public VAssignDamage(final CardView attacker, final List<CardView> blockers, final int damage0, final GameEntityView defender0, boolean overrideOrder) {
|
||||
dlg.setTitle("Assign damage dealt by " + attacker);
|
||||
|
||||
// Set damage storage vars
|
||||
this.totalDamageToAssign = damage0;
|
||||
this.defender = defender;
|
||||
this.attackerHasDeathtouch = attacker.getOriginal().hasDeathtouch();
|
||||
this.attackerHasInfect = attacker.getOriginal().hasInfect();
|
||||
this.attackerHasTrample = defender != null && attacker.getOriginal().hasTrample();
|
||||
this.overrideCombatantOrder = overrideOrder;
|
||||
totalDamageToAssign = damage0;
|
||||
defender = defender0;
|
||||
attackerHasDeathtouch = attacker.getOriginal().hasDeathtouch();
|
||||
attackerHasInfect = attacker.getOriginal().hasInfect();
|
||||
attackerHasTrample = defender != null && attacker.getOriginal().hasTrample();
|
||||
overrideCombatantOrder = overrideOrder;
|
||||
|
||||
// Top-level UI stuff
|
||||
final JPanel overlay = SOverlayUtils.genericOverlay();
|
||||
@@ -184,28 +184,23 @@ public class VAssignDamage {
|
||||
// Top row of cards...
|
||||
for (final CardView c : blockers) {
|
||||
DamageTarget dt = new DamageTarget(c, new FLabel.Builder().text("0").fontSize(18).fontAlign(SwingConstants.CENTER).build());
|
||||
this.damage.put(c, dt);
|
||||
this.defenders.add(dt);
|
||||
damage.put(c, dt);
|
||||
defenders.add(dt);
|
||||
addPanelForDefender(pnlDefenders, c);
|
||||
}
|
||||
|
||||
if (attackerHasTrample) {
|
||||
DamageTarget dt = new DamageTarget(null, new FLabel.Builder().text("0").fontSize(18).fontAlign(SwingConstants.CENTER).build());
|
||||
this.damage.put(null, dt);
|
||||
this.defenders.add(dt);
|
||||
damage.put(null, dt);
|
||||
defenders.add(dt);
|
||||
CardView fakeCard = null;
|
||||
if (defender instanceof CardView) {
|
||||
fakeCard = (CardView)defender;
|
||||
}
|
||||
else if (defender instanceof PlayerView) {
|
||||
fakeCard = new CardView(-1);
|
||||
fakeCard.getOriginal().setName(this.defender.toString());
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
fakeCard.setOwner(p);
|
||||
fakeCard.setController(p);
|
||||
fakeCard.getOriginal().setImageKey(CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayer()));
|
||||
fakeCard = new CardView(-1, defender.toString(), p, CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayer()));
|
||||
}
|
||||
|
||||
addPanelForDefender(pnlDefenders, fakeCard);
|
||||
}
|
||||
|
||||
@@ -251,12 +246,12 @@ public class VAssignDamage {
|
||||
initialAssignDamage(false);
|
||||
SOverlayUtils.showOverlay();
|
||||
|
||||
this.dlg.setUndecorated(true);
|
||||
this.dlg.setContentPane(pnlMain);
|
||||
this.dlg.setSize(new Dimension(wDlg, hDlg));
|
||||
this.dlg.setLocation((overlay.getWidth() - wDlg) / 2, (overlay.getHeight() - hDlg) / 2);
|
||||
this.dlg.setModalityType(ModalityType.APPLICATION_MODAL);
|
||||
this.dlg.setVisible(true);
|
||||
dlg.setUndecorated(true);
|
||||
dlg.setContentPane(pnlMain);
|
||||
dlg.setSize(new Dimension(wDlg, hDlg));
|
||||
dlg.setLocation((overlay.getWidth() - wDlg) / 2, (overlay.getHeight() - hDlg) / 2);
|
||||
dlg.setModalityType(ModalityType.APPLICATION_MODAL);
|
||||
dlg.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,7 +279,7 @@ public class VAssignDamage {
|
||||
|
||||
// If trying to assign to the defender, follow the normal assignment rules
|
||||
// No need to check for "active" creature assignee when overiding combatant order
|
||||
if ((source == null || source == this.defender || !this.overrideCombatantOrder) && isAdding &&
|
||||
if ((source == null || source == defender || !overrideCombatantOrder) && isAdding &&
|
||||
!VAssignDamage.this.canAssignTo(source)) {
|
||||
return;
|
||||
}
|
||||
@@ -312,7 +307,7 @@ public class VAssignDamage {
|
||||
|
||||
// cannot assign first blocker less than lethal damage except when overriding order
|
||||
boolean isFirstBlocker = defenders.get(0).card == source;
|
||||
if (!this.overrideCombatantOrder && isFirstBlocker && damageToAdd + damageItHad < lethalDamage )
|
||||
if (!overrideCombatantOrder && isFirstBlocker && damageToAdd + damageItHad < lethalDamage )
|
||||
return;
|
||||
|
||||
if ( 0 == damageToAdd || damageToAdd + damageItHad < 0)
|
||||
@@ -331,7 +326,7 @@ public class VAssignDamage {
|
||||
int damage = dt.damage;
|
||||
// If overriding combatant order, make sure everything has lethal if defender has damage assigned to it
|
||||
// Otherwise, follow normal combatant order
|
||||
if ( hasAliveEnemy && (!this.overrideCombatantOrder || dt.card == null || dt.card == this.defender))
|
||||
if ( hasAliveEnemy && (!overrideCombatantOrder || dt.card == null || dt.card == defender))
|
||||
dt.damage = 0;
|
||||
else
|
||||
hasAliveEnemy |= damage < lethal;
|
||||
@@ -340,7 +335,7 @@ public class VAssignDamage {
|
||||
|
||||
// will assign all damage to defenders and rest to player, if present
|
||||
private void initialAssignDamage(boolean toAllBlockers) {
|
||||
if (!toAllBlockers && this.overrideCombatantOrder) {
|
||||
if (!toAllBlockers && overrideCombatantOrder) {
|
||||
// Don't auto assign the first damage when overriding combatant order
|
||||
updateLabels();
|
||||
return;
|
||||
@@ -420,7 +415,7 @@ public class VAssignDamage {
|
||||
dt.label.setText(sb.toString());
|
||||
}
|
||||
|
||||
this.lblTotalDamage.setText(String.format("Available damage points: %d (of %d)", damageLeft, this.totalDamageToAssign));
|
||||
lblTotalDamage.setText(String.format("Available damage points: %d (of %d)", damageLeft, totalDamageToAssign));
|
||||
btnOK.setEnabled(damageLeft == 0);
|
||||
lblAssignRemaining.setVisible(allHaveLethal && damageLeft > 0);
|
||||
}
|
||||
@@ -435,23 +430,20 @@ public class VAssignDamage {
|
||||
dlg.dispose();
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param card
|
||||
* @return
|
||||
*/
|
||||
|
||||
private int getDamageToKill(final CardView card) {
|
||||
int lethalDamage = 0;
|
||||
if (card == null) {
|
||||
if (defender instanceof PlayerView) {
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
lethalDamage = attackerHasInfect ? MatchUtil.getGameView().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
} else if (defender instanceof CardView) { // planeswalker
|
||||
}
|
||||
else if (defender instanceof CardView) { // planeswalker
|
||||
final CardView pw = (CardView)defender;
|
||||
lethalDamage = pw.getOriginal().getLoyalty();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lethalDamage = VAssignDamage.this.attackerHasDeathtouch ? 1 : Math.max(0, card.getLethalDamage());
|
||||
}
|
||||
return lethalDamage;
|
||||
|
||||
@@ -10,13 +10,13 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FCheckBox;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.IGameView;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class VAutoYields extends FDialog {
|
||||
@@ -31,12 +31,12 @@ public class VAutoYields extends FDialog {
|
||||
private final FCheckBox chkDisableAll;
|
||||
private final List<String> autoYields;
|
||||
|
||||
public VAutoYields(final IGameView game) {
|
||||
public VAutoYields(final PlayerControllerHuman humanController) {
|
||||
super(true);
|
||||
setTitle("Auto-Yields");
|
||||
|
||||
autoYields = new ArrayList<String>();
|
||||
for (final String autoYield : game.getAutoYields()) {
|
||||
for (final String autoYield : humanController.getAutoYields()) {
|
||||
autoYields.add(autoYield);
|
||||
}
|
||||
lstAutoYields = new FList<String>(new AutoYieldsListModel());
|
||||
@@ -48,11 +48,11 @@ public class VAutoYields extends FDialog {
|
||||
|
||||
listScroller = new FScrollPane(lstAutoYields, true);
|
||||
|
||||
chkDisableAll = new FCheckBox("Disable All Auto Yields", game.getDisableAutoYields());
|
||||
chkDisableAll = new FCheckBox("Disable All Auto Yields", humanController.getDisableAutoYields());
|
||||
chkDisableAll.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
game.setDisableAutoYields(chkDisableAll.isSelected());
|
||||
humanController.setDisableAutoYields(chkDisableAll.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ public class VAutoYields extends FDialog {
|
||||
if (selected != null) {
|
||||
autoYields.remove(selected);
|
||||
btnRemove.setEnabled(autoYields.size() > 0);
|
||||
game.setShouldAutoYield(selected, false);
|
||||
humanController.setShouldAutoYield(selected, false);
|
||||
VAutoYields.this.revalidate();
|
||||
lstAutoYields.repaint();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.match;
|
||||
|
||||
import forge.game.GameView;
|
||||
import forge.gui.framework.*;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.properties.ForgePreferences;
|
||||
@@ -8,7 +9,6 @@ import forge.sound.MusicPlaylist;
|
||||
import forge.sound.SoundSystem;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.view.FView;
|
||||
import forge.view.IGameView;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.List;
|
||||
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
|
||||
*/
|
||||
public enum VMatchUI implements IVTopLevelUI {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private List<VCommand> lstCommands = new ArrayList<VCommand>();
|
||||
@@ -45,12 +44,10 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
for (int i = 0; i < 8; i++) EDocID.Hands[i].setDoc(new VEmptyDoc(EDocID.Hands[i]));
|
||||
}
|
||||
|
||||
/** */
|
||||
@Override
|
||||
public void instantiate() {
|
||||
}
|
||||
|
||||
/** */
|
||||
@Override
|
||||
public void populate() {
|
||||
// Dev mode disabled? Remove from parent cell if exists.
|
||||
@@ -95,23 +92,12 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
}
|
||||
}
|
||||
|
||||
if (MatchUtil.getGameView().isCommandZoneNeeded()) {
|
||||
// Add extra players alternatively to existing user/AI field panels.
|
||||
for (int i = 2; i < lstCommands.size(); i++) {
|
||||
// If already in layout, no need to add again.
|
||||
VCommand cmdView = lstCommands.get(i);
|
||||
if (cmdView.getParentCell() == null) {
|
||||
lstCommands.get(i % 2).getParentCell().addDoc(cmdView);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//If game goesn't need command zone, remove it from existing field panels
|
||||
for (int i = 0; i < 2; i++) {
|
||||
VCommand cmdView = lstCommands.get(i);
|
||||
if (cmdView.getParentCell() != null) {
|
||||
cmdView.getParentCell().removeDoc(cmdView);
|
||||
}
|
||||
// Add extra players alternatively to existing user/AI field panels.
|
||||
for (int i = 2; i < lstCommands.size(); i++) {
|
||||
// If already in layout, no need to add again.
|
||||
VCommand cmdView = lstCommands.get(i);
|
||||
if (cmdView.getParentCell() == null) {
|
||||
lstCommands.get(i % 2).getParentCell().addDoc(cmdView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,24 +133,18 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
});
|
||||
}
|
||||
|
||||
//========== Retrieval methods
|
||||
|
||||
/** @return {@link forge.screens.match.CMatchUI} */
|
||||
public CMatchUI getControl() {
|
||||
return this.control;
|
||||
}
|
||||
|
||||
/** @param lst0 List<VField> */
|
||||
public void setFieldViews(final List<VField> lst0) {
|
||||
this.lstFields = lst0;
|
||||
}
|
||||
|
||||
/** @return {@link java.util.List}<{@link forge.screens.match.views.VHand}> */
|
||||
public List<VField> getFieldViews() {
|
||||
return lstFields;
|
||||
}
|
||||
|
||||
/** @param lst0 List<VField> */
|
||||
public void setHandViews(final List<VHand> lst0) {
|
||||
this.lstHands = lst0;
|
||||
}
|
||||
@@ -177,16 +157,10 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
return VPrompt.SINGLETON_INSTANCE.getBtnOK();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lstCommands
|
||||
*/
|
||||
public List<VCommand> getCommandViews() {
|
||||
return lstCommands;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lstCommands0 the lstCommands to set
|
||||
*/
|
||||
public void setCommandViews(List<VCommand> lstCommands0) {
|
||||
this.lstCommands = lstCommands0;
|
||||
}
|
||||
@@ -195,20 +169,14 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
return lstHands;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.IVTopLevelUI#onSwitching(forge.gui.framework.FScreen)
|
||||
*/
|
||||
@Override
|
||||
public boolean onSwitching(FScreen fromScreen, FScreen toScreen) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.IVTopLevelUI#onClosing(forge.control.FControl.Screens)
|
||||
*/
|
||||
@Override
|
||||
public boolean onClosing(FScreen screen) {
|
||||
final IGameView gameView = MatchUtil.getGameView();
|
||||
final GameView gameView = MatchUtil.getGameView();
|
||||
if (gameView != null && !gameView.isGameOver()) {
|
||||
MatchUtil.concede();
|
||||
return false; //delay hiding tab even if concede successful
|
||||
|
||||
@@ -18,6 +18,7 @@ import forge.LobbyPlayer;
|
||||
import forge.UiCommand;
|
||||
import forge.game.GameLogEntry;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.GameView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.interfaces.IWinLoseView;
|
||||
import forge.model.FModel;
|
||||
@@ -29,7 +30,6 @@ import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.toolbox.FTextArea;
|
||||
import forge.view.IGameView;
|
||||
|
||||
public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
private final FButton btnContinue, btnRestart, btnQuit;
|
||||
@@ -39,10 +39,10 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
private final SkinnedLabel lblStats = new SkinnedLabel("WinLoseFrame > lblStats needs updating.");
|
||||
private final JPanel pnlOutcomes = new JPanel(new MigLayout("wrap, align center"));
|
||||
|
||||
private final IGameView game;
|
||||
private final GameView game;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public ViewWinLose(final IGameView game0) {
|
||||
public ViewWinLose(final GameView game0) {
|
||||
|
||||
this.game = game0;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
|
||||
// Assemble game log scroller.
|
||||
final FTextArea txtLog = new FTextArea();
|
||||
txtLog.setText(StringUtils.join(game.getLogEntries(null), "\r\n").replace("[COMPUTER]", "[AI]"));
|
||||
txtLog.setText(StringUtils.join(game.getGameLog().getLogEntries(null), "\r\n").replace("[COMPUTER]", "[AI]"));
|
||||
txtLog.setFont(FSkin.getFont(14));
|
||||
txtLog.setFocusable(true); // allow highlighting and copying of log
|
||||
|
||||
@@ -187,7 +187,7 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
|
||||
}
|
||||
|
||||
private String composeTitle(final IGameView game) {
|
||||
private String composeTitle(final GameView game) {
|
||||
final LobbyPlayer winner = game.getWinningPlayer();
|
||||
final int winningTeam = game.getWinningTeam();
|
||||
if (winner == null) {
|
||||
@@ -220,12 +220,12 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
}
|
||||
|
||||
private void showGameOutcomeSummary() {
|
||||
for (final GameLogEntry o : game.getLogEntriesExact(GameLogEntryType.GAME_OUTCOME))
|
||||
for (final GameLogEntry o : game.getGameLog().getLogEntriesExact(GameLogEntryType.GAME_OUTCOME))
|
||||
pnlOutcomes.add(new FLabel.Builder().text(o.message).fontSize(14).build(), "h 20!");
|
||||
}
|
||||
|
||||
private void showPlayerScores() {
|
||||
for (final GameLogEntry o : game.getLogEntriesExact(GameLogEntryType.MATCH_RESULTS)) {
|
||||
for (final GameLogEntry o : game.getGameLog().getLogEntriesExact(GameLogEntryType.MATCH_RESULTS)) {
|
||||
lblStats.setText(removePlayerTypeFromLogMessage(o.message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.match.MatchConstants;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Receives click and programmatic requests for viewing data stacks in the
|
||||
|
||||
@@ -5,14 +5,14 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.game.combat.CombatView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.views.VCombat;
|
||||
import forge.util.Lang;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Controls the combat panel in the match UI.
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.views.VCommand;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Controls Swing components of a player's command instance.
|
||||
|
||||
@@ -20,14 +20,13 @@ package forge.screens.match.controllers;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.screens.match.views.VDetail;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Controls the card detail area in the match UI.
|
||||
@@ -58,7 +57,7 @@ public enum CDetail implements ICDoc {
|
||||
|
||||
public void showCard(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
showCard(ViewUtil.getCardForUi((IPaperCard)item));
|
||||
showCard(CardView.getCardForUi((IPaperCard)item));
|
||||
} else if (item instanceof InventoryItemFromSet) {
|
||||
view.getLblFlipcard().setVisible(false);
|
||||
view.getPnlDetail().setItem((InventoryItemFromSet)item);
|
||||
|
||||
@@ -27,7 +27,7 @@ public enum CDev implements ICDoc {
|
||||
public void togglePlayManyLandsPerTurn() {
|
||||
boolean newValue = !VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().getToggled();
|
||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(newValue);
|
||||
MatchUtil.getGameView().cheat().setCanPlayUnlimitedLands(newValue);
|
||||
MatchUtil.getHumanController().cheat().setCanPlayUnlimitedLands(newValue);
|
||||
}
|
||||
|
||||
private final MouseListener madViewAll = new MouseAdapter() {
|
||||
@@ -39,7 +39,7 @@ public enum CDev implements ICDoc {
|
||||
public void toggleViewAllCards() {
|
||||
boolean newValue = !VDev.SINGLETON_INSTANCE.getLblViewAll().getToggled();
|
||||
VDev.SINGLETON_INSTANCE.getLblViewAll().setToggled(newValue);
|
||||
MatchUtil.getGameView().cheat().setViewAllCards(newValue);
|
||||
MatchUtil.getHumanController().cheat().setViewAllCards(newValue);
|
||||
}
|
||||
|
||||
private final MouseListener madMana = new MouseAdapter() {
|
||||
@@ -49,7 +49,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void generateMana() {
|
||||
MatchUtil.getGameView().cheat().generateMana();
|
||||
MatchUtil.getHumanController().cheat().generateMana();
|
||||
}
|
||||
|
||||
private final MouseListener madSetup = new MouseAdapter() {
|
||||
@@ -59,7 +59,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void setupGameState() {
|
||||
MatchUtil.getGameView().cheat().setupGameState();
|
||||
MatchUtil.getHumanController().cheat().setupGameState();
|
||||
}
|
||||
|
||||
private final MouseListener madTutor = new MouseAdapter() {
|
||||
@@ -69,7 +69,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void tutorForCard() {
|
||||
MatchUtil.getGameView().cheat().tutorForCard();
|
||||
MatchUtil.getHumanController().cheat().tutorForCard();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToHand = new MouseAdapter() {
|
||||
@@ -79,7 +79,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void addCardToHand() {
|
||||
MatchUtil.getGameView().cheat().addCardToHand();
|
||||
MatchUtil.getHumanController().cheat().addCardToHand();
|
||||
}
|
||||
|
||||
private final MouseListener madCounter = new MouseAdapter() {
|
||||
@@ -89,7 +89,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void addCounterToPermanent() {
|
||||
MatchUtil.getGameView().cheat().addCountersToPermanent();
|
||||
MatchUtil.getHumanController().cheat().addCountersToPermanent();
|
||||
}
|
||||
|
||||
private final MouseListener madTap = new MouseAdapter() {
|
||||
@@ -99,7 +99,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void tapPermanent() {
|
||||
MatchUtil.getGameView().cheat().tapPermanents();
|
||||
MatchUtil.getHumanController().cheat().tapPermanents();
|
||||
}
|
||||
|
||||
private final MouseListener madUntap = new MouseAdapter() {
|
||||
@@ -109,7 +109,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void untapPermanent() {
|
||||
MatchUtil.getGameView().cheat().untapPermanents();
|
||||
MatchUtil.getHumanController().cheat().untapPermanents();
|
||||
}
|
||||
|
||||
private final MouseListener madLife = new MouseAdapter() {
|
||||
@@ -119,7 +119,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void setPlayerLife() {
|
||||
MatchUtil.getGameView().cheat().setPlayerLife();
|
||||
MatchUtil.getHumanController().cheat().setPlayerLife();
|
||||
}
|
||||
|
||||
private final MouseListener madWinGame = new MouseAdapter() {
|
||||
@@ -129,7 +129,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void winGame() {
|
||||
MatchUtil.getGameView().cheat().winGame();
|
||||
MatchUtil.getHumanController().cheat().winGame();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToBattlefield = new MouseAdapter() {
|
||||
@@ -139,7 +139,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void addCardToBattlefield() {
|
||||
MatchUtil.getGameView().cheat().addCardToBattlefield();
|
||||
MatchUtil.getHumanController().cheat().addCardToBattlefield();
|
||||
}
|
||||
|
||||
private final MouseListener madRiggedRoll = new MouseAdapter() {
|
||||
@@ -149,7 +149,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void riggedPlanerRoll() {
|
||||
MatchUtil.getGameView().cheat().riggedPlanarRoll();
|
||||
MatchUtil.getHumanController().cheat().riggedPlanarRoll();
|
||||
}
|
||||
|
||||
private final MouseListener madWalkToPlane = new MouseAdapter() {
|
||||
@@ -159,7 +159,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void planeswalkTo() {
|
||||
MatchUtil.getGameView().cheat().planeswalkTo();
|
||||
MatchUtil.getHumanController().cheat().planeswalkTo();
|
||||
}
|
||||
|
||||
//========== End mouse listener inits
|
||||
@@ -198,7 +198,7 @@ public enum CDev implements ICDoc {
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(MatchUtil.getGameView().canPlayUnlimitedLands());
|
||||
VDev.SINGLETON_INSTANCE.getLblViewAll().setToggled(MatchUtil.getGameView().canViewAllCards());
|
||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(MatchUtil.getHumanController().canPlayUnlimitedLands());
|
||||
VDev.SINGLETON_INSTANCE.getLblViewAll().setToggled(MatchUtil.getHumanController().mayLookAtAllCards());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public enum CDock implements ICDoc {
|
||||
VDock.SINGLETON_INSTANCE.getBtnAlphaStrike().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().alphaStrike();
|
||||
MatchUtil.getHumanController().alphaStrike();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().setCommand(new UiCommand() {
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.google.common.base.Function;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchConstants;
|
||||
@@ -32,8 +34,6 @@ import forge.match.MatchUtil;
|
||||
import forge.screens.match.ZoneAction;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Controls Swing components of a player's field instance.
|
||||
@@ -79,21 +79,20 @@ public class CField implements ICDoc {
|
||||
}
|
||||
@Override
|
||||
protected Iterable<CardView> getCardsAsIterable() {
|
||||
return player.getFlashbackCards();
|
||||
return player.getFlashback();
|
||||
}
|
||||
};
|
||||
|
||||
Function<Byte, Void> manaAction = new Function<Byte, Void>() {
|
||||
public Void apply(Byte colorCode) {
|
||||
if (CField.this.player.getLobbyPlayer() == Singletons.getControl().getGuiPlayer()) {
|
||||
MatchUtil.getGameView().useMana(colorCode.byteValue());
|
||||
MatchUtil.getHumanController().useMana(colorCode.byteValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
view.getDetailsPanel().setupMouseActions(handAction, libraryAction, exileAction, graveAction, flashBackAction, manaAction);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,12 +33,12 @@ import com.google.common.collect.Lists;
|
||||
import forge.FThreads;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.screens.match.views.VHand;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
import forge.view.arcane.HandArea;
|
||||
import forge.view.arcane.util.Animation;
|
||||
@@ -46,7 +46,6 @@ import forge.view.arcane.util.CardPanelMouseAdapter;
|
||||
|
||||
/**
|
||||
* Controls Swing components of a player's hand instance.
|
||||
*
|
||||
*/
|
||||
public class CHand implements ICDoc {
|
||||
private final PlayerView player;
|
||||
@@ -108,7 +107,7 @@ public class CHand implements ICDoc {
|
||||
|
||||
final List<CardView> cards;
|
||||
synchronized (player) {
|
||||
cards = ImmutableList.copyOf(player.getHandCards());
|
||||
cards = ImmutableList.copyOf(player.getHand());
|
||||
}
|
||||
|
||||
synchronized (ordering) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import javax.swing.JLabel;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.IPaperCard;
|
||||
@@ -32,8 +33,6 @@ import forge.item.InventoryItem;
|
||||
import forge.screens.match.views.VPicture;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Singleton controller for VPicture.
|
||||
@@ -83,18 +82,20 @@ public enum CPicture implements ICDoc {
|
||||
public void showImage(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
final IPaperCard paperCard = ((IPaperCard)item);
|
||||
final CardView c = ViewUtil.getCardForUi(paperCard);
|
||||
final CardView c = CardView.getCardForUi(paperCard);
|
||||
if (paperCard.isFoil() && c.getOriginal().getFoilIndex() == 0) {
|
||||
// FIXME should assign a random foil here in all cases
|
||||
// (currently assigns 1 for the deck editors where foils "flicker" otherwise)
|
||||
if (item instanceof Card) {
|
||||
c.getOriginal().setRandomFoil();
|
||||
} else if (item instanceof IPaperCard) {
|
||||
c.getOriginal().setFoilIndex(1);
|
||||
c.getOriginal().setFoilIndexOverride(-1); //-1 to choose random
|
||||
}
|
||||
else if (item instanceof IPaperCard) {
|
||||
c.getOriginal().setFoilIndexOverride(1);
|
||||
}
|
||||
}
|
||||
showCard(c, false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
currentView = null;
|
||||
isDisplayAlt = false;
|
||||
flipIndicator.setVisible(false);
|
||||
@@ -177,5 +178,4 @@ public enum CPicture implements ICDoc {
|
||||
CDetail.SINGLETON_INSTANCE.showCard(currentView, isDisplayAlt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,16 +28,16 @@ import javax.swing.JButton;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.UiCommand;
|
||||
import forge.game.GameView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.views.VPrompt;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.SpellAbilityView;
|
||||
|
||||
/**
|
||||
* Controls the prompt panel in the match UI.
|
||||
@@ -45,7 +45,6 @@ import forge.view.SpellAbilityView;
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*/
|
||||
public enum CPrompt implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private Component lastFocusedButton = null;
|
||||
@@ -89,34 +88,33 @@ public enum CPrompt implements ICDoc {
|
||||
}
|
||||
|
||||
public void selectButtonOk() {
|
||||
MatchUtil.getGameView().selectButtonOk();
|
||||
MatchUtil.getHumanController().selectButtonOk();
|
||||
}
|
||||
|
||||
public void selectButtonCancel() {
|
||||
MatchUtil.getGameView().selectButtonCancel();
|
||||
MatchUtil.getHumanController().selectButtonCancel();
|
||||
}
|
||||
|
||||
public boolean passPriority() {
|
||||
return MatchUtil.getGameView().passPriority();
|
||||
return MatchUtil.getHumanController().passPriority();
|
||||
}
|
||||
|
||||
public boolean passPriorityUntilEndOfTurn() {
|
||||
return MatchUtil.getGameView().passPriorityUntilEndOfTurn();
|
||||
return MatchUtil.getHumanController().passPriorityUntilEndOfTurn();
|
||||
}
|
||||
|
||||
public void selectPlayer(final PlayerView player, final ITriggerEvent triggerEvent) {
|
||||
MatchUtil.getGameView().selectPlayer(player, triggerEvent);
|
||||
MatchUtil.getHumanController().selectPlayer(player, triggerEvent);
|
||||
}
|
||||
|
||||
public void selectCard(final CardView card, final ITriggerEvent triggerEvent) {
|
||||
MatchUtil.getGameView().selectCard(card, triggerEvent);
|
||||
MatchUtil.getHumanController().selectCard(card, triggerEvent);
|
||||
}
|
||||
|
||||
public void selectAbility(final SpellAbilityView sa) {
|
||||
MatchUtil.getGameView().selectAbility(sa);
|
||||
public void selectAbility(final SpellAbility sa) {
|
||||
MatchUtil.getHumanController().selectAbility(sa);
|
||||
}
|
||||
|
||||
/** @param s0   {@link java.lang.String} */
|
||||
public void setMessage(String s0) {
|
||||
view.getTarMessage().setText(FSkin.encodeSymbols(s0, false));
|
||||
}
|
||||
@@ -126,17 +124,11 @@ public enum CPrompt implements ICDoc {
|
||||
SDisplayUtil.remind(view);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
*/
|
||||
@Override
|
||||
public UiCommand getCommandOnSelect() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
// set focus back to button that last had it
|
||||
@@ -147,9 +139,9 @@ public enum CPrompt implements ICDoc {
|
||||
|
||||
public void updateText() {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
final IGameView game = MatchUtil.getGameView();
|
||||
final String text = String.format("T:%d G:%d/%d [%s]", game.getTurnNumber(), game.getNumPlayedGamesInMatch() + 1, game.getNumGamesInMatch(), game.getGameType());
|
||||
final GameView game = MatchUtil.getGameView();
|
||||
final String text = String.format("T:%d G:%d/%d [%s]", game.getTurn(), game.getNumPlayedGamesInMatch() + 1, game.getNumGamesInMatch(), game.getGameType());
|
||||
view.getLblGames().setText(text);
|
||||
view.getLblGames().setToolTipText(String.format("%s: Game #%d of %d, turn %d", game.getGameType(), game.getNumPlayedGamesInMatch() + 1, game.getNumGamesInMatch(), game.getTurnNumber()));
|
||||
view.getLblGames().setToolTipText(String.format("%s: Game #%d of %d, turn %d", game.getGameType(), game.getNumPlayedGamesInMatch() + 1, game.getNumGamesInMatch(), game.getTurn()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ public class DevModeMenu implements ActionListener {
|
||||
menu.add(getMenuItem(DevMenuItem.WIN_GAME));
|
||||
menu.addSeparator();
|
||||
menu.add(getMenuItem(DevMenuItem.SETUP_GAME_STATE));
|
||||
menu.add(getCheckboxMenuItem(DevMenuItem.PLAY_UNLIMITED_LANDS, MatchUtil.getGameView().canPlayUnlimitedLands()));
|
||||
menu.add(getCheckboxMenuItem(DevMenuItem.VIEW_ALL, MatchUtil.getGameView().canViewAllCards()));
|
||||
menu.add(getCheckboxMenuItem(DevMenuItem.PLAY_UNLIMITED_LANDS, MatchUtil.getHumanController().canPlayUnlimitedLands()));
|
||||
menu.add(getCheckboxMenuItem(DevMenuItem.VIEW_ALL, MatchUtil.getHumanController().mayLookAtAllCards()));
|
||||
menu.add(getMenuItem(DevMenuItem.ADD_COUNTER));
|
||||
menu.addSeparator();
|
||||
menu.add(getMenuItem(DevMenuItem.TAP_PERMANENT));
|
||||
|
||||
@@ -83,7 +83,7 @@ public final class GameMenu {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MatchUtil.getGameView().tryUndoLastAction();
|
||||
MatchUtil.getHumanController().tryUndoLastAction();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public final class GameMenu {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final VAutoYields autoYields = new VAutoYields(MatchUtil.getGameView());
|
||||
final VAutoYields autoYields = new VAutoYields(MatchUtil.getHumanController());
|
||||
autoYields.showAutoYields();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,6 +25,8 @@ import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.gui.WrapLayout;
|
||||
import forge.gui.framework.DragCell;
|
||||
@@ -35,8 +37,6 @@ import forge.match.MatchUtil;
|
||||
import forge.screens.match.controllers.CAntes;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of card ante area.
|
||||
@@ -121,15 +121,15 @@ public enum VAntes implements IVDoc<CAntes> {
|
||||
pnl.removeAll();
|
||||
|
||||
for (final PlayerView p : MatchUtil.getGameView().getPlayers()) {
|
||||
for (final CardView c : p.getAnteCards()) {
|
||||
final AntePanel pnlTemp = new AntePanel(c);
|
||||
allAntes.add(pnlTemp);
|
||||
Iterable<CardView> ante = p.getAnte();
|
||||
if (ante != null) {
|
||||
for (final CardView c : ante) {
|
||||
final AntePanel pnlTemp = new AntePanel(c);
|
||||
allAntes.add(pnlTemp);
|
||||
pnl.add(pnlTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(AntePanel ap : allAntes) {
|
||||
pnl.add(ap);
|
||||
}
|
||||
}
|
||||
|
||||
//========= Private class handling
|
||||
|
||||
@@ -20,6 +20,7 @@ package forge.screens.match.views;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
@@ -28,7 +29,6 @@ import forge.gui.framework.IVDoc;
|
||||
import forge.screens.match.controllers.CCommand;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.PlayArea;
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ import javax.swing.border.Border;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
@@ -41,7 +42,6 @@ import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.toolbox.special.PhaseIndicator;
|
||||
import forge.toolbox.special.PlayerDetailsPanel;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.PlayArea;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,13 +20,13 @@ package forge.screens.match.views;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.screens.match.controllers.CHand;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.HandArea;
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.GameLogEntry;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.GameView;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -38,8 +39,6 @@ import forge.screens.match.GameLogPanel;
|
||||
import forge.screens.match.controllers.CLog;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinFont;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.LocalGameView;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of game log report.
|
||||
@@ -55,7 +54,7 @@ public enum VLog implements IVDoc<CLog> {
|
||||
private final List<GameLogEntry> displayedLogEntries = Lists.newArrayList();
|
||||
|
||||
// Used to determine when a new game has started.
|
||||
private IGameView gameLogModel = null;
|
||||
private GameView gameLogModel = null;
|
||||
|
||||
// Fields used with interface IVDoc
|
||||
private DragCell parentCell;
|
||||
@@ -128,7 +127,7 @@ public enum VLog implements IVDoc<CLog> {
|
||||
*/
|
||||
public void updateConsole() {
|
||||
if (isGameLogConsoleVisible()) {
|
||||
LocalGameView model = MatchUtil.getGameView();
|
||||
GameView model = MatchUtil.getGameView();
|
||||
resetDisplayIfNewGame(model);
|
||||
displayNewGameLogEntries(model);
|
||||
// Important : refreshLayout() needs to be called every update.
|
||||
@@ -140,7 +139,7 @@ public enum VLog implements IVDoc<CLog> {
|
||||
return parentCell.getSelected().equals(this);
|
||||
}
|
||||
|
||||
private void resetDisplayIfNewGame(final IGameView model) {
|
||||
private void resetDisplayIfNewGame(final GameView model) {
|
||||
if (this.gameLogModel != model) {
|
||||
gameLog.reset();
|
||||
this.displayedLogEntries.clear();
|
||||
@@ -167,17 +166,17 @@ public enum VLog implements IVDoc<CLog> {
|
||||
p.add(gameLog, "w 10:100%, h 100%");
|
||||
}
|
||||
|
||||
private void displayNewGameLogEntries(final IGameView model) {
|
||||
private void displayNewGameLogEntries(final GameView model) {
|
||||
List<GameLogEntry> newLogEntries = Lists.reverse(getNewGameLogEntries(model));
|
||||
if (newLogEntries.size() > 0) {
|
||||
addNewLogEntriesToJPanel(newLogEntries);
|
||||
}
|
||||
}
|
||||
|
||||
private List<GameLogEntry> getNewGameLogEntries(final IGameView model) {
|
||||
private List<GameLogEntry> getNewGameLogEntries(final GameView model) {
|
||||
String logEntryType = FModel.getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE);
|
||||
GameLogEntryType logVerbosityFilter = GameLogEntryType.valueOf(logEntryType);
|
||||
List<GameLogEntry> logEntries = model.getLogEntries(logVerbosityFilter);
|
||||
List<GameLogEntry> logEntries = model.getGameLog().getLogEntries(logVerbosityFilter);
|
||||
// Set subtraction - remove all log entries from new list which are already displayed.
|
||||
logEntries.removeAll(this.displayedLogEntries);
|
||||
return logEntries;
|
||||
|
||||
@@ -28,6 +28,8 @@ import javax.swing.ScrollPaneConstants;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -39,8 +41,6 @@ import forge.screens.match.controllers.CPlayers;
|
||||
import forge.toolbox.FScrollPanel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of players report.
|
||||
@@ -165,14 +165,16 @@ public enum VPlayers implements IVDoc<CPlayers> {
|
||||
temp[5].setText("");
|
||||
}
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
||||
final List<CardView> list = p0.getAnteCards();
|
||||
final Iterable<CardView> list = p0.getAnte();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Ante'd: ");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
sb.append(list.get(i));
|
||||
if (i < (list.size() - 1)) {
|
||||
boolean needDelim = false;
|
||||
for (CardView cv : list) {
|
||||
if (needDelim) {
|
||||
sb.append(", ");
|
||||
}
|
||||
else { needDelim = true; }
|
||||
sb.append(cv);
|
||||
}
|
||||
temp[6].setText(sb.toString());
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
@@ -38,11 +36,16 @@ import net.miginfocom.swing.MigLayout;
|
||||
import forge.ImageCache;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.game.GameView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.StackItemView;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.controllers.CPrompt;
|
||||
import forge.screens.match.controllers.CStack;
|
||||
@@ -50,11 +53,7 @@ import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.FScrollPanel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedTextArea;
|
||||
import forge.view.CardView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.LocalGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.StackItemView;
|
||||
import forge.util.FCollection;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
@@ -63,7 +62,6 @@ import forge.view.arcane.CardPanel;
|
||||
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
|
||||
*/
|
||||
public enum VStack implements IVDoc<CStack> {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
// Fields used with interface IVDoc
|
||||
@@ -80,65 +78,40 @@ public enum VStack implements IVDoc<CStack> {
|
||||
private VStack() {
|
||||
}
|
||||
|
||||
//========= Overridden methods
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.IVDoc#populate()
|
||||
*/
|
||||
@Override
|
||||
public void populate() {
|
||||
parentCell.getBody().setLayout(new MigLayout("insets 3px, gap 0"));
|
||||
parentCell.getBody().add(scroller, "grow, push");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.IVDoc#setParentCell()
|
||||
*/
|
||||
@Override
|
||||
public void setParentCell(final DragCell cell0) {
|
||||
this.parentCell = cell0;
|
||||
parentCell = cell0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.IVDoc#getParentCell()
|
||||
*/
|
||||
@Override
|
||||
public DragCell getParentCell() {
|
||||
return this.parentCell;
|
||||
return parentCell;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.IVDoc#getDocumentID()
|
||||
*/
|
||||
@Override
|
||||
public EDocID getDocumentID() {
|
||||
return EDocID.REPORT_STACK;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.IVDoc#getTabLabel()
|
||||
*/
|
||||
@Override
|
||||
public DragTab getTabLabel() {
|
||||
return tab;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.IVDoc#getLayoutControl()
|
||||
*/
|
||||
@Override
|
||||
public CStack getLayoutControl() {
|
||||
return CStack.SINGLETON_INSTANCE;
|
||||
}
|
||||
|
||||
//========== Observer update methods
|
||||
|
||||
/**
|
||||
* @param models
|
||||
* @param viewer */
|
||||
public void updateStack() {
|
||||
final LocalGameView model = MatchUtil.getGameView();
|
||||
final List<StackItemView> items = model.getStack();
|
||||
final GameView model = MatchUtil.getGameView();
|
||||
final FCollection<StackItemView>.FCollectionView items = model.getStack();
|
||||
tab.setText("Stack : " + items.size());
|
||||
|
||||
// No need to update the rest unless it's showing
|
||||
@@ -155,7 +128,7 @@ public enum VStack implements IVDoc<CStack> {
|
||||
//update the Card Picture/Detail when the spell is added to the stack
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(item.getSource());
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(item.getSourceCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,10 +151,10 @@ public enum VStack implements IVDoc<CStack> {
|
||||
|
||||
private final CardView sourceCard;
|
||||
|
||||
public StackInstanceTextArea(final LocalGameView gameView, final StackItemView item) {
|
||||
sourceCard = item.getSource();
|
||||
public StackInstanceTextArea(final GameView gameView, final StackItemView item) {
|
||||
sourceCard = item.getSourceCard();
|
||||
|
||||
final PlayerView localPlayer = gameView.getPlayerView(MatchUtil.getCurrentPlayer(), false);
|
||||
final PlayerView localPlayer = PlayerView.get(MatchUtil.getCurrentPlayer());
|
||||
final String txt = (item.isOptionalTrigger() && item.getActivatingPlayer().equals(localPlayer)
|
||||
? "(OPTIONAL) " : "") + item.getText();
|
||||
|
||||
@@ -200,7 +173,7 @@ public enum VStack implements IVDoc<CStack> {
|
||||
@Override
|
||||
public void mouseEntered(final MouseEvent e) {
|
||||
if (!txt.startsWith("Morph ")) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(item.getSource());
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(item.getSourceCard());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -216,13 +189,13 @@ public enum VStack implements IVDoc<CStack> {
|
||||
onClick(e);
|
||||
}
|
||||
private void onClick(MouseEvent e) {
|
||||
abilityMenu.setStackInstance(gameView, item, localPlayer);
|
||||
abilityMenu.setStackInstance(MatchUtil.getHumanController(), item, localPlayer);
|
||||
abilityMenu.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final DetailColors color = CardDetailUtil.getBorderColor(item.getSource().getOriginal());
|
||||
final DetailColors color = CardDetailUtil.getBorderColor(item.getSourceCard().getOriginal());
|
||||
setBackground(new Color(color.r, color.g, color.b));
|
||||
setForeground(FSkin.getHighContrastColor(getBackground()));
|
||||
}
|
||||
@@ -248,7 +221,7 @@ public enum VStack implements IVDoc<CStack> {
|
||||
private final JCheckBoxMenuItem jmiAutoYield;
|
||||
private final JCheckBoxMenuItem jmiAlwaysYes;
|
||||
private final JCheckBoxMenuItem jmiAlwaysNo;
|
||||
private IGameView game;
|
||||
private PlayerControllerHuman humanController;
|
||||
private StackItemView item;
|
||||
|
||||
private Integer triggerID = 0;
|
||||
@@ -259,9 +232,9 @@ public enum VStack implements IVDoc<CStack> {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
final String key = item.getKey();
|
||||
final boolean autoYield = game.shouldAutoYield(key);
|
||||
game.setShouldAutoYield(key, !autoYield);
|
||||
if (!autoYield && game.peekStack() == item) {
|
||||
final boolean autoYield = humanController.shouldAutoYield(key);
|
||||
humanController.setShouldAutoYield(key, !autoYield);
|
||||
if (!autoYield && MatchUtil.getGameView().peekStack() == item) {
|
||||
//auto-pass priority if ability is on top of stack
|
||||
CPrompt.SINGLETON_INSTANCE.passPriority();
|
||||
}
|
||||
@@ -273,14 +246,14 @@ public enum VStack implements IVDoc<CStack> {
|
||||
jmiAlwaysYes.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (game.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
game.setShouldAlwaysAskTrigger(triggerID);
|
||||
if (humanController.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
humanController.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
game.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (game.peekStack() == item) {
|
||||
humanController.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (MatchUtil.getGameView().peekStack() == item) {
|
||||
//auto-yes if ability is on top of stack
|
||||
game.confirm();
|
||||
humanController.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,14 +264,14 @@ public enum VStack implements IVDoc<CStack> {
|
||||
jmiAlwaysNo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (game.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
game.setShouldAlwaysAskTrigger(triggerID);
|
||||
if (humanController.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
humanController.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
game.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (game.peekStack() == item) {
|
||||
humanController.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (MatchUtil.getGameView().peekStack() == item) {
|
||||
//auto-no if ability is on top of stack
|
||||
game.confirm();
|
||||
humanController.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,16 +279,16 @@ public enum VStack implements IVDoc<CStack> {
|
||||
add(jmiAlwaysNo);
|
||||
}
|
||||
|
||||
public void setStackInstance(final IGameView game, final StackItemView item, final PlayerView localPlayer) {
|
||||
this.game = game;
|
||||
this.item = item;
|
||||
public void setStackInstance(final PlayerControllerHuman humanController0, final StackItemView item0, final PlayerView localPlayer0) {
|
||||
humanController = humanController0;
|
||||
item = item0;
|
||||
triggerID = Integer.valueOf(item.getSourceTrigger());
|
||||
|
||||
jmiAutoYield.setSelected(game.shouldAutoYield(item.getKey()));
|
||||
jmiAutoYield.setSelected(humanController.shouldAutoYield(item.getKey()));
|
||||
|
||||
if (item.isOptionalTrigger() && item.getActivatingPlayer().equals(localPlayer)) {
|
||||
jmiAlwaysYes.setSelected(game.shouldAlwaysAcceptTrigger(triggerID));
|
||||
jmiAlwaysNo.setSelected(game.shouldAlwaysDeclineTrigger(triggerID));
|
||||
if (item.isOptionalTrigger() && item.getActivatingPlayer().equals(localPlayer0)) {
|
||||
jmiAlwaysYes.setSelected(humanController.shouldAlwaysAcceptTrigger(triggerID));
|
||||
jmiAlwaysNo.setSelected(humanController.shouldAlwaysDeclineTrigger(triggerID));
|
||||
jmiAlwaysYes.setVisible(true);
|
||||
jmiAlwaysNo.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.toolbox.CardFaceSymbols;
|
||||
import forge.toolbox.FSkin.SkinIcon;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
/**
|
||||
* Common image-related routines specific to Forge images.
|
||||
|
||||
@@ -26,11 +26,11 @@ import javax.swing.JPanel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.item.PaperCard;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple JPanel that shows three columns: card list, pic, and description..
|
||||
@@ -40,7 +40,6 @@ import forge.view.ViewUtil;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class CardViewer extends JPanel {
|
||||
|
||||
// Data and number of choices for the list
|
||||
private final List<PaperCard> list;
|
||||
|
||||
@@ -49,12 +48,6 @@ public class CardViewer extends JPanel {
|
||||
private final CardDetailPanel detail;
|
||||
private final CardPicturePanel picture;
|
||||
|
||||
/**
|
||||
* Instantiates a new card viewer.
|
||||
*
|
||||
* @param list
|
||||
* the list
|
||||
*/
|
||||
public CardViewer(final List<PaperCard> list) {
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
this.jList = new JList<PaperCard>(new ChooserListModel());
|
||||
@@ -72,7 +65,6 @@ public class CardViewer extends JPanel {
|
||||
}
|
||||
|
||||
private class ChooserListModel extends AbstractListModel<PaperCard> {
|
||||
|
||||
private static final long serialVersionUID = 3871965346333840556L;
|
||||
|
||||
@Override
|
||||
@@ -93,11 +85,9 @@ public class CardViewer extends JPanel {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < CardViewer.this.list.size())) {
|
||||
final PaperCard cp = CardViewer.this.list.get(row);
|
||||
CardViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
CardViewer.this.detail.setCard(CardView.getCardForUi(cp));
|
||||
CardViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ import javax.swing.Timer;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.toolbox.FSkin;
|
||||
@@ -39,8 +41,6 @@ import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.toolbox.imaging.FImagePanel;
|
||||
import forge.toolbox.imaging.FImagePanel.AutoSizeImageMode;
|
||||
import forge.toolbox.imaging.FImageUtil;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
/**
|
||||
* Displays card image at its original size and correct orientation.
|
||||
@@ -201,7 +201,7 @@ public enum CardZoomer {
|
||||
* Displays a graphical indicator that shows whether the current card can be flipped or transformed.
|
||||
*/
|
||||
private void setFlipIndicator() {
|
||||
if (thisCard.hasAltState()) {
|
||||
if (thisCard.getAlternate() != null) {
|
||||
imagePanel.setLayout(new MigLayout("insets 0, w 100%!, h 100%!"));
|
||||
imagePanel.add(lblFlipcard, "pos (100% - 100px) 0");
|
||||
}
|
||||
@@ -276,7 +276,7 @@ public enum CardZoomer {
|
||||
* Toggles between primary and alternate image associated with card if applicable.
|
||||
*/
|
||||
private void toggleCardImage() {
|
||||
if (thisCard.hasAltState()) {
|
||||
if (thisCard.getAlternate() != null) {
|
||||
toggleFlipCard();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ import com.google.common.base.Function;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.card.MagicColor;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.screens.match.controllers.CPlayers;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class PlayerDetailsPanel extends JPanel {
|
||||
private static final long serialVersionUID = 8444559244193214459L;
|
||||
@@ -119,14 +119,14 @@ public class PlayerDetailsPanel extends JPanel {
|
||||
* @param p0   {@link forge.game.player.Player}
|
||||
*/
|
||||
public void updateZones() {
|
||||
this.getLblHand().setText("" + player.getnHandCards());
|
||||
this.getLblHand().setText("" + player.getHandSize());
|
||||
final String handMaxToolTip = player.hasUnlimitedHandSize()
|
||||
? "no maximum hand size" : String.valueOf(player.getMaxHandSize());
|
||||
this.getLblHand().setToolTipText("Cards in hand (max: " + handMaxToolTip + ")");
|
||||
this.getLblGraveyard().setText("" + player.getGraveCards().size());
|
||||
this.getLblLibrary().setText("" + player.getnLibraryCards());
|
||||
this.getLblFlashback().setText("" + player.getFlashbackCards().size());
|
||||
this.getLblExile().setText("" + player.getExileCards().size());
|
||||
this.getLblGraveyard().setText("" + player.getGraveyardSize());
|
||||
this.getLblLibrary().setText("" + player.getLibrarySize());
|
||||
this.getLblFlashback().setText("" + player.getFlashbackSize());
|
||||
this.getLblExile().setText("" + player.getExileSize());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ import javax.swing.SwingUtilities;
|
||||
import forge.ImageCache;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.gui.CardContainer;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
@@ -44,8 +46,6 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.toolbox.CardFaceSymbols;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.toolbox.IDisposable;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.arcane.util.OutlinedLabel;
|
||||
|
||||
/**
|
||||
@@ -117,21 +117,21 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public CardPanel(final CardView card0) {
|
||||
this.setBackground(Color.black);
|
||||
this.setOpaque(false);
|
||||
setBackground(Color.black);
|
||||
setOpaque(false);
|
||||
|
||||
createCardNameOverlay();
|
||||
createPTOverlay();
|
||||
createCardIdOverlay();
|
||||
createScaleImagePanel();
|
||||
|
||||
this.setCard(card0);
|
||||
setCard(card0);
|
||||
}
|
||||
|
||||
private void createScaleImagePanel() {
|
||||
this.imagePanel = new ScaledImagePanel();
|
||||
this.add(this.imagePanel);
|
||||
this.addComponentListener(new ComponentAdapter() {
|
||||
imagePanel = new ScaledImagePanel();
|
||||
add(imagePanel);
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentShown(final ComponentEvent e) {
|
||||
CardPanel.this.setCard(CardPanel.this.getCard());
|
||||
@@ -144,224 +144,157 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
private void createCardNameOverlay() {
|
||||
this.titleText = new OutlinedLabel();
|
||||
this.titleText.setFont(this.getFont().deriveFont(Font.BOLD, 13f));
|
||||
this.titleText.setForeground(Color.white);
|
||||
this.titleText.setGlow(Color.black);
|
||||
this.titleText.setWrap(true);
|
||||
this.add(this.titleText);
|
||||
titleText = new OutlinedLabel();
|
||||
titleText.setFont(getFont().deriveFont(Font.BOLD, 13f));
|
||||
titleText.setForeground(Color.white);
|
||||
titleText.setGlow(Color.black);
|
||||
titleText.setWrap(true);
|
||||
add(titleText);
|
||||
}
|
||||
|
||||
private void createPTOverlay() {
|
||||
// Power/Toughness
|
||||
this.ptText = new OutlinedLabel();
|
||||
this.ptText.setFont(this.getFont().deriveFont(Font.BOLD, 13f));
|
||||
this.ptText.setForeground(Color.white);
|
||||
this.ptText.setGlow(Color.black);
|
||||
this.add(this.ptText);
|
||||
ptText = new OutlinedLabel();
|
||||
ptText.setFont(getFont().deriveFont(Font.BOLD, 13f));
|
||||
ptText.setForeground(Color.white);
|
||||
ptText.setGlow(Color.black);
|
||||
add(ptText);
|
||||
|
||||
// Damage
|
||||
this.damageText = new OutlinedLabel();
|
||||
this.damageText.setFont(this.getFont().deriveFont(Font.BOLD, 15f));
|
||||
this.damageText.setForeground(new Color(160,0,0));
|
||||
this.damageText.setGlow(Color.white);
|
||||
this.add(this.damageText);
|
||||
damageText = new OutlinedLabel();
|
||||
damageText.setFont(getFont().deriveFont(Font.BOLD, 15f));
|
||||
damageText.setForeground(new Color(160,0,0));
|
||||
damageText.setGlow(Color.white);
|
||||
add(damageText);
|
||||
}
|
||||
|
||||
private void createCardIdOverlay() {
|
||||
this.cardIdText = new OutlinedLabel();
|
||||
this.cardIdText.setFont(this.getFont().deriveFont(Font.BOLD, 11f));
|
||||
this.cardIdText.setForeground(Color.LIGHT_GRAY);
|
||||
this.cardIdText.setGlow(Color.black);
|
||||
this.add(this.cardIdText);
|
||||
cardIdText = new OutlinedLabel();
|
||||
cardIdText.setFont(getFont().deriveFont(Font.BOLD, 11f));
|
||||
cardIdText.setForeground(Color.LIGHT_GRAY);
|
||||
cardIdText.setGlow(Color.black);
|
||||
add(cardIdText);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setImage.
|
||||
* </p>
|
||||
*
|
||||
* @param srcImage
|
||||
* a {@link java.awt.Image} object.
|
||||
* @param srcImageBlurred
|
||||
* a {@link java.awt.Image} object.
|
||||
* @param srcImageBlurred
|
||||
* a {@link java.awt.Image} object.
|
||||
*/
|
||||
private void setImage(final BufferedImage srcImage) {
|
||||
synchronized (this.imagePanel) {
|
||||
this.imagePanel.setImage(srcImage);
|
||||
this.repaint();
|
||||
for (final CardPanel cardPanel : this.imageLoadListeners) {
|
||||
synchronized (imagePanel) {
|
||||
imagePanel.setImage(srcImage);
|
||||
repaint();
|
||||
for (final CardPanel cardPanel : imageLoadListeners) {
|
||||
cardPanel.setImage(srcImage);
|
||||
cardPanel.repaint();
|
||||
}
|
||||
this.imageLoadListeners.clear();
|
||||
imageLoadListeners.clear();
|
||||
}
|
||||
this.doLayout();
|
||||
doLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setImage.
|
||||
* </p>
|
||||
*
|
||||
* @param panel
|
||||
* a {@link forge.view.arcane.CardPanel} object.
|
||||
*/
|
||||
public final void setImage(final CardPanel panel) {
|
||||
if (panel == this) {
|
||||
throw new IllegalArgumentException("Can't pass 'this' as argument to CardPanel#setImage");
|
||||
}
|
||||
synchronized (panel.imagePanel) {
|
||||
if (panel.imagePanel.hasImage()) {
|
||||
this.setImage(panel.imagePanel.getSrcImage());
|
||||
setImage(panel.imagePanel.getSrcImage());
|
||||
} else {
|
||||
panel.imageLoadListeners.add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Setter for the field <code>displayEnabled</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param displayEnabled
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setDisplayEnabled(final boolean displayEnabled) {
|
||||
this.displayEnabled = displayEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isDisplayEnabled.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isDisplayEnabled() {
|
||||
return this.displayEnabled;
|
||||
return displayEnabled;
|
||||
}
|
||||
public final void setDisplayEnabled(final boolean displayEnabled0) {
|
||||
displayEnabled = displayEnabled0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setAnimationPanel.
|
||||
* </p>
|
||||
*
|
||||
* @param isAnimationPanel
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setAnimationPanel(final boolean isAnimationPanel) {
|
||||
this.isAnimationPanel = isAnimationPanel;
|
||||
public final void setAnimationPanel(final boolean isAnimationPanel0) {
|
||||
isAnimationPanel = isAnimationPanel0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setSelected.
|
||||
* </p>
|
||||
*
|
||||
* @param isSelected
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setSelected(final boolean isSelected) {
|
||||
this.isSelected = isSelected;
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isSelected.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isSelected() {
|
||||
return this.isSelected;
|
||||
return isSelected;
|
||||
}
|
||||
public final void setSelected(final boolean isSelected0) {
|
||||
isSelected = isSelected0;
|
||||
repaint();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
||||
@Override
|
||||
public final void paint(final Graphics g) {
|
||||
if (!this.displayEnabled) {
|
||||
if (!displayEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!this.isValid()) {
|
||||
if (!isValid()) {
|
||||
super.validate();
|
||||
}
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
if (this.getTappedAngle() > 0) {
|
||||
if (getTappedAngle() > 0) {
|
||||
g2d = (Graphics2D) g2d.create();
|
||||
final float edgeOffset = this.cardWidth / 2f;
|
||||
g2d.rotate(this.getTappedAngle(), this.cardXOffset + edgeOffset, (this.cardYOffset + this.cardHeight)
|
||||
final float edgeOffset = cardWidth / 2f;
|
||||
g2d.rotate(getTappedAngle(), cardXOffset + edgeOffset, (cardYOffset + cardHeight)
|
||||
- edgeOffset);
|
||||
}
|
||||
super.paint(g2d);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final void paintComponent(final Graphics g) {
|
||||
final Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
final int cornerSize = Math.max(4, Math.round(this.cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
|
||||
final int offset = this.isTapped() ? 1 : 0;
|
||||
final int cornerSize = Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
|
||||
final int offset = isTapped() ? 1 : 0;
|
||||
|
||||
// Magenta outline for when card was chosen to pay
|
||||
if (MatchUtil.isUsedToPay(this.getCard())) {
|
||||
if (MatchUtil.isUsedToPay(getCard())) {
|
||||
g2d.setColor(Color.magenta);
|
||||
final int n2 = Math.max(1, Math.round(2 * this.cardWidth * CardPanel.SELECTED_BORDER_SIZE));
|
||||
g2d.fillRoundRect(this.cardXOffset - n2, (this.cardYOffset - n2) + offset, this.cardWidth + (n2 * 2), this.cardHeight + (n2 * 2), cornerSize + n2, cornerSize + n2);
|
||||
final int n2 = Math.max(1, Math.round(2 * cardWidth * CardPanel.SELECTED_BORDER_SIZE));
|
||||
g2d.fillRoundRect(cardXOffset - n2, (cardYOffset - n2) + offset, cardWidth + (n2 * 2), cardHeight + (n2 * 2), cornerSize + n2, cornerSize + n2);
|
||||
}
|
||||
|
||||
// Green outline for hover
|
||||
if (this.isSelected) {
|
||||
if (isSelected) {
|
||||
g2d.setColor(Color.green);
|
||||
final int n = Math.max(1, Math.round(this.cardWidth * CardPanel.SELECTED_BORDER_SIZE));
|
||||
g2d.fillRoundRect(this.cardXOffset - n, (this.cardYOffset - n) + offset, this.cardWidth + (n * 2), this.cardHeight + (n * 2), cornerSize + n , cornerSize + n);
|
||||
final int n = Math.max(1, Math.round(cardWidth * CardPanel.SELECTED_BORDER_SIZE));
|
||||
g2d.fillRoundRect(cardXOffset - n, (cardYOffset - n) + offset, cardWidth + (n * 2), cardHeight + (n * 2), cornerSize + n , cornerSize + n);
|
||||
}
|
||||
|
||||
// Black fill - (will become outline for white bordered cards)
|
||||
final int n = 0;
|
||||
g2d.setColor(Color.black);
|
||||
g2d.fillRoundRect(this.cardXOffset - n, (this.cardYOffset - n) + offset, this.cardWidth + (n * 2), this.cardHeight + (n * 2), cornerSize + n , cornerSize + n);
|
||||
g2d.fillRoundRect(cardXOffset - n, (cardYOffset - n) + offset, cardWidth + (n * 2), cardHeight + (n * 2), cornerSize + n , cornerSize + n);
|
||||
|
||||
// White border if card is known to have it.
|
||||
if (this.getCard() != null) {
|
||||
CardEdition ed = FModel.getMagicDb().getEditions().get(this.getCard().getSetCode());
|
||||
if (ed != null && ed.isWhiteBorder() && this.getCard().getOriginal().getFoilIndex() == 0) {
|
||||
if (getCard() != null) {
|
||||
CardEdition ed = FModel.getMagicDb().getEditions().get(getCard().getSetCode());
|
||||
if (ed != null && ed.isWhiteBorder() && getCard().getOriginal().getFoilIndex() == 0) {
|
||||
g2d.setColor(Color.white);
|
||||
int ins = 1;
|
||||
g2d.fillRoundRect(this.cardXOffset + ins, this.cardYOffset + ins, this.cardWidth - ins*2, this.cardHeight - ins*2, cornerSize-ins, cornerSize-ins);
|
||||
g2d.fillRoundRect(cardXOffset + ins, cardYOffset + ins, cardWidth - ins*2, cardHeight - ins*2, cornerSize-ins, cornerSize-ins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param g
|
||||
* @param manaCost
|
||||
*/
|
||||
private void drawManaCost(final Graphics g, ManaCost cost, int deltaY) {
|
||||
int width = CardFaceSymbols.getWidth(cost);
|
||||
int height = CardFaceSymbols.getHeight();
|
||||
CardFaceSymbols.draw(g, cost, (this.cardXOffset + (this.cardWidth / 2)) - (width / 2), deltaY + this.cardYOffset + (this.cardHeight / 2) - height/2);
|
||||
CardFaceSymbols.draw(g, cost, (cardXOffset + (cardWidth / 2)) - (width / 2), deltaY + cardYOffset + (cardHeight / 2) - height/2);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final void paintChildren(final Graphics g) {
|
||||
super.paintChildren(g);
|
||||
|
||||
if (this.isAnimationPanel || this.card == null) {
|
||||
if (isAnimationPanel || card == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
displayIconOverlay(g);
|
||||
drawFoilEffect(g, card, this.cardXOffset, this.cardYOffset,
|
||||
this.cardWidth, this.cardHeight, Math.round(this.cardWidth * BLACK_BORDER_SIZE));
|
||||
drawFoilEffect(g, card, cardXOffset, cardYOffset,
|
||||
cardWidth, cardHeight, Math.round(cardWidth * BLACK_BORDER_SIZE));
|
||||
}
|
||||
|
||||
public static void drawFoilEffect(final Graphics g, final CardView card2, final int x, final int y, final int width, final int height, final int borderSize) {
|
||||
@@ -376,15 +309,15 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
|
||||
@Override
|
||||
public final void doLayout() {
|
||||
final int borderSize = Math.round(this.cardWidth * CardPanel.BLACK_BORDER_SIZE);
|
||||
final int borderSize = Math.round(cardWidth * CardPanel.BLACK_BORDER_SIZE);
|
||||
|
||||
final Point imgPos = new Point(this.cardXOffset + borderSize, this.cardYOffset + borderSize);
|
||||
final Dimension imgSize = new Dimension(this.cardWidth - (borderSize * 2), this.cardHeight - (borderSize * 2));
|
||||
final Point imgPos = new Point(cardXOffset + borderSize, cardYOffset + borderSize);
|
||||
final Dimension imgSize = new Dimension(cardWidth - (borderSize * 2), cardHeight - (borderSize * 2));
|
||||
|
||||
this.imagePanel.setLocation(imgPos);
|
||||
this.imagePanel.setSize(imgSize);
|
||||
imagePanel.setLocation(imgPos);
|
||||
imagePanel.setSize(imgSize);
|
||||
|
||||
boolean showText = !this.imagePanel.hasImage() || !this.isAnimationPanel;
|
||||
boolean showText = !imagePanel.hasImage() || !isAnimationPanel;
|
||||
|
||||
displayCardNameOverlay(showText && showCardNameOverlay(), imgSize, imgPos);
|
||||
displayPTOverlay(showText && showCardPowerOverlay(), imgSize, imgPos);
|
||||
@@ -393,33 +326,33 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
|
||||
private void displayCardIdOverlay(boolean isVisible, Dimension imgSize, Point imgPos) {
|
||||
if (isVisible) {
|
||||
final Dimension idSize = this.cardIdText.getPreferredSize();
|
||||
this.cardIdText.setSize(idSize.width, idSize.height);
|
||||
final Dimension idSize = cardIdText.getPreferredSize();
|
||||
cardIdText.setSize(idSize.width, idSize.height);
|
||||
final int idX = Math.round(imgSize.width * (24f / 480));
|
||||
final int idY = Math.round(imgSize.height * (650f / 680)) - 8;
|
||||
this.cardIdText.setLocation(imgPos.x + idX, imgPos.y + idY);
|
||||
cardIdText.setLocation(imgPos.x + idX, imgPos.y + idY);
|
||||
}
|
||||
this.cardIdText.setVisible(isVisible);
|
||||
cardIdText.setVisible(isVisible);
|
||||
}
|
||||
|
||||
private void displayPTOverlay(boolean isVisible, Dimension imgSize, Point imgPos) {
|
||||
if (isVisible) {
|
||||
final int rightLine = Math.round(imgSize.width * (412f / 480)) + 3;
|
||||
// Power
|
||||
final Dimension ptSize = this.ptText.getPreferredSize();
|
||||
this.ptText.setSize(ptSize.width, ptSize.height);
|
||||
final Dimension ptSize = ptText.getPreferredSize();
|
||||
ptText.setSize(ptSize.width, ptSize.height);
|
||||
final int ptX = rightLine - ptSize.width/2;
|
||||
final int ptY = Math.round(imgSize.height * (650f / 680)) - 10;
|
||||
this.ptText.setLocation(imgPos.x + ptX, imgPos.y + ptY);
|
||||
ptText.setLocation(imgPos.x + ptX, imgPos.y + ptY);
|
||||
// Toughness
|
||||
final Dimension dmgSize = this.damageText.getPreferredSize();
|
||||
this.damageText.setSize(dmgSize.width, dmgSize.height);
|
||||
final Dimension dmgSize = damageText.getPreferredSize();
|
||||
damageText.setSize(dmgSize.width, dmgSize.height);
|
||||
final int dmgX = rightLine - dmgSize.width / 2;
|
||||
final int dmgY = ptY - 16;
|
||||
this.damageText.setLocation(imgPos.x + dmgX, imgPos.y + dmgY);
|
||||
damageText.setLocation(imgPos.x + dmgX, imgPos.y + dmgY);
|
||||
}
|
||||
this.ptText.setVisible(isVisible);
|
||||
this.damageText.setVisible(isVisible);
|
||||
ptText.setVisible(isVisible);
|
||||
damageText.setVisible(isVisible);
|
||||
}
|
||||
|
||||
private void displayCardNameOverlay(boolean isVisible, Dimension imgSize, Point imgPos) {
|
||||
@@ -427,13 +360,13 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
final int titleX = Math.round(imgSize.width * (24f / 480));
|
||||
final int titleY = Math.round(imgSize.height * (54f / 640)) - 15;
|
||||
final int titleH = Math.round(imgSize.height * (360f / 640));
|
||||
this.titleText.setBounds(imgPos.x + titleX, imgPos.y + titleY + 2, imgSize.width - 2 * titleX, titleH - titleY);
|
||||
titleText.setBounds(imgPos.x + titleX, imgPos.y + titleY + 2, imgSize.width - 2 * titleX, titleH - titleY);
|
||||
}
|
||||
this.titleText.setVisible(isVisible);
|
||||
titleText.setVisible(isVisible);
|
||||
}
|
||||
|
||||
private void displayIconOverlay(final Graphics g) {
|
||||
if (showCardManaCostOverlay() && this.cardWidth < 200) {
|
||||
if (showCardManaCostOverlay() && cardWidth < 200) {
|
||||
final boolean showSplitMana = card.isSplitCard();
|
||||
if (!showSplitMana) {
|
||||
drawManaCost(g, card.getOriginal().getManaCost(), 0);
|
||||
@@ -444,26 +377,28 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
int number = 0;
|
||||
for (final Integer i : card.getCounters().values()) {
|
||||
number += i.intValue();
|
||||
if (card.getCounters() != null) {
|
||||
for (final Integer i : card.getCounters().values()) {
|
||||
number += i.intValue();
|
||||
}
|
||||
}
|
||||
|
||||
final int counters = number;
|
||||
final int yCounters = (this.cardYOffset + this.cardHeight) - (this.cardHeight / 3) - 40;
|
||||
final int yCounters = (cardYOffset + cardHeight) - (cardHeight / 3) - 40;
|
||||
|
||||
if (counters == 1) {
|
||||
CardFaceSymbols.drawSymbol("counters1", g, this.cardXOffset - 15, yCounters);
|
||||
CardFaceSymbols.drawSymbol("counters1", g, cardXOffset - 15, yCounters);
|
||||
} else if (counters == 2) {
|
||||
CardFaceSymbols.drawSymbol("counters2", g, this.cardXOffset - 15, yCounters);
|
||||
CardFaceSymbols.drawSymbol("counters2", g, cardXOffset - 15, yCounters);
|
||||
} else if (counters == 3) {
|
||||
CardFaceSymbols.drawSymbol("counters3", g, this.cardXOffset - 15, yCounters);
|
||||
CardFaceSymbols.drawSymbol("counters3", g, cardXOffset - 15, yCounters);
|
||||
} else if (counters > 3) {
|
||||
CardFaceSymbols.drawSymbol("countersMulti", g, this.cardXOffset - 15, yCounters);
|
||||
CardFaceSymbols.drawSymbol("countersMulti", g, cardXOffset - 15, yCounters);
|
||||
}
|
||||
|
||||
final int combatXSymbols = (this.cardXOffset + (this.cardWidth / 4)) - 16;
|
||||
final int stateXSymbols = (this.cardXOffset + (this.cardWidth / 2)) - 16;
|
||||
final int ySymbols = (this.cardYOffset + this.cardHeight) - (this.cardHeight / 8) - 16;
|
||||
final int combatXSymbols = (cardXOffset + (cardWidth / 4)) - 16;
|
||||
final int stateXSymbols = (cardXOffset + (cardWidth / 2)) - 16;
|
||||
final int ySymbols = (cardYOffset + cardHeight) - (cardHeight / 8) - 16;
|
||||
|
||||
if (card.isAttacking()) {
|
||||
CardFaceSymbols.drawSymbol("attack", g, combatXSymbols, ySymbols);
|
||||
@@ -481,131 +416,70 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
if (MatchUtil.isUsedToPay(card)) {
|
||||
CardFaceSymbols.drawSymbol("sacrifice", g, (this.cardXOffset + (this.cardWidth / 2)) - 20,
|
||||
(this.cardYOffset + (this.cardHeight / 2)) - 20);
|
||||
CardFaceSymbols.drawSymbol("sacrifice", g, (cardXOffset + (cardWidth / 2)) - 20,
|
||||
(cardYOffset + (cardHeight / 2)) - 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.getCard().toString();
|
||||
return getCard().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setCardBounds.
|
||||
* </p>
|
||||
*
|
||||
* @param x
|
||||
* a int.
|
||||
* @param y
|
||||
* a int.
|
||||
* @param width
|
||||
* a int.
|
||||
* @param height
|
||||
* a int.
|
||||
*/
|
||||
public final void setCardBounds(final int x, final int y, int width, int height) {
|
||||
this.cardWidth = width;
|
||||
this.cardHeight = height;
|
||||
cardWidth = width;
|
||||
cardHeight = height;
|
||||
final int rotCenterX = Math.round(width / 2f);
|
||||
final int rotCenterY = height - rotCenterX;
|
||||
final int rotCenterToTopCorner = Math.round(width * CardPanel.ROT_CENTER_TO_TOP_CORNER);
|
||||
final int rotCenterToBottomCorner = Math.round(width * CardPanel.ROT_CENTER_TO_BOTTOM_CORNER);
|
||||
final int xOffset = rotCenterX - rotCenterToBottomCorner;
|
||||
final int yOffset = rotCenterY - rotCenterToTopCorner;
|
||||
this.cardXOffset = -xOffset;
|
||||
this.cardYOffset = -yOffset;
|
||||
cardXOffset = -xOffset;
|
||||
cardYOffset = -yOffset;
|
||||
width = -xOffset + rotCenterX + rotCenterToTopCorner;
|
||||
height = -yOffset + rotCenterY + rotCenterToBottomCorner;
|
||||
this.setBounds(x + xOffset, y + yOffset, width, height);
|
||||
setBounds(x + xOffset, y + yOffset, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* repaint.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public final void repaint() {
|
||||
final Rectangle b = this.getBounds();
|
||||
final Rectangle b = getBounds();
|
||||
final JRootPane rootPane = SwingUtilities.getRootPane(this);
|
||||
if (rootPane == null) {
|
||||
return;
|
||||
}
|
||||
final Point p = SwingUtilities.convertPoint(this.getParent(), b.x, b.y, rootPane);
|
||||
final Point p = SwingUtilities.convertPoint(getParent(), b.x, b.y, rootPane);
|
||||
rootPane.repaint(p.x, p.y, b.width, b.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getCardX.
|
||||
* </p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardX() {
|
||||
return this.getX() + this.cardXOffset;
|
||||
return getX() + cardXOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getCardY.
|
||||
* </p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardY() {
|
||||
return this.getY() + this.cardYOffset;
|
||||
return getY() + cardYOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>cardWidth</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardWidth() {
|
||||
return this.cardWidth;
|
||||
return cardWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>cardHeight</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getCardHeight() {
|
||||
return this.cardHeight;
|
||||
return cardHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getCardLocation.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.awt.Point} object.
|
||||
*/
|
||||
public final Point getCardLocation() {
|
||||
final Point p = this.getLocation();
|
||||
p.x += this.cardXOffset;
|
||||
p.y += this.cardYOffset;
|
||||
final Point p = getLocation();
|
||||
p.x += cardXOffset;
|
||||
p.y += cardYOffset;
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getCardLocationOnScreen.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.awt.Point} object.
|
||||
*/
|
||||
public final Point getCardLocationOnScreen() {
|
||||
final Point p = this.getLocationOnScreen();
|
||||
p.x += this.cardXOffset;
|
||||
p.y += this.cardYOffset;
|
||||
final Point p = getLocationOnScreen();
|
||||
p.x += cardXOffset;
|
||||
p.y += cardYOffset;
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -615,13 +489,13 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
// Card name overlay
|
||||
this.titleText.setText(card.getOriginal().getName());
|
||||
titleText.setText(card.getOriginal().getName());
|
||||
|
||||
int damage = card.getDamage();
|
||||
this.damageText.setText(damage > 0 ? "\u00BB " + String.valueOf(damage) + " \u00AB" : "");
|
||||
damageText.setText(damage > 0 ? "\u00BB " + String.valueOf(damage) + " \u00AB" : "");
|
||||
|
||||
// Card Id overlay
|
||||
this.cardIdText.setText(Integer.toString(card.getId()));
|
||||
cardIdText.setText(Integer.toString(card.getId()));
|
||||
}
|
||||
|
||||
public final void updatePTOverlay() {
|
||||
@@ -637,46 +511,41 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
else if (state.isPlaneswalker()) {
|
||||
sPt = String.valueOf(state.getLoyalty());
|
||||
}
|
||||
this.ptText.setText(sPt);
|
||||
ptText.setText(sPt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the card.
|
||||
*
|
||||
* @return the card
|
||||
*/
|
||||
@Override
|
||||
public final CardView getCard() {
|
||||
return this.card;
|
||||
return card;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void setCard(final CardView cardView) {
|
||||
if ((this.getCard() != null) && this.getCard().equals(cardView) && this.isAnimationPanel
|
||||
&& this.imagePanel.hasImage()) {
|
||||
if ((getCard() != null) && getCard().equals(cardView) && isAnimationPanel
|
||||
&& imagePanel.hasImage()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.card = cardView;
|
||||
card = cardView;
|
||||
|
||||
if (this.imagePanel == null) {
|
||||
if (imagePanel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final BufferedImage image = cardView == null ? null : ImageCache.getImage(cardView, imagePanel.getWidth(), imagePanel.getHeight());
|
||||
this.updateText();
|
||||
this.updatePTOverlay();
|
||||
updateText();
|
||||
updatePTOverlay();
|
||||
|
||||
this.setImage(image);
|
||||
setImage(image);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
this.attachedToPanel = null;
|
||||
this.attachedPanels = null;
|
||||
this.imagePanel.setImage(null);
|
||||
this.imagePanel = null;
|
||||
this.card = null;
|
||||
attachedToPanel = null;
|
||||
attachedPanels = null;
|
||||
imagePanel.setImage(null);
|
||||
imagePanel = null;
|
||||
card = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -704,7 +573,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* @return the attachedToPanel
|
||||
*/
|
||||
public final CardPanel getAttachedToPanel() {
|
||||
return this.attachedToPanel;
|
||||
return attachedToPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -714,7 +583,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* the attachedToPanel to set
|
||||
*/
|
||||
public final void setAttachedToPanel(final CardPanel attachedToPanel0) {
|
||||
this.attachedToPanel = attachedToPanel0;
|
||||
attachedToPanel = attachedToPanel0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -723,7 +592,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* @return the attachedPanels
|
||||
*/
|
||||
public final List<CardPanel> getAttachedPanels() {
|
||||
return this.attachedPanels;
|
||||
return attachedPanels;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -733,7 +602,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* the attachedPanels to set
|
||||
*/
|
||||
public final void setAttachedPanels(final List<CardPanel> attachedPanels0) {
|
||||
this.attachedPanels = attachedPanels0;
|
||||
attachedPanels = attachedPanels0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -742,7 +611,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* @return the tapped
|
||||
*/
|
||||
public final boolean isTapped() {
|
||||
return this.tapped;
|
||||
return tapped;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -752,7 +621,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* the tapped to set
|
||||
*/
|
||||
public final void setTapped(final boolean tapped0) {
|
||||
this.tapped = tapped0;
|
||||
tapped = tapped0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -761,7 +630,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* @return the tappedAngle
|
||||
*/
|
||||
public final double getTappedAngle() {
|
||||
return this.tappedAngle;
|
||||
return tappedAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -771,7 +640,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* the tappedAngle to set
|
||||
*/
|
||||
public final void setTappedAngle(final double tappedAngle0) {
|
||||
this.tappedAngle = tappedAngle0;
|
||||
tappedAngle = tappedAngle0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -788,7 +657,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
private boolean isShowingOverlays() {
|
||||
return isPreferenceEnabled(FPref.UI_SHOW_CARD_OVERLAYS) && this.card != null;
|
||||
return isPreferenceEnabled(FPref.UI_SHOW_CARD_OVERLAYS) && card != null;
|
||||
}
|
||||
|
||||
private boolean showCardNameOverlay() {
|
||||
|
||||
@@ -30,11 +30,11 @@ import java.util.List;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.card.CardView;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.CardView;
|
||||
import forge.view.arcane.util.CardPanelMouseListener;
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,14 +28,14 @@ import java.util.List;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.controllers.CPrompt;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.util.Animation;
|
||||
import forge.view.arcane.util.CardPanelMouseListener;
|
||||
|
||||
@@ -124,7 +124,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
break;
|
||||
}
|
||||
if (!panel.getAttachedPanels().isEmpty()
|
||||
|| !panel.getCard().getCounters().equals(firstPanel.getCard().getCounters())
|
||||
|| !panel.getCard().hasSameCounters(firstPanel.getCard())
|
||||
|| firstPanel.getCard().isEnchanted() || (stack.size() == this.landStackMax)) {
|
||||
// If this land has attachments or the stack is full,
|
||||
// put it to the right.
|
||||
@@ -180,7 +180,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
final String firstText = firstState.getText();
|
||||
|
||||
if (!panel.getAttachedPanels().isEmpty()
|
||||
|| !card.getCounters().equals(firstPanel.getCard().getCounters())
|
||||
|| !card.hasSameCounters(firstPanel.getCard())
|
||||
|| (card.isSick() != firstCard.isSick())
|
||||
|| (state.getPower() != firstState.getPower())
|
||||
|| (state.getToughness() != firstState.getToughness())
|
||||
@@ -670,27 +670,33 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
}
|
||||
toPanel.getAttachedPanels().clear();
|
||||
|
||||
final Iterable<CardView> enchants = card.getEnchantedBy();
|
||||
for (final CardView e : enchants) {
|
||||
final CardPanel cardE = getCardPanel(e.getId());
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
if (card.isEnchanted()) {
|
||||
final Iterable<CardView> enchants = card.getEnchantedBy();
|
||||
for (final CardView e : enchants) {
|
||||
final CardPanel cardE = getCardPanel(e.getId());
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Iterable<CardView> equips = card.getEquippedBy();
|
||||
for (final CardView e : equips) {
|
||||
final CardPanel cardE = getCardPanel(e.getId());
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
if (card.isEquipped()) {
|
||||
final Iterable<CardView> equips = card.getEquippedBy();
|
||||
for (final CardView e : equips) {
|
||||
final CardPanel cardE = getCardPanel(e.getId());
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Iterable<CardView> fortifications = card.getFortifiedBy();
|
||||
for (final CardView f : fortifications) {
|
||||
final CardPanel cardE = getCardPanel(f.getId());
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
if (card.isFortified()) {
|
||||
final Iterable<CardView> fortifications = card.getFortifiedBy();
|
||||
for (final CardView f : fortifications) {
|
||||
final CardPanel cardE = getCardPanel(f.getId());
|
||||
if (cardE != null) {
|
||||
toPanel.getAttachedPanels().add(cardE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -773,7 +779,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
final CardStateView thisState = thisCard.getOriginal();
|
||||
if (otherState.getName().equals(thisState.getName()) && s.size() < othersStackMax) {
|
||||
if (panel.getAttachedPanels().isEmpty()
|
||||
&& thisCard.getCounters().equals(otherCard.getCounters())
|
||||
&& thisCard.hasSameCounters(otherCard)
|
||||
&& (thisCard.isSick() == otherCard.isSick())
|
||||
&& (thisCard.isCloned() == otherCard.isCloned())) {
|
||||
s.add(panel);
|
||||
|
||||
@@ -28,6 +28,8 @@ import forge.deck.FDeckViewer;
|
||||
import forge.deck.FSideboardDialog;
|
||||
import forge.error.BugReportDialog;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.DelayedReveal;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.interfaces.IGuiBase;
|
||||
@@ -49,8 +51,6 @@ import forge.util.ThreadUtil;
|
||||
import forge.util.WaitCallback;
|
||||
import forge.util.WaitRunnable;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
import forge.view.CardView;
|
||||
import forge.view.GameEntityView;
|
||||
|
||||
public class GuiMobile implements IGuiBase {
|
||||
private final String assetsDir;
|
||||
@@ -215,7 +215,7 @@ public class GuiMobile implements IGuiBase {
|
||||
@Override
|
||||
public GameEntityView chooseSingleEntityForEffect(final String title, final Collection<? extends GameEntity> optionList, final DelayedReveal delayedReveal, final boolean isOptional, final PlayerControllerHuman controller) {
|
||||
controller.tempShow(optionList);
|
||||
final List<GameEntityView> choiceList = controller.getGameView().getGameEntityViews(optionList, false);
|
||||
final List<GameEntityView> choiceList = GameEntityView.getEntityCollection(optionList);
|
||||
|
||||
if (delayedReveal == null || Iterables.isEmpty(delayedReveal.getCards())) {
|
||||
if (isOptional) {
|
||||
@@ -225,7 +225,7 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
controller.tempShow(delayedReveal.getCards());
|
||||
final List<CardView> revealList = controller.getGameView().getCardViews(delayedReveal.getCards(), false);
|
||||
final List<CardView> revealList = CardView.getCollection(delayedReveal.getCards());
|
||||
final String revealListCaption = StringUtils.capitalize(MessageUtil.formatMessage("{player's} " + delayedReveal.getZone().name(), controller.getPlayer(), delayedReveal.getOwner()));
|
||||
final FImage revealListImage = MatchController.getView().getPlayerPanels().values().iterator().next().getZoneTab(delayedReveal.getZone()).getIcon();
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import forge.ImageKeys;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.view.CardView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ import forge.assets.TextRenderer;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.CardRenderer.CardStackPosition;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.screens.FScreen;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
public class CardImageRenderer {
|
||||
private static final float BASE_IMAGE_WIDTH = 360;
|
||||
@@ -166,7 +166,7 @@ public class CardImageRenderer {
|
||||
//draw mana cost for card
|
||||
float manaCostWidth = 0;
|
||||
ManaCost mainManaCost = state.getManaCost();
|
||||
if (card.isSplitCard() && card.hasAltState()) {
|
||||
if (card.isSplitCard() && card.getAlternate() != null) {
|
||||
//handle rendering both parts of split card
|
||||
mainManaCost = state.getManaCost();
|
||||
ManaCost otherManaCost = card.getAlternate().getManaCost();
|
||||
|
||||
@@ -23,6 +23,8 @@ import forge.assets.ImageCache;
|
||||
import forge.assets.TextRenderer;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
@@ -31,9 +33,6 @@ import forge.toolbox.FCardPanel;
|
||||
import forge.toolbox.FDialog;
|
||||
import forge.toolbox.FList;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
public class CardRenderer {
|
||||
public enum CardStackPosition {
|
||||
@@ -284,7 +283,7 @@ public class CardRenderer {
|
||||
}
|
||||
}
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, IPaperCard pc, int count, String suffix, float x, float y, float w, float h, boolean compactMode) {
|
||||
final CardView card = ViewUtil.getCardForUi(pc);
|
||||
final CardView card = CardView.getCardForUi(pc);
|
||||
final CardStateView state = card.getOriginal();
|
||||
drawCardListItem(g, font, foreColor, getCardArt(pc), card, pc.getEdition(),
|
||||
pc.getRarity(), state.getPower(), state.getToughness(),
|
||||
@@ -372,7 +371,7 @@ public class CardRenderer {
|
||||
float cardArtHeight = getCardListItemHeight(compactMode);
|
||||
float cardArtWidth = cardArtHeight * CARD_ART_RATIO;
|
||||
if (x <= cardArtWidth && y <= cardArtHeight) {
|
||||
CardZoom.show(ViewUtil.getCardForUi(pc));
|
||||
CardZoom.show(CardView.getCardForUi(pc));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -489,15 +488,15 @@ public class CardRenderer {
|
||||
Texture image = ImageCache.getImage(pc);
|
||||
if (image != null) {
|
||||
if (image == ImageCache.defaultImage) {
|
||||
CardImageRenderer.drawCardImage(g, ViewUtil.getCardForUi(pc), x, y, w, h, pos);
|
||||
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), x, y, w, h, pos);
|
||||
}
|
||||
else {
|
||||
g.drawImage(image, x, y, w, h);
|
||||
}
|
||||
if (pc.isFoil()) { //draw foil effect if needed
|
||||
final CardView card = ViewUtil.getCardForUi(pc);
|
||||
final CardView card = CardView.getCardForUi(pc);
|
||||
if (card.getOriginal().getFoilIndex() == 0) { //if foil finish not yet established, assign a random one
|
||||
card.getOriginal().setRandomFoil();
|
||||
card.getOriginal().setFoilIndexOverride(-1);
|
||||
}
|
||||
drawFoilEffect(g, card, x, y, w, h);
|
||||
}
|
||||
@@ -564,8 +563,10 @@ public class CardRenderer {
|
||||
}
|
||||
|
||||
int number = 0;
|
||||
for (final Integer i : card.getCounters().values()) {
|
||||
number += i.intValue();
|
||||
if (card.getCounters() != null) {
|
||||
for (final Integer i : card.getCounters().values()) {
|
||||
number += i.intValue();
|
||||
}
|
||||
}
|
||||
|
||||
final int counters = number;
|
||||
|
||||
@@ -5,12 +5,11 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
import forge.Graphics;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.game.card.CardView;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
public class CardZoom extends FOverlay {
|
||||
private static final float TAB_HEIGHT = Utils.AVG_FINGER_HEIGHT;
|
||||
@@ -20,7 +19,7 @@ public class CardZoom extends FOverlay {
|
||||
private static boolean zoomMode = true;
|
||||
|
||||
public static <T> void show(final IPaperCard pc0) {
|
||||
card = ViewUtil.getCardForUi(pc0);
|
||||
card = CardView.getCardForUi(pc0);
|
||||
cardZoom.show();
|
||||
}
|
||||
public static <T> void show(final CardView card0) {
|
||||
|
||||
@@ -8,6 +8,8 @@ import forge.Forge;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.screens.TabPageScreen;
|
||||
import forge.toolbox.FChoiceList;
|
||||
import forge.toolbox.FDialog;
|
||||
@@ -16,8 +18,6 @@ import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FTextField;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.util.Callback;
|
||||
import forge.view.CardView;
|
||||
import forge.view.GameEntityView;
|
||||
|
||||
public class GameEntityPicker extends TabPageScreen<GameEntityPicker> {
|
||||
private final FOptionPane optionPane;
|
||||
|
||||
@@ -12,6 +12,7 @@ import forge.card.CardRenderer;
|
||||
import forge.card.CardRenderer.CardStackPosition;
|
||||
import forge.card.CardZoom;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.game.card.CardView;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
@@ -32,7 +33,6 @@ import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.util.Utils;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
@@ -874,7 +874,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
public boolean longPress(float x, float y) {
|
||||
ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop());
|
||||
if (item != null && item.item instanceof IPaperCard) {
|
||||
CardZoom.show(ViewUtil.getCardForUi((IPaperCard) item.item));
|
||||
CardZoom.show(CardView.getCardForUi((IPaperCard) item.item));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -15,9 +15,14 @@ import forge.LobbyPlayer;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkin;
|
||||
import forge.assets.FTextureRegionImage;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.GameView;
|
||||
import forge.game.Match;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.interfaces.IButton;
|
||||
import forge.match.IMatchController;
|
||||
@@ -27,10 +32,10 @@ import forge.player.PlayerControllerHuman;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.views.VAssignDamage;
|
||||
import forge.screens.match.views.VPhaseIndicator;
|
||||
import forge.screens.match.views.VPlayerPanel;
|
||||
import forge.screens.match.views.VCardDisplayArea.CardAreaPanel;
|
||||
import forge.screens.match.views.VPhaseIndicator;
|
||||
import forge.screens.match.views.VPhaseIndicator.PhaseLabel;
|
||||
import forge.screens.match.views.VPlayerPanel;
|
||||
import forge.screens.match.views.VPlayerPanel.InfoTab;
|
||||
import forge.screens.match.views.VPrompt;
|
||||
import forge.screens.match.winlose.ViewWinLose;
|
||||
@@ -38,12 +43,6 @@ import forge.toolbox.FDisplayObject;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.util.WaitCallback;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.LocalGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.SpellAbilityView;
|
||||
|
||||
public class MatchController implements IMatchController {
|
||||
private MatchController() { }
|
||||
@@ -98,7 +97,7 @@ public class MatchController implements IMatchController {
|
||||
boolean noHumans = MatchUtil.getHumanCount() == 0;
|
||||
List<VPlayerPanel> playerPanels = new ArrayList<VPlayerPanel>();
|
||||
for (Player p : sortedPlayers) {
|
||||
playerPanels.add(new VPlayerPanel(MatchUtil.getGameView(p).getPlayerView(p, false), noHumans || p.getController() instanceof PlayerControllerHuman));
|
||||
playerPanels.add(new VPlayerPanel(PlayerView.get(p), noHumans || p.getController() instanceof PlayerControllerHuman));
|
||||
}
|
||||
view = new MatchScreen(playerPanels);
|
||||
|
||||
@@ -151,7 +150,7 @@ public class MatchController implements IMatchController {
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
LocalGameView gameView = MatchUtil.getGameView();
|
||||
GameView gameView = MatchUtil.getGameView();
|
||||
final PlayerView p = gameView.getPlayerTurn();
|
||||
final PhaseType ph = gameView.getPhase();
|
||||
|
||||
@@ -171,7 +170,7 @@ public class MatchController implements IMatchController {
|
||||
public void updatePlayerControl() {
|
||||
//show/hide hand for top player based on whether the opponent is controlled
|
||||
if (MatchUtil.getHumanCount() == 1) {
|
||||
Player player = MatchUtil.getGameView().getPlayer(view.getTopPlayerPanel().getPlayer());
|
||||
Player player = Player.get(view.getTopPlayerPanel().getPlayer());
|
||||
if (player.getMindSlaveMaster() != null) {
|
||||
view.getTopPlayerPanel().setSelectedZone(ZoneType.Hand);
|
||||
}
|
||||
@@ -205,19 +204,18 @@ public class MatchController implements IMatchController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAbilityToPlay(List<SpellAbilityView> abilities, ITriggerEvent triggerEvent) {
|
||||
public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, ITriggerEvent triggerEvent) {
|
||||
if (abilities.isEmpty()) {
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
if (abilities.size() == 1) {
|
||||
return abilities.get(0).getId();
|
||||
return abilities.get(0);
|
||||
}
|
||||
final SpellAbilityView choice = SGuiChoose.oneOrNone("Choose ability to play", abilities);
|
||||
return choice == null ? -1 : choice.getId();
|
||||
return SGuiChoose.oneOrNone("Choose ability to play", abilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCombat(final CombatView combat) {
|
||||
public void showCombat() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,19 @@ import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Forge.KeyInputAdapter;
|
||||
import forge.Graphics;
|
||||
import forge.animation.AbilityEffect;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.assets.FSkinTexture;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.combat.CombatView;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.menu.FDropDown;
|
||||
@@ -25,35 +37,24 @@ import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.FScreen;
|
||||
import forge.screens.match.views.VAvatar;
|
||||
import forge.screens.match.views.VCardDisplayArea.CardAreaPanel;
|
||||
import forge.screens.match.views.VDevMenu;
|
||||
import forge.screens.match.views.VGameMenu;
|
||||
import forge.screens.match.views.VLog;
|
||||
import forge.screens.match.views.VManaPool;
|
||||
import forge.screens.match.views.VPlayerPanel;
|
||||
import forge.screens.match.views.VCardDisplayArea.CardAreaPanel;
|
||||
import forge.screens.match.views.VPhaseIndicator.PhaseLabel;
|
||||
import forge.screens.match.views.VPlayerPanel;
|
||||
import forge.screens.match.views.VPlayerPanel.InfoTab;
|
||||
import forge.screens.match.views.VPlayers;
|
||||
import forge.screens.match.views.VPrompt;
|
||||
import forge.screens.match.views.VStack;
|
||||
import forge.sound.MusicPlaylist;
|
||||
import forge.sound.SoundSystem;
|
||||
import forge.Forge.KeyInputAdapter;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.animation.AbilityEffect;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinTexture;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.toolbox.FCardPanel;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.util.Callback;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class MatchScreen extends FScreen {
|
||||
public static FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
|
||||
@@ -85,13 +86,13 @@ public class MatchScreen extends FScreen {
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchUtil.getGameView().selectButtonOk();
|
||||
MatchUtil.getHumanController().selectButtonOk();
|
||||
}
|
||||
},
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchUtil.getGameView().selectButtonCancel();
|
||||
MatchUtil.getHumanController().selectButtonCancel();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -103,13 +104,13 @@ public class MatchScreen extends FScreen {
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchUtil.getGameView().selectButtonOk();
|
||||
MatchUtil.getHumanController().selectButtonOk();
|
||||
}
|
||||
},
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchUtil.getGameView().selectButtonCancel();
|
||||
MatchUtil.getHumanController().selectButtonCancel();
|
||||
}
|
||||
}));
|
||||
topPlayerPrompt.setRotate180(true);
|
||||
@@ -229,7 +230,7 @@ public class MatchScreen extends FScreen {
|
||||
}
|
||||
|
||||
public boolean isTopHumanPlayerActive() {
|
||||
return topPlayerPrompt != null && MatchUtil.getGameView().getPlayer(topPlayerPanel.getPlayer()) == MatchUtil.getCurrentPlayer();
|
||||
return topPlayerPrompt != null && Player.get(topPlayerPanel.getPlayer()) == MatchUtil.getCurrentPlayer();
|
||||
}
|
||||
|
||||
public VPrompt getActivePrompt() {
|
||||
@@ -375,7 +376,7 @@ public class MatchScreen extends FScreen {
|
||||
break;
|
||||
case Keys.Z: //undo on Ctrl+Z
|
||||
if (KeyInputAdapter.isCtrlKeyDown()) {
|
||||
MatchUtil.getGameView().tryUndoLastAction();
|
||||
MatchUtil.getHumanController().tryUndoLastAction();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -20,10 +20,10 @@ package forge.screens.match;
|
||||
import forge.Graphics;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.screens.match.views.VCardDisplayArea.CardAreaPanel;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
@@ -24,6 +24,9 @@ import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.card.CardZoom;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.toolbox.FButton;
|
||||
@@ -39,9 +42,6 @@ import forge.toolbox.FScrollPane;
|
||||
import forge.util.Callback;
|
||||
import forge.util.Utils;
|
||||
import forge.util.WaitCallback;
|
||||
import forge.view.CardView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.assets.FImage;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.util.Utils;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VAvatar extends FDisplayObject {
|
||||
public static final float WIDTH = Utils.AVG_FINGER_WIDTH;
|
||||
@@ -29,7 +29,7 @@ public class VAvatar extends FDisplayObject {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke in game thread in case a dialog needs to be shown
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().selectPlayer(player, null);
|
||||
MatchUtil.getHumanController().selectPlayer(player, null);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
||||
@@ -11,10 +11,10 @@ import forge.FThreads;
|
||||
import forge.Graphics;
|
||||
import forge.card.CardZoom;
|
||||
import forge.card.CardRenderer.CardStackPosition;
|
||||
import forge.game.card.CardView;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.toolbox.FCardPanel;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.view.CardView;
|
||||
|
||||
public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
private static final float CARD_STACK_OFFSET = 0.2f;
|
||||
@@ -42,7 +42,7 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
rotateCards180 = b0;
|
||||
}
|
||||
|
||||
protected void refreshCardPanels(List<CardView> model) {
|
||||
protected void refreshCardPanels(Iterable<CardView> model) {
|
||||
clear();
|
||||
|
||||
CardAreaPanel newCardPanel = null;
|
||||
@@ -261,7 +261,7 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
}
|
||||
|
||||
public boolean selectCard() {
|
||||
if (MatchUtil.getGameView().selectCard(getCard(), null)) {
|
||||
if (MatchUtil.getHumanController().selectCard(getCard(), null)) {
|
||||
return true;
|
||||
}
|
||||
//if panel can't do anything with card selection, try selecting previous panel in stack
|
||||
|
||||
@@ -17,7 +17,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke all these in game thread since they may require synchronous user input
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().generateMana();
|
||||
MatchUtil.getHumanController().cheat().generateMana();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().tutorForCard();
|
||||
MatchUtil.getHumanController().cheat().tutorForCard();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().addCardToHand();
|
||||
MatchUtil.getHumanController().cheat().addCardToHand();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().addCardToBattlefield();
|
||||
MatchUtil.getHumanController().cheat().addCardToBattlefield();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().setPlayerLife();
|
||||
MatchUtil.getHumanController().cheat().setPlayerLife();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().winGame();
|
||||
MatchUtil.getHumanController().cheat().winGame();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -83,26 +83,26 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().setupGameState();
|
||||
MatchUtil.getHumanController().cheat().setupGameState();
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
final boolean unlimitedLands = MatchUtil.getGameView().canPlayUnlimitedLands();
|
||||
final boolean unlimitedLands = MatchUtil.getHumanController().canPlayUnlimitedLands();
|
||||
addItem(new FCheckBoxMenuItem("Play Unlimited Lands", unlimitedLands,
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchUtil.getGameView().cheat().setCanPlayUnlimitedLands(!unlimitedLands);
|
||||
MatchUtil.getHumanController().cheat().setCanPlayUnlimitedLands(!unlimitedLands);
|
||||
}
|
||||
}));
|
||||
final boolean viewAll = MatchUtil.getGameView().canViewAllCards();
|
||||
final boolean viewAll = MatchUtil.getHumanController().mayLookAtAllCards();
|
||||
addItem(new FCheckBoxMenuItem("View All Cards", viewAll,
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchUtil.getGameView().cheat().setViewAllCards(!viewAll);
|
||||
MatchUtil.getHumanController().cheat().setViewAllCards(!viewAll);
|
||||
}
|
||||
}));
|
||||
addItem(new FMenuItem("Add Counters to Permanent", new FEventHandler() {
|
||||
@@ -111,7 +111,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().addCountersToPermanent();
|
||||
MatchUtil.getHumanController().cheat().addCountersToPermanent();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().tapPermanents();
|
||||
MatchUtil.getHumanController().cheat().tapPermanents();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().untapPermanents();
|
||||
MatchUtil.getHumanController().cheat().untapPermanents();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().riggedPlanarRoll();
|
||||
MatchUtil.getHumanController().cheat().riggedPlanarRoll();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class VDevMenu extends FDropDownMenu {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getGameView().cheat().planeswalkTo();
|
||||
MatchUtil.getHumanController().cheat().planeswalkTo();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.screens.match.views.VCardDisplayArea.CardAreaPanel;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VField extends FContainer {
|
||||
private final PlayerView player;
|
||||
@@ -49,7 +49,7 @@ public class VField extends FContainer {
|
||||
public void run() {
|
||||
clear();
|
||||
|
||||
List<CardView> model = player.getBfCards();
|
||||
Iterable<CardView> model = player.getBattlefield();
|
||||
for (CardView card : model) {
|
||||
updateCard(card);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class VField extends FContainer {
|
||||
for (CardView c : cardsOfType) {
|
||||
if (!c.isEnchanted() && !c.isEquipped() &&
|
||||
cardName.equals(c.getOriginal().getName()) &&
|
||||
card.getCounters().equals(c.getCounters()) &&
|
||||
card.hasSameCounters(c) &&
|
||||
card.isToken() == c.isToken()) { //don't stack tokens on top of non-tokens
|
||||
CardAreaPanel cPanel = CardAreaPanel.get(c);
|
||||
while (cPanel.getNextPanelInStack() != null) {
|
||||
@@ -125,6 +125,7 @@ public class VField extends FContainer {
|
||||
toPanel.setTapped(card.isTapped());
|
||||
|
||||
toPanel.getAttachedPanels().clear();
|
||||
|
||||
if (card.isEnchanted()) {
|
||||
final Iterable<CardView> enchants = card.getEnchantedBy();
|
||||
for (final CardView e : enchants) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.view.PlayerView;
|
||||
import forge.game.player.PlayerView;
|
||||
|
||||
public class VFlashbackZone extends VCardDisplayArea {
|
||||
private final PlayerView player;
|
||||
@@ -18,7 +18,7 @@ public class VFlashbackZone extends VCardDisplayArea {
|
||||
private final Runnable updateRoutine = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
refreshCardPanels(player.getFlashbackCards());
|
||||
refreshCardPanels(player.getFlashback());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class VGameMenu extends FDropDownMenu {
|
||||
//if re-enabling auto-yields, auto-yield to current ability on stack if applicable
|
||||
SpellAbility ability = game.getStack().peekAbility();
|
||||
if (ability != null && ability.isAbility() && localPlayer.getController().shouldAutoYield(ability.toUnsuppressedString())) {
|
||||
MatchUtil.getGameView().passPriority();
|
||||
MatchUtil.getHumanController().passPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class VLog extends FDropDown {
|
||||
clear();
|
||||
|
||||
GameLogEntryType logVerbosityFilter = GameLogEntryType.valueOf(FModel.getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE));
|
||||
List<GameLogEntry> logEntrys = MatchUtil.getGameView().getLogEntries(logVerbosityFilter);
|
||||
List<GameLogEntry> logEntrys = MatchUtil.getGameView().getGameLog().getLogEntries(logVerbosityFilter);
|
||||
|
||||
LogEntryDisplay logEntryDisplay;
|
||||
float width = maxWidth - getMenuTab().screenPos.x; //stretch from tab to edge of screen
|
||||
|
||||
@@ -11,10 +11,10 @@ import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.card.MagicColor;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VManaPool extends VDisplayArea {
|
||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
@@ -82,7 +82,7 @@ public class VManaPool extends VDisplayArea {
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
if (player.getLobbyPlayer() == GamePlayerUtil.getGuiPlayer()) {
|
||||
MatchUtil.getGameView().useMana(colorCode);
|
||||
MatchUtil.getHumanController().useMana(colorCode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
@@ -22,8 +24,6 @@ import forge.screens.match.MatchScreen;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VPlayerPanel extends FContainer {
|
||||
private static final FSkinFont LIFE_FONT = FSkinFont.get(18);
|
||||
@@ -312,7 +312,7 @@ public class VPlayerPanel extends FContainer {
|
||||
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
MatchUtil.getGameView().selectPlayer(player, null); //treat tapping on life the same as tapping on the avatar
|
||||
MatchUtil.getHumanController().selectPlayer(player, null); //treat tapping on life the same as tapping on the avatar
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ public class VPlayerPanel extends FContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshCardPanels(List<CardView> model) {
|
||||
protected void refreshCardPanels(Iterable<CardView> model) {
|
||||
int oldCount = getCount();
|
||||
super.refreshCardPanels(model);
|
||||
int newCount = getCount();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||
|
||||
import forge.Graphics;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.menu.FDropDown;
|
||||
import forge.model.FModel;
|
||||
@@ -16,8 +16,6 @@ import forge.toolbox.FContainer;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.toolbox.FList;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VPlayers extends FDropDown {
|
||||
public VPlayers() {
|
||||
@@ -79,13 +77,15 @@ public class VPlayers extends FDropDown {
|
||||
builder.append(" | " + player.getKeywords().toString());
|
||||
}
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
||||
List<CardView> list = player.getAnteCards();
|
||||
Iterable<CardView> list = player.getAnte();
|
||||
builder.append(" | Ante'd: ");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
builder.append(list.get(i));
|
||||
if (i < (list.size() - 1)) {
|
||||
boolean needDelim = false;
|
||||
for (CardView cv : list) {
|
||||
if (needDelim) {
|
||||
builder.append(", ");
|
||||
}
|
||||
else { needDelim = true; }
|
||||
builder.append(cv);
|
||||
}
|
||||
}
|
||||
if (MatchUtil.getGameView().isCommander()) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.screens.match.views;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -20,7 +19,10 @@ import forge.card.CardRenderer;
|
||||
import forge.card.CardZoom;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.CardRenderer.CardStackPosition;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.StackItemView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.menu.FCheckBoxMenuItem;
|
||||
@@ -28,6 +30,7 @@ import forge.menu.FDropDown;
|
||||
import forge.menu.FMenuItem;
|
||||
import forge.menu.FMenuTab;
|
||||
import forge.menu.FPopupMenu;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.screens.match.TargetingOverlay;
|
||||
import forge.toolbox.FCardPanel;
|
||||
@@ -35,11 +38,8 @@ import forge.toolbox.FDisplayObject;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.util.FCollection;
|
||||
import forge.util.Utils;
|
||||
import forge.view.CardView;
|
||||
import forge.view.LocalGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.StackItemView;
|
||||
|
||||
public class VStack extends FDropDown {
|
||||
public static final float CARD_WIDTH = Utils.AVG_FINGER_WIDTH;
|
||||
@@ -93,7 +93,7 @@ public class VStack extends FDropDown {
|
||||
activeStackInstance = null; //reset before updating stack
|
||||
restoreOldZones();
|
||||
|
||||
final List<StackItemView> stack = MatchUtil.getGameView().getStack();
|
||||
final FCollection<StackItemView>.FCollectionView stack = MatchUtil.getGameView().getStack();
|
||||
if (stackSize != stack.size()) {
|
||||
int oldStackSize = stackSize;
|
||||
stackSize = stack.size();
|
||||
@@ -124,7 +124,7 @@ public class VStack extends FDropDown {
|
||||
float totalWidth = maxWidth - MatchController.getView().getTopPlayerPanel().getTabs().iterator().next().getRight(); //keep avatar, life total, and hand tab visible to left of stack
|
||||
float width = totalWidth - 2 * MARGINS;
|
||||
|
||||
final List<StackItemView> stack = MatchUtil.getGameView().getStack();
|
||||
final FCollection<StackItemView>.FCollectionView stack = MatchUtil.getGameView().getStack();
|
||||
if (stack.isEmpty()) { //show label if stack empty
|
||||
FLabel label = add(new FLabel.Builder().text("[Empty]").font(FONT).align(HAlignment.CENTER).build());
|
||||
|
||||
@@ -222,7 +222,7 @@ public class VStack extends FDropDown {
|
||||
|
||||
private StackInstanceDisplay(StackItemView stackInstance0, float width) {
|
||||
stackInstance = stackInstance0;
|
||||
CardView card = stackInstance.getSource();
|
||||
CardView card = stackInstance.getSourceCard();
|
||||
|
||||
text = stackInstance.getText();
|
||||
if (stackInstance.isOptionalTrigger() &&
|
||||
@@ -255,53 +255,53 @@ public class VStack extends FDropDown {
|
||||
FPopupMenu menu = new FPopupMenu() {
|
||||
@Override
|
||||
protected void buildMenu() {
|
||||
final LocalGameView gameView = MatchUtil.getGameView();
|
||||
final PlayerView playerView = gameView.getPlayerView(player, false);
|
||||
final PlayerControllerHuman humanController = MatchUtil.getHumanController();
|
||||
final PlayerView playerView = PlayerView.get(player);
|
||||
final String key = stackInstance.getKey();
|
||||
final boolean autoYield = gameView.shouldAutoYield(key);
|
||||
final boolean autoYield = humanController.shouldAutoYield(key);
|
||||
addItem(new FCheckBoxMenuItem("Auto-Yield", autoYield,
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
MatchUtil.getGameView().setShouldAutoYield(key, !autoYield);
|
||||
if (!autoYield && stackInstance.equals(gameView.peekStack())) {
|
||||
humanController.setShouldAutoYield(key, !autoYield);
|
||||
if (!autoYield && stackInstance.equals(MatchUtil.getGameView().peekStack())) {
|
||||
//auto-pass priority if ability is on top of stack
|
||||
gameView.passPriority();
|
||||
humanController.passPriority();
|
||||
}
|
||||
}
|
||||
}));
|
||||
if (stackInstance.isOptionalTrigger() && stackInstance.getActivatingPlayer().equals(playerView)) {
|
||||
final int triggerID = stackInstance.getSourceTrigger();
|
||||
addItem(new FCheckBoxMenuItem("Always Yes",
|
||||
gameView.shouldAlwaysAcceptTrigger(triggerID),
|
||||
humanController.shouldAlwaysAcceptTrigger(triggerID),
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
if (gameView.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
gameView.setShouldAlwaysAskTrigger(triggerID);
|
||||
if (humanController.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
humanController.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
gameView.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (stackInstance.equals(gameView.peekStack())) {
|
||||
humanController.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (stackInstance.equals(MatchUtil.getGameView().peekStack())) {
|
||||
//auto-yes if ability is on top of stack
|
||||
gameView.confirm();
|
||||
humanController.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
addItem(new FCheckBoxMenuItem("Always No",
|
||||
gameView.shouldAlwaysDeclineTrigger(triggerID),
|
||||
humanController.shouldAlwaysDeclineTrigger(triggerID),
|
||||
new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
if (gameView.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
gameView.setShouldAlwaysAskTrigger(triggerID);
|
||||
if (humanController.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
humanController.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
gameView.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (stackInstance.equals(gameView.peekStack())) {
|
||||
humanController.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (stackInstance.equals(MatchUtil.getGameView().peekStack())) {
|
||||
//auto-no if ability is on top of stack
|
||||
gameView.confirm();
|
||||
humanController.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +310,7 @@ public class VStack extends FDropDown {
|
||||
addItem(new FMenuItem("Zoom/Details", new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
CardZoom.show(stackInstance.getSource());
|
||||
CardZoom.show(stackInstance.getSourceCard());
|
||||
}
|
||||
}));
|
||||
};
|
||||
@@ -320,13 +320,13 @@ public class VStack extends FDropDown {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
CardZoom.show(stackInstance.getSource());
|
||||
CardZoom.show(stackInstance.getSourceCard());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean longPress(float x, float y) {
|
||||
CardZoom.show(stackInstance.getSource());
|
||||
CardZoom.show(stackInstance.getSourceCard());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ public class VStack extends FDropDown {
|
||||
|
||||
x += PADDING;
|
||||
y += PADDING;
|
||||
CardRenderer.drawCardWithOverlays(g, stackInstance.getSource(), x, y, CARD_WIDTH, CARD_HEIGHT, CardStackPosition.Top);
|
||||
CardRenderer.drawCardWithOverlays(g, stackInstance.getSourceCard(), x, y, CARD_WIDTH, CARD_HEIGHT, CardStackPosition.Top);
|
||||
|
||||
x += CARD_WIDTH + PADDING;
|
||||
w -= x + PADDING - BORDER_THICKNESS;
|
||||
|
||||
@@ -3,10 +3,10 @@ package forge.screens.match.views;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.toolbox.FCardPanel;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class VZoneDisplay extends VCardDisplayArea {
|
||||
private final PlayerView player;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package forge.screens.match.winlose;
|
||||
|
||||
import forge.game.GameView;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.toolbox.FEvent;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* Default controller for a ViewWinLose object. This class can
|
||||
@@ -14,11 +14,11 @@ import forge.view.IGameView;
|
||||
*/
|
||||
public class ControlWinLose {
|
||||
private final ViewWinLose view;
|
||||
protected final IGameView lastGame;
|
||||
protected final GameView lastGame;
|
||||
|
||||
/** @param v   ViewWinLose
|
||||
* @param match */
|
||||
public ControlWinLose(final ViewWinLose v, IGameView game) {
|
||||
public ControlWinLose(final ViewWinLose v, GameView game) {
|
||||
view = v;
|
||||
lastGame = game;
|
||||
addListeners();
|
||||
|
||||
@@ -19,9 +19,9 @@ package forge.screens.match.winlose;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.GameView;
|
||||
import forge.gauntlet.GauntletWinLoseController;
|
||||
import forge.util.gui.SOptionPane;
|
||||
import forge.view.IGameView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class GauntletWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match
|
||||
*/
|
||||
public GauntletWinLose(final ViewWinLose view0, IGameView lastGame) {
|
||||
public GauntletWinLose(final ViewWinLose view0, GameView lastGame) {
|
||||
super(view0, lastGame);
|
||||
controller = new GauntletWinLoseController(view0, lastGame) {
|
||||
@Override
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user