Merge branch 'playerControllerGameMemory' into 'master'

GameView: do not store Game anymore, get it from Match

Closes #1650

See merge request core-developers/forge!3457
This commit is contained in:
Sol
2020-12-01 01:40:04 +00:00
21 changed files with 295 additions and 244 deletions

View File

@@ -213,7 +213,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
if(FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.FILTERED_HANDS)){
baseLandParameter--;
}
landsNeeded = new Double((baseLandParameter + 3.14f * avCMC) * targetSize/60f).intValue();
landsNeeded = Double.valueOf((baseLandParameter + 3.14f * avCMC) * targetSize/60f).intValue();
if (logToConsole) {
System.out.println("Required lands from linear regression : " + avCMC + " cmc, needed: " + landsNeeded);
}
@@ -425,8 +425,6 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
@Override
public boolean apply(CardRules subject) {
ManaCost mc = subject.getManaCost();
boolean generic = mc.isPureGeneric();
return ((allowedColor.containsAllColorsFrom(subject.getColorIdentity().getColor())));
}
}

View File

@@ -126,6 +126,8 @@ public class HostedMatch {
title = TextUtil.concatNoSpace("Multiplayer Game (", String.valueOf(sortedPlayers.size()), " players)");
}
this.match = new Match(gameRules, sortedPlayers, title);
this.match.subscribeToEvents(SoundSystem.instance);
this.match.subscribeToEvents(visitor);
startGame();
}
@@ -149,7 +151,7 @@ public class HostedMatch {
if (game.getRules().getGameType() == GameType.Quest) {
final QuestController qc = FModel.getQuest();
// Reset new list when the Match round starts, not when each game starts
if (game.getMatch().getPlayedGames().isEmpty()) {
if (game.getMatch().getOutcomes().isEmpty()) {
qc.getCards().resetNewList();
}
game.subscribeToEvents(qc); // this one listens to player's mulligans ATM

View File

@@ -269,7 +269,7 @@ public class InputAttack extends InputSyncronizedBase {
combat.addAttacker(card, currentDefender, activeBand);
activateBand(activeBand);
card.getGame().fireEvent(new UiEventAttackerDeclared(
card.getGame().getMatch().fireEvent(new UiEventAttackerDeclared(
CardView.get(card),
GameEntityView.get(currentDefender)));
}
@@ -280,7 +280,7 @@ public class InputAttack extends InputSyncronizedBase {
// When removing an attacker clear the attacking band
activateBand(null);
card.getGame().fireEvent(new UiEventAttackerDeclared(
card.getGame().getMatch().fireEvent(new UiEventAttackerDeclared(
CardView.get(card), null));
return true;
}

View File

@@ -122,7 +122,7 @@ public class InputBlock extends InputSyncronizedBase {
boolean isCorrectAction = false;
if (triggerEvent != null && triggerEvent.getButton() == 3 && card.getController() == defender) {
combat.removeFromCombat(card);
card.getGame().fireEvent(new UiEventBlockerAssigned(CardView.get(card), null));
card.getGame().getMatch().fireEvent(new UiEventBlockerAssigned(CardView.get(card), null));
isCorrectAction = true;
}
else {
@@ -137,14 +137,14 @@ public class InputBlock extends InputSyncronizedBase {
if (combat.isBlocking(card, currentAttacker)) {
//if creature already blocking current attacker, remove blocker from combat
combat.removeBlockAssignment(currentAttacker, card);
card.getGame().fireEvent(new UiEventBlockerAssigned(CardView.get(card), null));
card.getGame().getMatch().fireEvent(new UiEventBlockerAssigned(CardView.get(card), null));
isCorrectAction = true;
}
else {
isCorrectAction = CombatUtil.canBlock(currentAttacker, card, combat);
if (isCorrectAction) {
combat.addBlocker(currentAttacker, card);
card.getGame().fireEvent(new UiEventBlockerAssigned(
card.getGame().getMatch().fireEvent(new UiEventBlockerAssigned(
CardView.get(card),
CardView.get(currentAttacker)));
}

View File

@@ -4,7 +4,6 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import forge.FThreads;
import forge.game.Game;
import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.player.PlayerView;
@@ -17,10 +16,8 @@ public class InputLockUI implements Input {
private final AtomicInteger iCall = new AtomicInteger();
private final InputQueue inputQueue;
private final Game game;
private final PlayerControllerHuman controller;
public InputLockUI(final Game game0, final InputQueue inputQueue0, final PlayerControllerHuman controller) {
game = game0;
public InputLockUI(final InputQueue inputQueue0, final PlayerControllerHuman controller) {
inputQueue = inputQueue0;
this.controller = controller;
}
@@ -90,7 +87,7 @@ public class InputLockUI implements Input {
@Override
public void selectButtonCancel() {
//cancel auto pass for all players
for (final Player player : game.getPlayers()) {
for (final Player player : controller.getGame().getPlayers()) {
player.getController().autoPassCancel();
}
}

View File

@@ -21,7 +21,7 @@ import java.util.Observable;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import forge.game.Game;
import forge.game.GameView;
import forge.player.PlayerControllerHuman;
/**
@@ -34,10 +34,10 @@ import forge.player.PlayerControllerHuman;
*/
public class InputQueue extends Observable {
private final BlockingDeque<InputSynchronized> inputStack = new LinkedBlockingDeque<>();
private final Game game;
private final GameView gameView;
public InputQueue(final Game game, final InputProxy inputProxy) {
this.game = game;
public InputQueue(final GameView gameView, final InputProxy inputProxy) {
this.gameView = gameView;
addObserver(inputProxy);
}
@@ -64,10 +64,10 @@ public class InputQueue extends Observable {
public final Input getActualInput(final PlayerControllerHuman controller) {
final Input topMost = inputStack.peek(); // incoming input to Control
if (topMost != null && !game.isGameOver()) {
if (topMost != null && !gameView.isGameOver()) {
return topMost;
}
return new InputLockUI(game, this, controller);
return new InputLockUI(this, controller);
} // getInput()
// only for debug purposes

View File

@@ -5,6 +5,8 @@ import java.util.*;
import java.util.Map.Entry;
import forge.game.ability.AbilityUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.Range;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -108,7 +110,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
public PlayerControllerHuman(final Game game0, final Player p, final LobbyPlayer lp) {
super(game0, p, lp);
inputProxy = new InputProxy(this);
inputQueue = new InputQueue(game, inputProxy);
inputQueue = new InputQueue(game0.getView(), inputProxy);
}
public PlayerControllerHuman(final Player p, final LobbyPlayer lp, final PlayerControllerHuman owner) {
@@ -268,19 +270,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
// Sideboard rules have changed for M14, just need to consider min
// maindeck and max sideboard sizes
// No longer need 1:1 sideboarding in non-limited formats
Object resp = getGui().sideboard(sideboard, main, message);
if (resp instanceof List<?> &&
!((List) resp).isEmpty() &&
((List) resp).get(0) instanceof PaperCard) {
newMain = (List) resp;
} else if (resp == null) {
// if we got here, the user took too long to reply
newMain = main.toFlatList();
} else {
System.err.println("PlayerControllerHuman.sideboard -- FAILED!");
System.err.println("resp instanceof " + resp.getClass().toString());
System.err.println("resp = " + resp.toString());
}
List<PaperCard> resp = getGui().sideboard(sideboard, main, message);
newMain = ObjectUtils.defaultIfNull(resp, main.toFlatList());
} while (conform && (newMain.size() < deckMinSize || combinedDeckSize - newMain.size() > sbMax));
return newMain;
@@ -667,8 +658,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
if (tos.containsKey(AbilityKey.Card)) {
final Card card = (Card) tos.get(AbilityKey.Card);
if (card != null && (card.getController() == player || game.getZoneOf(card) == null
|| game.getZoneOf(card).getZoneType().isKnown())) {
if (card != null && (card.getController() == player || getGame().getZoneOf(card) == null
|| getGame().getZoneOf(card).getZoneType().isKnown())) {
buildQuestion.append("\n").append(localizer.getMessage("lblTriggeredby")).append(": ").append(tos.get(AbilityKey.Card));
}
}
@@ -680,7 +671,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public Player chooseStartingPlayer(final boolean isFirstGame) {
if (game.getPlayers().size() == 2) {
if (getGame().getPlayers().size() == 2) {
String prompt = null;
if (isFirstGame) {
prompt = localizer.getMessage("lblYouHaveWonTheCoinToss", player.getName());
@@ -702,7 +693,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
prompt += "\n\n" + localizer.getMessage("lblWhoWouldYouLiketoStartthisGame");
final InputSelectEntitiesFromList<Player> input = new InputSelectEntitiesFromList<>(this, 1, 1,
new FCollection<>(game.getPlayersInTurnOrder()));
new FCollection<>(getGame().getPlayersInTurnOrder()));
input.setMessage(prompt);
input.showAndWait();
return input.getFirstSelected();
@@ -920,7 +911,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return cards;
case ForgeConstants.GRAVEYARD_ORDERING_OWN_CARDS:
// Order only if the relevant cards controlled by the player determine the potential necessity for it
if (!game.isGraveyardOrdered(player)) {
if (!getGame().isGraveyardOrdered(player)) {
return cards;
}
break;
@@ -1284,7 +1275,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public List<SpellAbility> chooseSpellAbilityToPlay() {
final MagicStack stack = game.getStack();
final MagicStack stack = getGame().getStack();
if (mayAutoPass()) {
// avoid prompting for input if current phase is set to be
@@ -1295,8 +1286,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
if (stack.isEmpty()) {
// make sure to briefly pause at phases you're not set up to
// skip
if (!getGui().isUiSetToSkipPhase(game.getPhaseHandler().getPlayerTurn().getView(),
game.getPhaseHandler().getPhase())) {
if (!getGui().isUiSetToSkipPhase(getGame().getPhaseHandler().getPlayerTurn().getView(),
getGame().getPhaseHandler().getPhase())) {
delay = FControlGamePlayback.phasesDelay;
}
} else {
@@ -1315,8 +1306,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
if (stack.isEmpty()) {
if (getGui().isUiSetToSkipPhase(game.getPhaseHandler().getPlayerTurn().getView(),
game.getPhaseHandler().getPhase())) {
if (getGui().isUiSetToSkipPhase(getGame().getPhaseHandler().getPlayerTurn().getView(),
getGame().getPhaseHandler().getPhase())) {
return null; // avoid prompt for input if stack is empty and
// player is set to skip the current phase
}
@@ -1502,7 +1493,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
public void notifyOfValue(final SpellAbility sa, final GameObject realtedTarget, final String value) {
final String message = MessageUtil.formatNotificationMessage(sa, player, realtedTarget, value);
if (sa != null && sa.isManaAbility()) {
game.getGameLog().add(GameLogEntryType.LAND, message);
getGame().getGameLog().add(GameLogEntryType.LAND, message);
} else {
getGui().message(message,
sa == null || sa.getHostCard() == null ? "" : CardView.get(sa.getHostCard()).toString());
@@ -1520,14 +1511,14 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public List<AbilitySub> chooseModeForAbility(final SpellAbility sa, List<AbilitySub> possible, final int min, final int num,
boolean allowRepeat) {
boolean trackerFrozen = game.getTracker().isFrozen();
boolean trackerFrozen = getGame().getTracker().isFrozen();
if (trackerFrozen) {
// The view tracker needs to be unfrozen to update the SpellAbilityViews at this point, or it may crash
game.getTracker().unfreeze();
getGame().getTracker().unfreeze();
}
Map<SpellAbilityView, AbilitySub> spellViewCache = SpellAbilityView.getMap(possible);
if (trackerFrozen) {
game.getTracker().freeze(); // refreeze if the tracker was frozen prior to this update
getGame().getTracker().freeze(); // refreeze if the tracker was frozen prior to this update
}
final List<SpellAbilityView> choices = Lists.newArrayList(spellViewCache.keySet());
final String modeTitle = localizer.getMessage("lblPlayerActivatedCardChooseMode", sa.getActivatingPlayer().toString(), CardTranslation.getTranslatedName(sa.getHostCard().getName()));
@@ -1892,10 +1883,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
public boolean canUndoLastAction() {
if (!game.stack.canUndo(player)) {
if (!getGame().stack.canUndo(player)) {
return false;
}
final Player priorityPlayer = game.getPhaseHandler().getPriorityPlayer();
final Player priorityPlayer = getGame().getPhaseHandler().getPriorityPlayer();
return priorityPlayer != null && priorityPlayer == player;
}
@@ -1909,7 +1900,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return false;
}
if (game.getStack().undo()) {
if (getGame().getStack().undo()) {
final Input currentInput = inputQueue.getInput();
if (currentInput instanceof InputPassPriority) {
// ensure prompt updated if needed
@@ -2055,7 +2046,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public void setViewAllCards(final boolean canViewAll) {
mayLookAtAllCards = canViewAll;
for (final Player p : game.getPlayers()) {
for (final Player p : getGame().getPlayers()) {
getGui().updateCards(CardView.getCollection(p.getAllCards()));
}
}
@@ -2067,18 +2058,18 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void generateMana() {
final Player pPriority = game.getPhaseHandler().getPriorityPlayer();
final Player pPriority = getGame().getPhaseHandler().getPriorityPlayer();
if (pPriority == null) {
getGui().message(localizer.getMessage("lblNoPlayerHasPriorityCannotAddedManaToPool"));
return;
}
final Card dummy = new Card(-777777, game);
final Card dummy = new Card(-777777, getGame());
dummy.setOwner(pPriority);
final Map<String, String> produced = Maps.newHashMap();
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
game.getAction().invoke(new Runnable() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
abMana.produceMana(null);
@@ -2104,7 +2095,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
public void dumpGameState() {
final GameState state = createGameStateObject();
try {
state.initFromGame(game);
state.initFromGame(getGame());
final File f = GuiBase.getInterface().getSaveFile(new File(ForgeConstants.USER_GAMES_DIR, "state.txt"));
if (f != null
&& (!f.exists() || getGui().showConfirmDialog(localizer.getMessage("lblOverwriteExistFileConfirm"), localizer.getMessage("lblFileExists")))) {
@@ -2154,12 +2145,12 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return;
}
final Player pPriority = game.getPhaseHandler().getPriorityPlayer();
final Player pPriority = getGame().getPhaseHandler().getPriorityPlayer();
if (pPriority == null) {
getGui().message(localizer.getMessage("lblNoPlayerPriorityGameStateCannotBeSetup"));
return;
}
state.applyToGame(game);
state.applyToGame(getGame());
}
/*
@@ -2169,7 +2160,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void tutorForCard() {
final Player pPriority = game.getPhaseHandler().getPriorityPlayer();
final Player pPriority = getGame().getPhaseHandler().getPriorityPlayer();
if (pPriority == null) {
getGui().message(localizer.getMessage("lblNoPlayerPriorityDeckCantBeTutoredFrom"));
return;
@@ -2178,17 +2169,17 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
final CardCollection lib = (CardCollection) pPriority.getCardsIn(ZoneType.Library);
final List<ZoneType> origin = Lists.newArrayList();
origin.add(ZoneType.Library);
final SpellAbility sa = new SpellAbility.EmptySa(new Card(-1, game));
final SpellAbility sa = new SpellAbility.EmptySa(new Card(-1, getGame()));
final Card card = chooseSingleCardForZoneChange(ZoneType.Hand, origin, sa, lib, null, localizer.getMessage("lblChooseaCard"), true,
pPriority);
if (card == null) {
return;
}
game.getAction().invoke(new Runnable() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
game.getAction().moveToHand(card, null);
getGame().getAction().moveToHand(card, null);
}
});
}
@@ -2216,7 +2207,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
public void modifyCountersOnPermanent(boolean subtract) {
final String titleMsg = subtract ? localizer.getMessage("lblRemoveCountersFromWhichCard") : localizer.getMessage("lblAddCountersToWhichCard");
GameEntityViewMap<Card, CardView> gameCacheCounters = GameEntityView.getMap(game.getCardsIn(ZoneType.Battlefield));
GameEntityViewMap<Card, CardView> gameCacheCounters = GameEntityView.getMap(getGame().getCardsIn(ZoneType.Battlefield));
final CardView cv = getGui().oneOrNone(titleMsg, gameCacheCounters.getTrackableKeys());
if (cv == null || !gameCacheCounters.containsKey(cv)) {
@@ -2257,10 +2248,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void tapPermanents() {
game.getAction().invoke(new Runnable() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
final CardCollectionView untapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield),
final CardCollectionView untapped = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield),
Predicates.not(CardPredicates.Presets.TAPPED));
final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0,
Integer.MAX_VALUE, untapped);
@@ -2283,10 +2274,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void untapPermanents() {
game.getAction().invoke(new Runnable() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
final CardCollectionView tapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield),
final CardCollectionView tapped = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield),
CardPredicates.Presets.TAPPED);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0,
Integer.MAX_VALUE, tapped);
@@ -2310,7 +2301,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public void setPlayerLife() {
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(game.getPlayers());
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
final PlayerView pv = getGui().oneOrNone(localizer.getMessage("lblSetLifeforWhichPlayer"), gameCachePlayer.getTrackableKeys());
if (pv == null || !gameCachePlayer.containsKey(pv)) {
@@ -2341,7 +2332,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
// set life of all other players to 0
final LobbyPlayer guiPlayer = getLobbyPlayer();
final FCollectionView<Player> players = game.getPlayers();
final FCollectionView<Player> players = getGame().getPlayers();
for (final Player player : players) {
if (player.getLobbyPlayer() != guiPlayer) {
player.setLife(0, null);
@@ -2446,7 +2437,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return;
}
} else {
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(game.getPlayers());
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
PlayerView pv = getGui().oneOrNone(message, gameCachePlayer.getTrackableKeys());
if (pv == null || !gameCachePlayer.containsKey(pv)) {
return;
@@ -2468,9 +2459,9 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
final PaperCard c = carddb.getUniqueByName(f.getName());
final Card forgeCard = Card.fromPaperCard(c, p);
forgeCard.setTimestamp(game.getNextTimestamp());
forgeCard.setTimestamp(getGame().getNextTimestamp());
game.getAction().invoke(new Runnable() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
if (targetZone == ZoneType.Battlefield) {
@@ -2486,7 +2477,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
}
}
game.getAction().moveTo(targetZone, forgeCard, null);
getGame().getAction().moveTo(targetZone, forgeCard, null);
if (forgeCard.isCreature()) {
forgeCard.setSickness(lastSummoningSickness);
}
@@ -2497,10 +2488,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
} else {
if (c.getRules().getType().isLand()) {
// this is needed to ensure land abilities fire
game.getAction().moveToHand(forgeCard, null);
game.getAction().moveToPlay(forgeCard, null);
getGame().getAction().moveToHand(forgeCard, null);
getGame().getAction().moveToPlay(forgeCard, null);
// ensure triggered abilities fire
game.getTriggerHandler().runWaitingTriggers();
getGame().getTriggerHandler().runWaitingTriggers();
} else {
final FCollectionView<SpellAbility> choices = forgeCard.getBasicSpells();
if (choices.isEmpty()) {
@@ -2520,14 +2511,14 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
lastAddedSA = sa;
// this is really needed (for rollbacks at least)
game.getAction().moveToHand(forgeCard, null);
getGame().getAction().moveToHand(forgeCard, null);
// Human player is choosing targets for an ability
// controlled by chosen player.
sa.setActivatingPlayer(p);
HumanPlay.playSaWithoutPayingManaCost(PlayerControllerHuman.this, game, sa, true);
HumanPlay.playSaWithoutPayingManaCost(PlayerControllerHuman.this, getGame(), sa, true);
}
// playSa could fire some triggers
game.getStack().addAllTriggeredAbilitiesToStack();
getGame().getStack().addAllTriggeredAbilitiesToStack();
}
} else if (targetZone == ZoneType.Library) {
if (!repeatLast) {
@@ -2535,12 +2526,12 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
true, Arrays.asList(localizer.getMessage("lblTop"), localizer.getMessage("lblBottom")));
}
if (lastTopOfTheLibrary) {
game.getAction().moveToLibrary(forgeCard, null);
getGame().getAction().moveToLibrary(forgeCard, null);
} else {
game.getAction().moveToBottomOfLibrary(forgeCard, null);
getGame().getAction().moveToBottomOfLibrary(forgeCard, null);
}
} else {
game.getAction().moveTo(targetZone, forgeCard, null);
getGame().getAction().moveTo(targetZone, forgeCard, null);
}
lastAdded = f;
@@ -2558,7 +2549,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void exileCardsFromHand() {
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(game.getPlayers());
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
final PlayerView pv = getGui().oneOrNone(localizer.getMessage("lblExileCardsFromPlayerHandConfirm"),
gameCachePlayer.getTrackableKeys());
@@ -2579,12 +2570,12 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
if (c == null) {
continue;
}
if (game.getAction().moveTo(ZoneType.Exile, c, null) != null) {
if (getGame().getAction().moveTo(ZoneType.Exile, c, null) != null) {
StringBuilder sb = new StringBuilder();
sb.append(p).append(" exiles ").append(c).append(" due to Dev Cheats.");
game.getGameLog().add(GameLogEntryType.DISCARD, sb.toString());
getGame().getGameLog().add(GameLogEntryType.DISCARD, sb.toString());
} else {
game.getGameLog().add(GameLogEntryType.INFORMATION, "DISCARD CHEAT ERROR");
getGame().getGameLog().add(GameLogEntryType.INFORMATION, "DISCARD CHEAT ERROR");
}
}
}
@@ -2596,7 +2587,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void exileCardsFromBattlefield() {
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(game.getPlayers());
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
final PlayerView pv = getGui().oneOrNone(localizer.getMessage("lblExileCardsFromPlayerBattlefieldConfirm"),
gameCachePlayer.getTrackableKeys());
@@ -2617,12 +2608,12 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
if (c == null) {
continue;
}
if (game.getAction().moveTo(ZoneType.Exile, c, null) != null) {
if (getGame().getAction().moveTo(ZoneType.Exile, c, null) != null) {
StringBuilder sb = new StringBuilder();
sb.append(p).append(" exiles ").append(c).append(" due to Dev Cheats.");
game.getGameLog().add(GameLogEntryType.ZONE_CHANGE, sb.toString());
getGame().getGameLog().add(GameLogEntryType.ZONE_CHANGE, sb.toString());
} else {
game.getGameLog().add(GameLogEntryType.INFORMATION, "EXILE FROM PLAY CHEAT ERROR");
getGame().getGameLog().add(GameLogEntryType.INFORMATION, "EXILE FROM PLAY CHEAT ERROR");
}
}
}
@@ -2634,7 +2625,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void removeCardsFromGame() {
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(game.getPlayers());
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
final PlayerView pv = getGui().oneOrNone(localizer.getMessage("lblRemoveCardBelongingWitchPlayer"),
gameCachePlayer.getTrackableKeys());
@@ -2663,7 +2654,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
StringBuilder sb = new StringBuilder();
sb.append(p).append(" removes ").append(c).append(" from game due to Dev Cheats.");
game.getGameLog().add(GameLogEntryType.ZONE_CHANGE, sb.toString());
getGame().getGameLog().add(GameLogEntryType.ZONE_CHANGE, sb.toString());
}
}
@@ -2674,7 +2665,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void riggedPlanarRoll() {
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(game.getPlayers());
GameEntityViewMap<Player, PlayerView> gameCachePlayer = GameEntityView.getMap(getGame().getPlayers());
final PlayerView pv = getGui().oneOrNone(localizer.getMessage("lblWhichPlayerShouldRoll"), gameCachePlayer.getTrackableKeys());
if (pv == null || !gameCachePlayer.containsKey(pv)) {
@@ -2689,7 +2680,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
System.out.println("Rigging planar dice roll: " + res.toString());
game.getAction().invoke(new Runnable() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
PlanarDice.roll(player, res);
@@ -2704,10 +2695,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
*/
@Override
public void planeswalkTo() {
if (!game.getRules().hasAppliedVariant(GameType.Planechase)) {
if (!getGame().getRules().hasAppliedVariant(GameType.Planechase)) {
return;
}
final Player p = game.getPhaseHandler().getPlayerTurn();
final Player p = getGame().getPhaseHandler().getPlayerTurn();
final List<PaperCard> allPlanars = Lists.newArrayList();
for (final PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) {
@@ -2725,10 +2716,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
final Card forgeCard = Card.fromPaperCard(c, p);
forgeCard.setOwner(p);
game.getAction().invoke(new Runnable() {
getGame().getAction().invoke(new Runnable() {
@Override
public void run() {
game.getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0, null);
getGame().getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0, null);
PlanarDice.roll(p, PlanarDice.Planeswalk);
}
});
@@ -2779,7 +2770,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
// the parsing
// process, and this implementation is still a "proof of concept".
int opponentID = 0;
for (final Player player : game.getPlayers()) {
for (final Player player : getGame().getPlayers()) {
if (player.getId() != playerID) {
opponentID = player.getId();
break;
@@ -2840,14 +2831,14 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
// Fetch cards and players specified by the user input
final ZoneType[] zones = { ZoneType.Battlefield, ZoneType.Hand, ZoneType.Graveyard, ZoneType.Exile,
ZoneType.Command };
final CardCollectionView cards = game.getCardsIn(Arrays.asList(zones));
final CardCollectionView cards = getGame().getCardsIn(Arrays.asList(zones));
for (final Pair<Integer, Boolean> entity : entityInfo) {
boolean found = false;
// Nested loops are no fun; however, seems there's no better way
// to get stuff by ID
boolean isPlayer = entity.getValue();
if (isPlayer) {
for (final Player player : game.getPlayers()) {
for (final Player player : getGame().getPlayers()) {
if (player.getId() == entity.getKey()) {
found = true;
rememberedActions.add(Pair.of(player.getView(), true));
@@ -2943,7 +2934,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override
public void nextGameDecision(final NextGameDecision decision) {
game.fireEvent(new UiEventNextGameDecision(this, decision));
gameView.getMatch().fireEvent(new UiEventNextGameDecision(this, decision));
}
@Override