|
|
|
|
@@ -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
|
|
|
|
|
|