mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Refactor dev mode cheat functions into separate class that through it's restricted access allows determining if a player as cheated during a game
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -17080,7 +17080,6 @@ forge-gui/src/main/java/forge/sound/SoundEffectType.java -text
|
|||||||
forge-gui/src/main/java/forge/sound/SoundSystem.java -text
|
forge-gui/src/main/java/forge/sound/SoundSystem.java -text
|
||||||
forge-gui/src/main/java/forge/util/Base64Coder.java svneol=native#text/plain
|
forge-gui/src/main/java/forge/util/Base64Coder.java svneol=native#text/plain
|
||||||
forge-gui/src/main/java/forge/util/Callback.java -text
|
forge-gui/src/main/java/forge/util/Callback.java -text
|
||||||
forge-gui/src/main/java/forge/util/DevModeUtil.java -text
|
|
||||||
forge-gui/src/main/java/forge/util/Evaluator.java -text
|
forge-gui/src/main/java/forge/util/Evaluator.java -text
|
||||||
forge-gui/src/main/java/forge/util/GuiDisplayUtil.java -text
|
forge-gui/src/main/java/forge/util/GuiDisplayUtil.java -text
|
||||||
forge-gui/src/main/java/forge/util/HttpUtil.java svneol=native#text/plain
|
forge-gui/src/main/java/forge/util/HttpUtil.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -185,8 +185,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
private boolean isPlayingExtraTrun = false;
|
private boolean isPlayingExtraTrun = false;
|
||||||
|
|
||||||
public boolean canCheatPlayUnlimitedLands = false;
|
|
||||||
|
|
||||||
private List<Card> lostOwnership = new ArrayList<Card>();
|
private List<Card> lostOwnership = new ArrayList<Card>();
|
||||||
private List<Card> gainedOwnership = new ArrayList<Card>();
|
private List<Card> gainedOwnership = new ArrayList<Card>();
|
||||||
|
|
||||||
@@ -1923,7 +1921,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
// **** Check for land play limit per turn ****
|
// **** Check for land play limit per turn ****
|
||||||
// Dev Mode
|
// Dev Mode
|
||||||
if (this.canCheatPlayUnlimitedLands || this.hasKeyword("You may play any number of additional lands on each of your turns.")) {
|
if (this.getController().canPlayUnlimitedLands() || this.hasKeyword("You may play any number of additional lands on each of your turns.")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,10 +215,11 @@ public abstract class PlayerController {
|
|||||||
public abstract List<SpellAbility> chooseSaToActivateFromOpeningHand(List<SpellAbility> usableFromOpeningHand);
|
public abstract List<SpellAbility> chooseSaToActivateFromOpeningHand(List<SpellAbility> usableFromOpeningHand);
|
||||||
public abstract Mana chooseManaFromPool(List<Mana> manaChoices);
|
public abstract Mana chooseManaFromPool(List<Mana> manaChoices);
|
||||||
|
|
||||||
|
public abstract String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes, boolean isOptional);
|
||||||
public final String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes) {
|
public final String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes) {
|
||||||
return chooseSomeType(kindOfType, sa, validTypes, invalidTypes, false);
|
return chooseSomeType(kindOfType, sa, validTypes, invalidTypes, false);
|
||||||
}
|
}
|
||||||
public abstract String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes, boolean isOptional);
|
|
||||||
public abstract Object vote(SpellAbility sa, String prompt, List<Object> options, ArrayListMultimap<Object, Player> votes);
|
public abstract Object vote(SpellAbility sa, String prompt, List<Object> options, ArrayListMultimap<Object, Player> votes);
|
||||||
public abstract Pair<CounterType,String> chooseAndRemoveOrPutCounter(Card cardWithCounter);
|
public abstract Pair<CounterType,String> chooseAndRemoveOrPutCounter(Card cardWithCounter);
|
||||||
public abstract boolean confirmReplacementEffect(ReplacementEffect replacementEffect, SpellAbility effectSA, String question);
|
public abstract boolean confirmReplacementEffect(ReplacementEffect replacementEffect, SpellAbility effectSA, String question);
|
||||||
@@ -286,4 +287,8 @@ public abstract class PlayerController {
|
|||||||
public boolean isGuiPlayer() {
|
public boolean isGuiPlayer() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canPlayUnlimitedLands() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ public enum CDev implements ICDoc {
|
|||||||
public void togglePlayManyLandsPerTurn() {
|
public void togglePlayManyLandsPerTurn() {
|
||||||
boolean newValue = !VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().getToggled();
|
boolean newValue = !VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().getToggled();
|
||||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(newValue);
|
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(newValue);
|
||||||
Singletons.getControl().getGameView().devSetUnlimitedLands(newValue);
|
Singletons.getControl().getGameView().cheat().setCanPlayUnlimitedLands(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madMana = new MouseAdapter() {
|
private final MouseListener madMana = new MouseAdapter() {
|
||||||
@@ -37,7 +37,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void generateMana() {
|
public void generateMana() {
|
||||||
Singletons.getControl().getGameView().devGenerateMana();
|
Singletons.getControl().getGameView().cheat().generateMana();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madSetup = new MouseAdapter() {
|
private final MouseListener madSetup = new MouseAdapter() {
|
||||||
@@ -47,7 +47,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void setupGameState() {
|
public void setupGameState() {
|
||||||
Singletons.getControl().getGameView().devSetupGameState();
|
Singletons.getControl().getGameView().cheat().setupGameState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madTutor = new MouseAdapter() {
|
private final MouseListener madTutor = new MouseAdapter() {
|
||||||
@@ -57,7 +57,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void tutorForCard() {
|
public void tutorForCard() {
|
||||||
Singletons.getControl().getGameView().devTutorForCard();
|
Singletons.getControl().getGameView().cheat().tutorForCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madCardToHand = new MouseAdapter() {
|
private final MouseListener madCardToHand = new MouseAdapter() {
|
||||||
@@ -67,7 +67,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void addCardToHand() {
|
public void addCardToHand() {
|
||||||
Singletons.getControl().getGameView().devAddCardToHand();
|
Singletons.getControl().getGameView().cheat().addCardToHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madCounter = new MouseAdapter() {
|
private final MouseListener madCounter = new MouseAdapter() {
|
||||||
@@ -77,7 +77,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void addCounterToPermanent() {
|
public void addCounterToPermanent() {
|
||||||
Singletons.getControl().getGameView().devAddCounterToPermanent();
|
Singletons.getControl().getGameView().cheat().addCountersToPermanent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madTap = new MouseAdapter() {
|
private final MouseListener madTap = new MouseAdapter() {
|
||||||
@@ -87,7 +87,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void tapPermanent() {
|
public void tapPermanent() {
|
||||||
Singletons.getControl().getGameView().devTapPermanent();
|
Singletons.getControl().getGameView().cheat().tapPermanents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madUntap = new MouseAdapter() {
|
private final MouseListener madUntap = new MouseAdapter() {
|
||||||
@@ -97,7 +97,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void untapPermanent() {
|
public void untapPermanent() {
|
||||||
Singletons.getControl().getGameView().devUntapPermanent();
|
Singletons.getControl().getGameView().cheat().untapPermanents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madLife = new MouseAdapter() {
|
private final MouseListener madLife = new MouseAdapter() {
|
||||||
@@ -107,7 +107,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void setPlayerLife() {
|
public void setPlayerLife() {
|
||||||
Singletons.getControl().getGameView().devSetPlayerLife();
|
Singletons.getControl().getGameView().cheat().setPlayerLife();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madWinGame = new MouseAdapter() {
|
private final MouseListener madWinGame = new MouseAdapter() {
|
||||||
@@ -117,7 +117,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void winGame() {
|
public void winGame() {
|
||||||
Singletons.getControl().getGameView().devWinGame();
|
Singletons.getControl().getGameView().cheat().winGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madCardToBattlefield = new MouseAdapter() {
|
private final MouseListener madCardToBattlefield = new MouseAdapter() {
|
||||||
@@ -127,7 +127,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void addCardToBattlefield() {
|
public void addCardToBattlefield() {
|
||||||
Singletons.getControl().getGameView().devAddCardToBattlefield();
|
Singletons.getControl().getGameView().cheat().addCardToBattlefield();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madRiggedRoll = new MouseAdapter() {
|
private final MouseListener madRiggedRoll = new MouseAdapter() {
|
||||||
@@ -137,7 +137,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void riggedPlanerRoll() {
|
public void riggedPlanerRoll() {
|
||||||
Singletons.getControl().getGameView().devRiggedPlanerRoll();
|
Singletons.getControl().getGameView().cheat().riggedPlanarRoll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MouseListener madWalkToPlane = new MouseAdapter() {
|
private final MouseListener madWalkToPlane = new MouseAdapter() {
|
||||||
@@ -147,7 +147,7 @@ public enum CDev implements ICDoc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public void planeswalkTo() {
|
public void planeswalkTo() {
|
||||||
Singletons.getControl().getGameView().devPlaneswalkTo();
|
Singletons.getControl().getGameView().cheat().planeswalkTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
//========== End mouse listener inits
|
//========== End mouse listener inits
|
||||||
@@ -186,6 +186,6 @@ public enum CDev implements ICDoc {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(Singletons.getControl().getGameView().devGetUnlimitedLands());
|
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(Singletons.getControl().getGameView().canPlayUnlimitedLands());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class DevModeMenu implements ActionListener {
|
|||||||
menu.add(getMenuItem(DevMenuItem.WIN_GAME));
|
menu.add(getMenuItem(DevMenuItem.WIN_GAME));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.add(getMenuItem(DevMenuItem.SETUP_GAME_STATE));
|
menu.add(getMenuItem(DevMenuItem.SETUP_GAME_STATE));
|
||||||
menu.add(getCheckboxMenuItem(DevMenuItem.PLAY_UNLIMITED_LANDS, Singletons.getControl().getGameView().devGetUnlimitedLands()));
|
menu.add(getCheckboxMenuItem(DevMenuItem.PLAY_UNLIMITED_LANDS, Singletons.getControl().getGameView().canPlayUnlimitedLands()));
|
||||||
menu.add(getMenuItem(DevMenuItem.ADD_COUNTER));
|
menu.add(getMenuItem(DevMenuItem.ADD_COUNTER));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.add(getMenuItem(DevMenuItem.TAP_PERMANENT));
|
menu.add(getMenuItem(DevMenuItem.TAP_PERMANENT));
|
||||||
|
|||||||
@@ -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
|
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke all these in game thread since they may require synchronous user input
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devGenerateMana();
|
FControl.getGameView().cheat().generateMana();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devTutorForCard();
|
FControl.getGameView().cheat().tutorForCard();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devAddCardToHand();
|
FControl.getGameView().cheat().addCardToHand();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devAddCardToBattlefield();
|
FControl.getGameView().cheat().addCardToBattlefield();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devSetPlayerLife();
|
FControl.getGameView().cheat().setPlayerLife();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devWinGame();
|
FControl.getGameView().cheat().winGame();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -83,18 +83,18 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devSetupGameState();
|
FControl.getGameView().cheat().setupGameState();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
final boolean unlimitedLands = FControl.getGameView().devGetUnlimitedLands();
|
final boolean unlimitedLands = FControl.getGameView().canPlayUnlimitedLands();
|
||||||
addItem(new FCheckBoxMenuItem("Play Unlimited Lands", unlimitedLands,
|
addItem(new FCheckBoxMenuItem("Play Unlimited Lands", unlimitedLands,
|
||||||
new FEventHandler() {
|
new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
FControl.getGameView().devSetUnlimitedLands(!unlimitedLands);
|
FControl.getGameView().cheat().setCanPlayUnlimitedLands(!unlimitedLands);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
addItem(new FMenuItem("Add Counters to Permanent", new FEventHandler() {
|
addItem(new FMenuItem("Add Counters to Permanent", new FEventHandler() {
|
||||||
@@ -103,7 +103,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devAddCounterToPermanent();
|
FControl.getGameView().cheat().addCountersToPermanent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devTapPermanent();
|
FControl.getGameView().cheat().tapPermanents();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devUntapPermanent();
|
FControl.getGameView().cheat().untapPermanents();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devRiggedPlanerRoll();
|
FControl.getGameView().cheat().riggedPlanarRoll();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FControl.getGameView().devPlaneswalkTo();
|
FControl.getGameView().cheat().planeswalkTo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
package forge.player;
|
package forge.player;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -16,6 +23,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@@ -24,6 +32,7 @@ import com.google.common.collect.Multimap;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import forge.LobbyPlayer;
|
import forge.LobbyPlayer;
|
||||||
|
import forge.card.CardCharacteristicName;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
@@ -39,8 +48,11 @@ import forge.game.GameLogEntryType;
|
|||||||
import forge.game.GameObject;
|
import forge.game.GameObject;
|
||||||
import forge.game.GameOutcome;
|
import forge.game.GameOutcome;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
|
import forge.game.PlanarDice;
|
||||||
import forge.game.ability.effects.CharmEffect;
|
import forge.game.ability.effects.CharmEffect;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.game.card.CardLists;
|
||||||
|
import forge.game.card.CardPredicates;
|
||||||
import forge.game.card.CardShields;
|
import forge.game.card.CardShields;
|
||||||
import forge.game.card.CounterType;
|
import forge.game.card.CounterType;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
@@ -54,16 +66,19 @@ import forge.game.player.Player;
|
|||||||
import forge.game.player.PlayerActionConfirmMode;
|
import forge.game.player.PlayerActionConfirmMode;
|
||||||
import forge.game.player.PlayerController;
|
import forge.game.player.PlayerController;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
|
import forge.game.spellability.AbilityManaPart;
|
||||||
import forge.game.spellability.AbilitySub;
|
import forge.game.spellability.AbilitySub;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.SpellAbilityStackInstance;
|
import forge.game.spellability.SpellAbilityStackInstance;
|
||||||
import forge.game.spellability.TargetChoices;
|
import forge.game.spellability.TargetChoices;
|
||||||
import forge.game.trigger.Trigger;
|
import forge.game.trigger.Trigger;
|
||||||
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.trigger.WrappedAbility;
|
import forge.game.trigger.WrappedAbility;
|
||||||
import forge.game.zone.MagicStack;
|
import forge.game.zone.MagicStack;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.interfaces.IGuiBase;
|
import forge.interfaces.IGuiBase;
|
||||||
|
import forge.item.IPaperCard;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.match.input.ButtonUtil;
|
import forge.match.input.ButtonUtil;
|
||||||
import forge.match.input.Input;
|
import forge.match.input.Input;
|
||||||
@@ -80,8 +95,8 @@ import forge.match.input.InputSelectCardsForConvoke;
|
|||||||
import forge.match.input.InputSelectCardsFromList;
|
import forge.match.input.InputSelectCardsFromList;
|
||||||
import forge.match.input.InputSelectEntitiesFromList;
|
import forge.match.input.InputSelectEntitiesFromList;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
|
import forge.properties.ForgeConstants;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
import forge.util.DevModeUtil;
|
|
||||||
import forge.util.ITriggerEvent;
|
import forge.util.ITriggerEvent;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
@@ -1318,16 +1333,14 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
/*
|
/*
|
||||||
* What follows are the View methods.
|
* What follows are the View methods.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private class GameView extends LocalGameView {
|
private class GameView extends LocalGameView {
|
||||||
|
|
||||||
public GameView(Game game) {
|
public GameView(Game game) {
|
||||||
super(game);
|
super(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameOutcome.AnteResult getAnteResult() {
|
public GameOutcome.AnteResult getAnteResult() {
|
||||||
return this.getGame().getOutcome().anteResult.get(player);
|
return game.getOutcome().anteResult.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAchievements() {
|
public void updateAchievements() {
|
||||||
@@ -1449,64 +1462,6 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
return card == null || !c.isFaceDown() || card.canCardFaceBeShownTo(player);
|
return card == null || !c.isFaceDown() || card.canCardFaceBeShownTo(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dev mode functions
|
|
||||||
@Override
|
|
||||||
public boolean devGetUnlimitedLands() {
|
|
||||||
return player.canCheatPlayUnlimitedLands;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devSetUnlimitedLands(final boolean b) {
|
|
||||||
player.canCheatPlayUnlimitedLands = b;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devGenerateMana() {
|
|
||||||
DevModeUtil.devModeGenerateMana(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devSetupGameState() {
|
|
||||||
DevModeUtil.devSetupGameState(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devTutorForCard() {
|
|
||||||
DevModeUtil.devModeTutor(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devAddCardToHand() {
|
|
||||||
DevModeUtil.devModeCardToHand(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devAddCounterToPermanent() {
|
|
||||||
DevModeUtil.devModeAddCounter(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devTapPermanent() {
|
|
||||||
DevModeUtil.devModeTapPerm(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devUntapPermanent() {
|
|
||||||
DevModeUtil.devModeUntapPerm(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devSetPlayerLife() {
|
|
||||||
DevModeUtil.devModeSetLife(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devWinGame() {
|
|
||||||
DevModeUtil.devModeWinGame(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devAddCardToBattlefield() {
|
|
||||||
DevModeUtil.devModeCardToBattlefield(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devRiggedPlanerRoll() {
|
|
||||||
DevModeUtil.devModeRiggedPlanarRoll(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devPlaneswalkTo() {
|
|
||||||
DevModeUtil.devModePlaneswalkTo(game, PlayerControllerHuman.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<String> getAutoYields() {
|
public Iterable<String> getAutoYields() {
|
||||||
return PlayerControllerHuman.this.getAutoYields();
|
return PlayerControllerHuman.this.getAutoYields();
|
||||||
@@ -1564,6 +1519,16 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
public void autoPassCancel() {
|
public void autoPassCancel() {
|
||||||
PlayerControllerHuman.this.autoPassCancel();
|
PlayerControllerHuman.this.autoPassCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayUnlimitedLands() {
|
||||||
|
return PlayerControllerHuman.this.canPlayUnlimitedLands();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DevModeCheats cheat() {
|
||||||
|
return PlayerControllerHuman.this.cheat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1715,4 +1680,447 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
// Not used by the human controller
|
// Not used by the human controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Dev Mode cheat functions
|
||||||
|
private DevModeCheats cheats;
|
||||||
|
private boolean canPlayUnlimitedLands;
|
||||||
|
public DevModeCheats cheat() {
|
||||||
|
if (cheats == null) {
|
||||||
|
cheats = new DevModeCheats();
|
||||||
|
//TODO: In Network game, inform other players that this player is cheating
|
||||||
|
}
|
||||||
|
return cheats;
|
||||||
|
}
|
||||||
|
public boolean hasCheated() {
|
||||||
|
return cheats != null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean canPlayUnlimitedLands() {
|
||||||
|
return canPlayUnlimitedLands;
|
||||||
|
}
|
||||||
|
public class DevModeCheats {
|
||||||
|
private DevModeCheats() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCanPlayUnlimitedLands(boolean canPlayUnlimitedLands0) {
|
||||||
|
canPlayUnlimitedLands = canPlayUnlimitedLands0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateMana() {
|
||||||
|
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||||
|
if (pPriority == null) {
|
||||||
|
SGuiDialog.message(getGui(), "No player has priority at the moment, so mana cannot be added to their pool.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Card dummy = new Card(-777777);
|
||||||
|
dummy.setOwner(pPriority);
|
||||||
|
Map<String, String> produced = new HashMap<String, String>();
|
||||||
|
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
||||||
|
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
||||||
|
game.getAction().invoke(new Runnable() {
|
||||||
|
@Override public void run() { abMana.produceMana(null); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupGameState() {
|
||||||
|
int humanLife = -1;
|
||||||
|
int computerLife = -1;
|
||||||
|
|
||||||
|
final Map<ZoneType, String> humanCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
||||||
|
final Map<ZoneType, String> aiCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
||||||
|
|
||||||
|
String tChangePlayer = "NONE";
|
||||||
|
String tChangePhase = "NONE";
|
||||||
|
|
||||||
|
File gamesDir = new File(ForgeConstants.USER_GAMES_DIR);
|
||||||
|
if (!gamesDir.exists()) { // if the directory does not exist, try to create it
|
||||||
|
gamesDir.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
String filename = getGui().showFileDialog("Select Game State File", ForgeConstants.USER_GAMES_DIR);
|
||||||
|
if (filename == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final FileInputStream fstream = new FileInputStream(filename);
|
||||||
|
final DataInputStream in = new DataInputStream(fstream);
|
||||||
|
final BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||||
|
|
||||||
|
String temp = "";
|
||||||
|
|
||||||
|
while ((temp = br.readLine()) != null) {
|
||||||
|
|
||||||
|
final String[] tempData = temp.split("=");
|
||||||
|
if (tempData.length < 2 || temp.charAt(0) == '#') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String categoryName = tempData[0].toLowerCase();
|
||||||
|
final String categoryValue = tempData[1];
|
||||||
|
|
||||||
|
if (categoryName.equals("humanlife")) humanLife = Integer.parseInt(categoryValue);
|
||||||
|
else if (categoryName.equals("ailife")) computerLife = Integer.parseInt(categoryValue);
|
||||||
|
|
||||||
|
else if (categoryName.equals("activeplayer")) tChangePlayer = categoryValue.trim().toLowerCase();
|
||||||
|
else if (categoryName.equals("activephase")) tChangePhase = categoryValue;
|
||||||
|
|
||||||
|
else if (categoryName.equals("humancardsinplay")) humanCardTexts.put(ZoneType.Battlefield, categoryValue);
|
||||||
|
else if (categoryName.equals("aicardsinplay")) aiCardTexts.put(ZoneType.Battlefield, categoryValue);
|
||||||
|
else if (categoryName.equals("humancardsinhand")) humanCardTexts.put(ZoneType.Hand, categoryValue);
|
||||||
|
else if (categoryName.equals("aicardsinhand")) aiCardTexts.put(ZoneType.Hand, categoryValue);
|
||||||
|
else if (categoryName.equals("humancardsingraveyard")) humanCardTexts.put(ZoneType.Graveyard, categoryValue);
|
||||||
|
else if (categoryName.equals("aicardsingraveyard")) aiCardTexts.put(ZoneType.Graveyard, categoryValue);
|
||||||
|
else if (categoryName.equals("humancardsinlibrary")) humanCardTexts.put(ZoneType.Library, categoryValue);
|
||||||
|
else if (categoryName.equals("aicardsinlibrary")) aiCardTexts.put(ZoneType.Library, categoryValue);
|
||||||
|
else if (categoryName.equals("humancardsinexile")) humanCardTexts.put(ZoneType.Exile, categoryValue);
|
||||||
|
else if (categoryName.equals("aicardsinexile")) aiCardTexts.put(ZoneType.Exile, categoryValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (final FileNotFoundException fnfe) {
|
||||||
|
SOptionPane.showErrorDialog(getGui(), "File not found: " + filename);
|
||||||
|
}
|
||||||
|
catch (final Exception e) {
|
||||||
|
SOptionPane.showErrorDialog(getGui(), "Error loading battle setup file!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setupGameState(humanLife, computerLife, humanCardTexts, aiCardTexts, tChangePlayer, tChangePhase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupGameState(final int humanLife, final int computerLife, final Map<ZoneType, String> humanCardTexts,
|
||||||
|
final Map<ZoneType, String> aiCardTexts, final String tChangePlayer, final String tChangePhase) {
|
||||||
|
|
||||||
|
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||||
|
if (pPriority == null) {
|
||||||
|
SGuiDialog.message(getGui(), "No player has priority at the moment, so game state cannot be setup.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
game.getAction().invoke(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final Player human = game.getPlayers().get(0);
|
||||||
|
final Player ai = game.getPlayers().get(1);
|
||||||
|
|
||||||
|
Player newPlayerTurn = tChangePlayer.equals("human") ? newPlayerTurn = human : tChangePlayer.equals("ai") ? newPlayerTurn = ai : null;
|
||||||
|
PhaseType newPhase = tChangePhase.trim().equalsIgnoreCase("none") ? null : PhaseType.smartValueOf(tChangePhase);
|
||||||
|
|
||||||
|
game.getPhaseHandler().devModeSet(newPhase, newPlayerTurn);
|
||||||
|
|
||||||
|
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||||
|
|
||||||
|
setupPlayerState(humanLife, humanCardTexts, human);
|
||||||
|
setupPlayerState(computerLife, aiCardTexts, ai);
|
||||||
|
|
||||||
|
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||||
|
|
||||||
|
game.getAction().checkStaticAbilities(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupPlayerState(int life, Map<ZoneType, String> cardTexts, final Player p) {
|
||||||
|
Map<ZoneType, List<Card>> humanCards = new EnumMap<ZoneType, List<Card>>(ZoneType.class);
|
||||||
|
for(Entry<ZoneType, String> kv : cardTexts.entrySet()) {
|
||||||
|
humanCards.put(kv.getKey(), processCardsForZone(kv.getValue().split(";"), p));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (life > 0) p.setLife(life, null);
|
||||||
|
for (Entry<ZoneType, List<Card>> kv : humanCards.entrySet()) {
|
||||||
|
if (kv.getKey() == ZoneType.Battlefield) {
|
||||||
|
for (final Card c : kv.getValue()) {
|
||||||
|
p.getZone(ZoneType.Hand).add(c);
|
||||||
|
p.getGame().getAction().moveToPlay(c);
|
||||||
|
c.setSickness(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.getZone(kv.getKey()).setCards(kv.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* processCardsForZone.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* an array of {@link java.lang.String} objects.
|
||||||
|
* @param player
|
||||||
|
* a {@link forge.game.player.Player} object.
|
||||||
|
* @return a {@link forge.CardList} object.
|
||||||
|
*/
|
||||||
|
private List<Card> processCardsForZone(final String[] data, final Player player) {
|
||||||
|
final List<Card> cl = new ArrayList<Card>();
|
||||||
|
for (final String element : data) {
|
||||||
|
final String[] cardinfo = element.trim().split("\\|");
|
||||||
|
|
||||||
|
final Card c = Card.fromPaperCard(FModel.getMagicDb().getCommonCards().getCard(cardinfo[0]), player);
|
||||||
|
|
||||||
|
boolean hasSetCurSet = false;
|
||||||
|
for (final String info : cardinfo) {
|
||||||
|
if (info.startsWith("Set:")) {
|
||||||
|
c.setCurSetCode(info.substring(info.indexOf(':') + 1));
|
||||||
|
hasSetCurSet = true;
|
||||||
|
} else if (info.equalsIgnoreCase("Tapped:True")) {
|
||||||
|
c.tap();
|
||||||
|
} else if (info.startsWith("Counters:")) {
|
||||||
|
final String[] counterStrings = info.substring(info.indexOf(':') + 1).split(",");
|
||||||
|
for (final String counter : counterStrings) {
|
||||||
|
c.addCounter(CounterType.valueOf(counter), 1, true);
|
||||||
|
}
|
||||||
|
} else if (info.equalsIgnoreCase("SummonSick:True")) {
|
||||||
|
c.setSickness(true);
|
||||||
|
} else if (info.equalsIgnoreCase("FaceDown:True")) {
|
||||||
|
c.setState(CardCharacteristicName.FaceDown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasSetCurSet) {
|
||||||
|
c.setCurSetCode(c.getMostRecentSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
cl.add(c);
|
||||||
|
}
|
||||||
|
return cl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Tutor.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @since 1.0.15
|
||||||
|
*/
|
||||||
|
public void tutorForCard() {
|
||||||
|
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||||
|
if (pPriority == null) {
|
||||||
|
SGuiDialog.message(getGui(), "No player has priority at the moment, so their deck can't be tutored from.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Card> lib = pPriority.getCardsIn(ZoneType.Library);
|
||||||
|
final List<ZoneType> origin = new ArrayList<ZoneType>();
|
||||||
|
origin.add(ZoneType.Library);
|
||||||
|
SpellAbility sa = new SpellAbility.EmptySa(new Card(-1));
|
||||||
|
final Card card = chooseSingleCardForZoneChange(ZoneType.Hand, origin, sa, lib, "Choose a card", true, pPriority);
|
||||||
|
if (card == null) { return; }
|
||||||
|
|
||||||
|
game.getAction().invoke(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
game.getAction().moveToHand(card);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* AddCounter.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @since 1.0.15
|
||||||
|
*/
|
||||||
|
public void addCountersToPermanent() {
|
||||||
|
final List<Card> cards = game.getCardsIn(ZoneType.Battlefield);
|
||||||
|
final CardView cardView = SGuiChoose.oneOrNone(getGui(), "Add counters to which card?", getCardViews(cards));
|
||||||
|
final Card card = getCard(cardView);
|
||||||
|
if (card == null) { return; }
|
||||||
|
|
||||||
|
final CounterType counter = SGuiChoose.oneOrNone(getGui(), "Which type of counter?", CounterType.values());
|
||||||
|
if (counter == null) { return; }
|
||||||
|
|
||||||
|
final Integer count = SGuiChoose.getInteger(getGui(), "How many counters?", 1, Integer.MAX_VALUE, 10);
|
||||||
|
if (count == null) { return; }
|
||||||
|
|
||||||
|
card.addCounter(counter, count, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tapPermanents() {
|
||||||
|
game.getAction().invoke(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final List<Card> untapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Predicates.not(CardPredicates.Presets.TAPPED));
|
||||||
|
InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0, Integer.MAX_VALUE, untapped);
|
||||||
|
inp.setCancelAllowed(true);
|
||||||
|
inp.setMessage("Choose permanents to tap");
|
||||||
|
inp.showAndWait();
|
||||||
|
if (!inp.hasCancelled()) {
|
||||||
|
for (Card c : inp.getSelected()) {
|
||||||
|
c.tap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void untapPermanents() {
|
||||||
|
game.getAction().invoke(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final List<Card> tapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.TAPPED);
|
||||||
|
InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0, Integer.MAX_VALUE, tapped);
|
||||||
|
inp.setCancelAllowed(true);
|
||||||
|
inp.setMessage("Choose permanents to untap");
|
||||||
|
inp.showAndWait();
|
||||||
|
if( !inp.hasCancelled() )
|
||||||
|
for(Card c : inp.getSelected())
|
||||||
|
c.untap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerLife() {
|
||||||
|
final List<Player> players = game.getPlayers();
|
||||||
|
final PlayerView playerView = SGuiChoose.oneOrNone(getGui(), "Set life for which player?", getPlayerViews(players));
|
||||||
|
final Player player = getPlayer(playerView);
|
||||||
|
if (player == null) { return; }
|
||||||
|
|
||||||
|
final Integer life = SGuiChoose.getInteger(getGui(), "Set life to what?", 0);
|
||||||
|
if (life == null) { return; }
|
||||||
|
|
||||||
|
player.setLife(life, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void winGame() {
|
||||||
|
Input input = getGui().getInputQueue().getInput();
|
||||||
|
if (!(input instanceof InputPassPriority)) {
|
||||||
|
SOptionPane.showMessageDialog(getGui(), "You must have priority to use this feature.", "Win Game", SOptionPane.INFORMATION_ICON);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set life of all other players to 0
|
||||||
|
final LobbyPlayer guiPlayer = getLobbyPlayer();
|
||||||
|
final List<Player> players = game.getPlayers();
|
||||||
|
for (Player player : players) {
|
||||||
|
if (player.getLobbyPlayer() != guiPlayer) {
|
||||||
|
player.setLife(0, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//pass priority so that causes gui player to win
|
||||||
|
input.selectButtonOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCardToHand() {
|
||||||
|
final List<Player> players = game.getPlayers();
|
||||||
|
final PlayerView pView = SGuiChoose.oneOrNone(getGui(), "Put card in hand for which player?", getPlayerViews(players));
|
||||||
|
final Player p = getPlayer(pView);
|
||||||
|
if (null == p) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<PaperCard> cards = Lists.newArrayList(FModel.getMagicDb().getCommonCards().getUniqueCards());
|
||||||
|
Collections.sort(cards);
|
||||||
|
|
||||||
|
// use standard forge's list selection dialog
|
||||||
|
final IPaperCard c = SGuiChoose.oneOrNone(getGui(), "Name the card", cards);
|
||||||
|
if (c == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
game.getAction().invoke(new Runnable() { @Override public void run() {
|
||||||
|
game.getAction().moveToHand(Card.fromPaperCard(c, p));
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCardToBattlefield() {
|
||||||
|
final List<Player> players = game.getPlayers();
|
||||||
|
final PlayerView pView = SGuiChoose.oneOrNone(getGui(), "Put card in play for which player?", getPlayerViews(players));
|
||||||
|
final Player p = getPlayer(pView);
|
||||||
|
if (null == p) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<PaperCard> cards = Lists.newArrayList(FModel.getMagicDb().getCommonCards().getUniqueCards());
|
||||||
|
Collections.sort(cards);
|
||||||
|
|
||||||
|
// use standard forge's list selection dialog
|
||||||
|
final IPaperCard c = SGuiChoose.oneOrNone(getGui(), "Name the card", cards);
|
||||||
|
if (c == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
game.getAction().invoke(new Runnable() {
|
||||||
|
@Override public void run() {
|
||||||
|
final Card forgeCard = Card.fromPaperCard(c, p);
|
||||||
|
|
||||||
|
if (c.getRules().getType().isLand()) {
|
||||||
|
game.getAction().moveToPlay(forgeCard);
|
||||||
|
} else {
|
||||||
|
final List<SpellAbility> choices = forgeCard.getBasicSpells();
|
||||||
|
if (choices.isEmpty()) {
|
||||||
|
return; // when would it happen?
|
||||||
|
}
|
||||||
|
|
||||||
|
final SpellAbility sa;
|
||||||
|
if (choices.size() == 1) {
|
||||||
|
sa = choices.iterator().next();
|
||||||
|
} else {
|
||||||
|
final SpellAbilityView saView = SGuiChoose.oneOrNone(getGui(), "Choose", getSpellAbilityViews(choices));
|
||||||
|
sa = getSpellAbility(saView);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sa == null) {
|
||||||
|
return; // happens if cancelled
|
||||||
|
}
|
||||||
|
|
||||||
|
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
||||||
|
// Human player is choosing targets for an ability controlled by chosen player.
|
||||||
|
sa.setActivatingPlayer(p);
|
||||||
|
HumanPlay.playSaWithoutPayingManaCost(PlayerControllerHuman.this, game, sa, true);
|
||||||
|
}
|
||||||
|
game.getStack().addAllTriggeredAbilitiesToStack(); // playSa could fire some triggers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void riggedPlanarRoll() {
|
||||||
|
final List<Player> players = game.getPlayers();
|
||||||
|
final PlayerView playerView = SGuiChoose.oneOrNone(getGui(), "Which player should roll?", getPlayerViews(players));
|
||||||
|
final Player player = getPlayer(playerView);
|
||||||
|
if (player == null) { return; }
|
||||||
|
|
||||||
|
final PlanarDice res = SGuiChoose.oneOrNone(getGui(), "Choose result", PlanarDice.values());
|
||||||
|
if (res == null) { return; }
|
||||||
|
|
||||||
|
System.out.println("Rigging planar dice roll: " + res.toString());
|
||||||
|
|
||||||
|
game.getAction().invoke(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
PlanarDice.roll(player, res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void planeswalkTo() {
|
||||||
|
if (!game.getRules().hasAppliedVariant(GameType.Planechase)) { return; }
|
||||||
|
final Player p = game.getPhaseHandler().getPlayerTurn();
|
||||||
|
|
||||||
|
final List<PaperCard> allPlanars = new ArrayList<PaperCard>();
|
||||||
|
for (PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) {
|
||||||
|
if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) {
|
||||||
|
allPlanars.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(allPlanars);
|
||||||
|
|
||||||
|
// use standard forge's list selection dialog
|
||||||
|
final IPaperCard c = SGuiChoose.oneOrNone(getGui(), "Name the card", allPlanars);
|
||||||
|
if (c == null) { return; }
|
||||||
|
final Card forgeCard = Card.fromPaperCard(c, p);
|
||||||
|
|
||||||
|
forgeCard.setOwner(p);
|
||||||
|
game.getAction().invoke(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
game.getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0);
|
||||||
|
PlanarDice.roll(p, PlanarDice.Planeswalk);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,508 +0,0 @@
|
|||||||
package forge.util;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import forge.LobbyPlayer;
|
|
||||||
import forge.card.CardCharacteristicName;
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.GameType;
|
|
||||||
import forge.game.PlanarDice;
|
|
||||||
import forge.game.card.Card;
|
|
||||||
import forge.game.card.CardLists;
|
|
||||||
import forge.game.card.CardPredicates;
|
|
||||||
import forge.game.card.CounterType;
|
|
||||||
import forge.game.phase.PhaseType;
|
|
||||||
import forge.game.player.Player;
|
|
||||||
import forge.game.spellability.AbilityManaPart;
|
|
||||||
import forge.game.spellability.SpellAbility;
|
|
||||||
import forge.game.trigger.TriggerType;
|
|
||||||
import forge.game.zone.ZoneType;
|
|
||||||
import forge.item.IPaperCard;
|
|
||||||
import forge.item.PaperCard;
|
|
||||||
import forge.match.input.Input;
|
|
||||||
import forge.match.input.InputPassPriority;
|
|
||||||
import forge.match.input.InputSelectCardsFromList;
|
|
||||||
import forge.model.FModel;
|
|
||||||
import forge.player.HumanPlay;
|
|
||||||
import forge.player.PlayerControllerHuman;
|
|
||||||
import forge.properties.ForgeConstants;
|
|
||||||
import forge.util.gui.SGuiChoose;
|
|
||||||
import forge.util.gui.SGuiDialog;
|
|
||||||
import forge.util.gui.SOptionPane;
|
|
||||||
import forge.view.CardView;
|
|
||||||
import forge.view.PlayerView;
|
|
||||||
import forge.view.SpellAbilityView;
|
|
||||||
|
|
||||||
public final class DevModeUtil {
|
|
||||||
|
|
||||||
private DevModeUtil() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void devModeGenerateMana(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
|
||||||
if (pPriority == null) {
|
|
||||||
SGuiDialog.message(controller.getGui(), "No player has priority at the moment, so mana cannot be added to their pool.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Card dummy = new Card(-777777);
|
|
||||||
dummy.setOwner(pPriority);
|
|
||||||
Map<String, String> produced = new HashMap<String, String>();
|
|
||||||
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
|
||||||
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
|
||||||
game.getAction().invoke(new Runnable() {
|
|
||||||
@Override public void run() { abMana.produceMana(null); }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void devSetupGameState(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
int humanLife = -1;
|
|
||||||
int computerLife = -1;
|
|
||||||
|
|
||||||
final Map<ZoneType, String> humanCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
|
||||||
final Map<ZoneType, String> aiCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
|
||||||
|
|
||||||
String tChangePlayer = "NONE";
|
|
||||||
String tChangePhase = "NONE";
|
|
||||||
|
|
||||||
File gamesDir = new File(ForgeConstants.USER_GAMES_DIR);
|
|
||||||
if (!gamesDir.exists()) { // if the directory does not exist, try to create it
|
|
||||||
gamesDir.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
String filename = controller.getGui().showFileDialog("Select Game State File", ForgeConstants.USER_GAMES_DIR);
|
|
||||||
if (filename == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
final FileInputStream fstream = new FileInputStream(filename);
|
|
||||||
final DataInputStream in = new DataInputStream(fstream);
|
|
||||||
final BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
|
||||||
|
|
||||||
String temp = "";
|
|
||||||
|
|
||||||
while ((temp = br.readLine()) != null) {
|
|
||||||
|
|
||||||
final String[] tempData = temp.split("=");
|
|
||||||
if (tempData.length < 2 || temp.charAt(0) == '#') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String categoryName = tempData[0].toLowerCase();
|
|
||||||
final String categoryValue = tempData[1];
|
|
||||||
|
|
||||||
if (categoryName.equals("humanlife")) humanLife = Integer.parseInt(categoryValue);
|
|
||||||
else if (categoryName.equals("ailife")) computerLife = Integer.parseInt(categoryValue);
|
|
||||||
|
|
||||||
else if (categoryName.equals("activeplayer")) tChangePlayer = categoryValue.trim().toLowerCase();
|
|
||||||
else if (categoryName.equals("activephase")) tChangePhase = categoryValue;
|
|
||||||
|
|
||||||
else if (categoryName.equals("humancardsinplay")) humanCardTexts.put(ZoneType.Battlefield, categoryValue);
|
|
||||||
else if (categoryName.equals("aicardsinplay")) aiCardTexts.put(ZoneType.Battlefield, categoryValue);
|
|
||||||
else if (categoryName.equals("humancardsinhand")) humanCardTexts.put(ZoneType.Hand, categoryValue);
|
|
||||||
else if (categoryName.equals("aicardsinhand")) aiCardTexts.put(ZoneType.Hand, categoryValue);
|
|
||||||
else if (categoryName.equals("humancardsingraveyard")) humanCardTexts.put(ZoneType.Graveyard, categoryValue);
|
|
||||||
else if (categoryName.equals("aicardsingraveyard")) aiCardTexts.put(ZoneType.Graveyard, categoryValue);
|
|
||||||
else if (categoryName.equals("humancardsinlibrary")) humanCardTexts.put(ZoneType.Library, categoryValue);
|
|
||||||
else if (categoryName.equals("aicardsinlibrary")) aiCardTexts.put(ZoneType.Library, categoryValue);
|
|
||||||
else if (categoryName.equals("humancardsinexile")) humanCardTexts.put(ZoneType.Exile, categoryValue);
|
|
||||||
else if (categoryName.equals("aicardsinexile")) aiCardTexts.put(ZoneType.Exile, categoryValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
catch (final FileNotFoundException fnfe) {
|
|
||||||
SOptionPane.showErrorDialog(controller.getGui(), "File not found: " + filename);
|
|
||||||
}
|
|
||||||
catch (final Exception e) {
|
|
||||||
SOptionPane.showErrorDialog(controller.getGui(), "Error loading battle setup file!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setupGameState(game, humanLife, computerLife, humanCardTexts, aiCardTexts, tChangePlayer, tChangePhase, controller);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setupGameState(final Game game, final int humanLife, final int computerLife, final Map<ZoneType, String> humanCardTexts,
|
|
||||||
final Map<ZoneType, String> aiCardTexts, final String tChangePlayer, final String tChangePhase, final PlayerControllerHuman controller) {
|
|
||||||
|
|
||||||
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
|
||||||
if (pPriority == null) {
|
|
||||||
SGuiDialog.message(controller.getGui(), "No player has priority at the moment, so game state cannot be setup.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
game.getAction().invoke(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final Player human = game.getPlayers().get(0);
|
|
||||||
final Player ai = game.getPlayers().get(1);
|
|
||||||
|
|
||||||
Player newPlayerTurn = tChangePlayer.equals("human") ? newPlayerTurn = human : tChangePlayer.equals("ai") ? newPlayerTurn = ai : null;
|
|
||||||
PhaseType newPhase = tChangePhase.trim().equalsIgnoreCase("none") ? null : PhaseType.smartValueOf(tChangePhase);
|
|
||||||
|
|
||||||
game.getPhaseHandler().devModeSet(newPhase, newPlayerTurn);
|
|
||||||
|
|
||||||
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
|
||||||
|
|
||||||
devSetupPlayerState(humanLife, humanCardTexts, human);
|
|
||||||
devSetupPlayerState(computerLife, aiCardTexts, ai);
|
|
||||||
|
|
||||||
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
|
||||||
|
|
||||||
game.getAction().checkStaticAbilities(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void devSetupPlayerState(int life, Map<ZoneType, String> cardTexts, final Player p) {
|
|
||||||
Map<ZoneType, List<Card>> humanCards = new EnumMap<ZoneType, List<Card>>(ZoneType.class);
|
|
||||||
for(Entry<ZoneType, String> kv : cardTexts.entrySet()) {
|
|
||||||
humanCards.put(kv.getKey(), devProcessCardsForZone(kv.getValue().split(";"), p));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (life > 0) p.setLife(life, null);
|
|
||||||
for (Entry<ZoneType, List<Card>> kv : humanCards.entrySet()) {
|
|
||||||
if (kv.getKey() == ZoneType.Battlefield) {
|
|
||||||
for (final Card c : kv.getValue()) {
|
|
||||||
p.getZone(ZoneType.Hand).add(c);
|
|
||||||
p.getGame().getAction().moveToPlay(c);
|
|
||||||
c.setSickness(false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.getZone(kv.getKey()).setCards(kv.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devProcessCardsForZone.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
* an array of {@link java.lang.String} objects.
|
|
||||||
* @param player
|
|
||||||
* a {@link forge.game.player.Player} object.
|
|
||||||
* @return a {@link forge.CardList} object.
|
|
||||||
*/
|
|
||||||
private static List<Card> devProcessCardsForZone(final String[] data, final Player player) {
|
|
||||||
final List<Card> cl = new ArrayList<Card>();
|
|
||||||
for (final String element : data) {
|
|
||||||
final String[] cardinfo = element.trim().split("\\|");
|
|
||||||
|
|
||||||
final Card c = Card.fromPaperCard(FModel.getMagicDb().getCommonCards().getCard(cardinfo[0]), player);
|
|
||||||
|
|
||||||
boolean hasSetCurSet = false;
|
|
||||||
for (final String info : cardinfo) {
|
|
||||||
if (info.startsWith("Set:")) {
|
|
||||||
c.setCurSetCode(info.substring(info.indexOf(':') + 1));
|
|
||||||
hasSetCurSet = true;
|
|
||||||
} else if (info.equalsIgnoreCase("Tapped:True")) {
|
|
||||||
c.tap();
|
|
||||||
} else if (info.startsWith("Counters:")) {
|
|
||||||
final String[] counterStrings = info.substring(info.indexOf(':') + 1).split(",");
|
|
||||||
for (final String counter : counterStrings) {
|
|
||||||
c.addCounter(CounterType.valueOf(counter), 1, true);
|
|
||||||
}
|
|
||||||
} else if (info.equalsIgnoreCase("SummonSick:True")) {
|
|
||||||
c.setSickness(true);
|
|
||||||
} else if (info.equalsIgnoreCase("FaceDown:True")) {
|
|
||||||
c.setState(CardCharacteristicName.FaceDown);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasSetCurSet) {
|
|
||||||
c.setCurSetCode(c.getMostRecentSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
cl.add(c);
|
|
||||||
}
|
|
||||||
return cl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devModeTutor.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 1.0.15
|
|
||||||
*/
|
|
||||||
public static void devModeTutor(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
Player pPriority = game.getPhaseHandler().getPriorityPlayer();
|
|
||||||
if (pPriority == null) {
|
|
||||||
SGuiDialog.message(controller.getGui(), "No player has priority at the moment, so their deck can't be tutored from.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Card> lib = pPriority.getCardsIn(ZoneType.Library);
|
|
||||||
final List<ZoneType> origin = new ArrayList<ZoneType>();
|
|
||||||
origin.add(ZoneType.Library);
|
|
||||||
SpellAbility sa = new SpellAbility.EmptySa(new Card(-1));
|
|
||||||
final Card card = controller.chooseSingleCardForZoneChange(ZoneType.Hand, origin, sa, lib, "Choose a card", true, pPriority);
|
|
||||||
if (card == null) { return; }
|
|
||||||
|
|
||||||
game.getAction().invoke(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
game.getAction().moveToHand(card);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devModeAddCounter.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 1.0.15
|
|
||||||
*/
|
|
||||||
public static void devModeAddCounter(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
final List<Card> cards = game.getCardsIn(ZoneType.Battlefield);
|
|
||||||
final CardView cardView = SGuiChoose.oneOrNone(controller.getGui(), "Add counters to which card?", controller.getCardViews(cards));
|
|
||||||
final Card card = controller.getCard(cardView);
|
|
||||||
if (card == null) { return; }
|
|
||||||
|
|
||||||
final CounterType counter = SGuiChoose.oneOrNone(controller.getGui(), "Which type of counter?", CounterType.values());
|
|
||||||
if (counter == null) { return; }
|
|
||||||
|
|
||||||
final Integer count = SGuiChoose.getInteger(controller.getGui(), "How many counters?", 1, Integer.MAX_VALUE, 10);
|
|
||||||
if (count == null) { return; }
|
|
||||||
|
|
||||||
card.addCounter(counter, count, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devModeTapPerm.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 1.0.15
|
|
||||||
*/
|
|
||||||
public static void devModeTapPerm(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
game.getAction().invoke(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final List<Card> untapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Predicates.not(CardPredicates.Presets.TAPPED));
|
|
||||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 0, Integer.MAX_VALUE, untapped);
|
|
||||||
inp.setCancelAllowed(true);
|
|
||||||
inp.setMessage("Choose permanents to tap");
|
|
||||||
inp.showAndWait();
|
|
||||||
if (!inp.hasCancelled()) {
|
|
||||||
for (Card c : inp.getSelected()) {
|
|
||||||
c.tap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devModeUntapPerm.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 1.0.15
|
|
||||||
*/
|
|
||||||
public static void devModeUntapPerm(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
game.getAction().invoke(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final List<Card> tapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.TAPPED);
|
|
||||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 0, Integer.MAX_VALUE, tapped);
|
|
||||||
inp.setCancelAllowed(true);
|
|
||||||
inp.setMessage("Choose permanents to untap");
|
|
||||||
inp.showAndWait();
|
|
||||||
if( !inp.hasCancelled() )
|
|
||||||
for(Card c : inp.getSelected())
|
|
||||||
c.untap();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devModeSetLife.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 1.1.3
|
|
||||||
*/
|
|
||||||
public static void devModeSetLife(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
final List<Player> players = game.getPlayers();
|
|
||||||
final PlayerView playerView = SGuiChoose.oneOrNone(controller.getGui(), "Set life for which player?", controller.getPlayerViews(players));
|
|
||||||
final Player player = controller.getPlayer(playerView);
|
|
||||||
if (player == null) { return; }
|
|
||||||
|
|
||||||
final Integer life = SGuiChoose.getInteger(controller.getGui(), "Set life to what?", 0);
|
|
||||||
if (life == null) { return; }
|
|
||||||
|
|
||||||
player.setLife(life, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devModeWinGame.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 1.5.23
|
|
||||||
*/
|
|
||||||
public static void devModeWinGame(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
Input input = controller.getGui().getInputQueue().getInput();
|
|
||||||
if (!(input instanceof InputPassPriority)) {
|
|
||||||
SOptionPane.showMessageDialog(controller.getGui(), "You must have priority to use this feature.", "Win Game", SOptionPane.INFORMATION_ICON);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//set life of all other players to 0
|
|
||||||
final LobbyPlayer guiPlayer = controller.getLobbyPlayer();
|
|
||||||
final List<Player> players = game.getPlayers();
|
|
||||||
for (Player player : players) {
|
|
||||||
if (player.getLobbyPlayer() != guiPlayer) {
|
|
||||||
player.setLife(0, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//pass priority so that causes gui player to win
|
|
||||||
input.selectButtonOK();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devModeTutorAnyCard.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 1.2.7
|
|
||||||
*/
|
|
||||||
public static void devModeCardToHand(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
final List<Player> players = game.getPlayers();
|
|
||||||
final PlayerView pView = SGuiChoose.oneOrNone(controller.getGui(), "Put card in hand for which player?", controller.getPlayerViews(players));
|
|
||||||
final Player p = controller.getPlayer(pView);
|
|
||||||
if (null == p) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<PaperCard> cards = Lists.newArrayList(FModel.getMagicDb().getCommonCards().getUniqueCards());
|
|
||||||
Collections.sort(cards);
|
|
||||||
|
|
||||||
// use standard forge's list selection dialog
|
|
||||||
final IPaperCard c = SGuiChoose.oneOrNone(controller.getGui(), "Name the card", cards);
|
|
||||||
if (c == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
game.getAction().invoke(new Runnable() { @Override public void run() {
|
|
||||||
game.getAction().moveToHand(Card.fromPaperCard(c, p));
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void devModeCardToBattlefield(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
final List<Player> players = game.getPlayers();
|
|
||||||
final PlayerView pView = SGuiChoose.oneOrNone(controller.getGui(), "Put card in play for which player?", controller.getPlayerViews(players));
|
|
||||||
final Player p = controller.getPlayer(pView);
|
|
||||||
if (null == p) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<PaperCard> cards = Lists.newArrayList(FModel.getMagicDb().getCommonCards().getUniqueCards());
|
|
||||||
Collections.sort(cards);
|
|
||||||
|
|
||||||
// use standard forge's list selection dialog
|
|
||||||
final IPaperCard c = SGuiChoose.oneOrNone(controller.getGui(), "Name the card", cards);
|
|
||||||
if (c == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
game.getAction().invoke(new Runnable() {
|
|
||||||
@Override public void run() {
|
|
||||||
final Card forgeCard = Card.fromPaperCard(c, p);
|
|
||||||
|
|
||||||
if (c.getRules().getType().isLand()) {
|
|
||||||
game.getAction().moveToPlay(forgeCard);
|
|
||||||
} else {
|
|
||||||
final List<SpellAbility> choices = forgeCard.getBasicSpells();
|
|
||||||
if (choices.isEmpty()) {
|
|
||||||
return; // when would it happen?
|
|
||||||
}
|
|
||||||
|
|
||||||
final SpellAbility sa;
|
|
||||||
if (choices.size() == 1) {
|
|
||||||
sa = choices.iterator().next();
|
|
||||||
} else {
|
|
||||||
final SpellAbilityView saView = SGuiChoose.oneOrNone(controller.getGui(), "Choose", controller.getSpellAbilityViews(choices));
|
|
||||||
sa = controller.getSpellAbility(saView);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sa == null) {
|
|
||||||
return; // happens if cancelled
|
|
||||||
}
|
|
||||||
|
|
||||||
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
|
||||||
// Human player is choosing targets for an ability controlled by chosen player.
|
|
||||||
sa.setActivatingPlayer(p);
|
|
||||||
HumanPlay.playSaWithoutPayingManaCost(controller, game, sa, true);
|
|
||||||
}
|
|
||||||
game.getStack().addAllTriggeredAbilitiesToStack(); // playSa could fire some triggers
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void devModeRiggedPlanarRoll(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
final List<Player> players = game.getPlayers();
|
|
||||||
final PlayerView playerView = SGuiChoose.oneOrNone(controller.getGui(), "Which player should roll?", controller.getPlayerViews(players));
|
|
||||||
final Player player = controller.getPlayer(playerView);
|
|
||||||
if (player == null) { return; }
|
|
||||||
|
|
||||||
final PlanarDice res = SGuiChoose.oneOrNone(controller.getGui(), "Choose result", PlanarDice.values());
|
|
||||||
if (res == null) { return; }
|
|
||||||
|
|
||||||
System.out.println("Rigging planar dice roll: " + res.toString());
|
|
||||||
|
|
||||||
game.getAction().invoke(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlanarDice.roll(player, res);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void devModePlaneswalkTo(final Game game, final PlayerControllerHuman controller) {
|
|
||||||
if (!game.getRules().hasAppliedVariant(GameType.Planechase)) { return; }
|
|
||||||
final Player p = game.getPhaseHandler().getPlayerTurn();
|
|
||||||
|
|
||||||
final List<PaperCard> allPlanars = new ArrayList<PaperCard>();
|
|
||||||
for (PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) {
|
|
||||||
if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) {
|
|
||||||
allPlanars.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Collections.sort(allPlanars);
|
|
||||||
|
|
||||||
// use standard forge's list selection dialog
|
|
||||||
final IPaperCard c = SGuiChoose.oneOrNone(controller.getGui(), "Name the card", allPlanars);
|
|
||||||
if (c == null) { return; }
|
|
||||||
final Card forgeCard = Card.fromPaperCard(c, p);
|
|
||||||
|
|
||||||
forgeCard.setOwner(p);
|
|
||||||
game.getAction().invoke(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
game.getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0);
|
|
||||||
PlanarDice.roll(p, PlanarDice.Planeswalk);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,6 +14,7 @@ import forge.game.GameType;
|
|||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.match.input.Input;
|
import forge.match.input.Input;
|
||||||
import forge.match.input.InputConfirm;
|
import forge.match.input.InputConfirm;
|
||||||
|
import forge.player.PlayerControllerHuman.DevModeCheats;
|
||||||
import forge.util.ITriggerEvent;
|
import forge.util.ITriggerEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -251,20 +252,9 @@ public interface IGameView {
|
|||||||
* automatically.
|
* automatically.
|
||||||
*/
|
*/
|
||||||
public abstract void autoPassCancel();
|
public abstract void autoPassCancel();
|
||||||
|
|
||||||
|
public abstract boolean canPlayUnlimitedLands();
|
||||||
|
|
||||||
public abstract boolean devGetUnlimitedLands();
|
//method used to wrap all functions that cheat
|
||||||
public abstract void devSetUnlimitedLands(boolean b);
|
public abstract DevModeCheats cheat();
|
||||||
public abstract void devGenerateMana();
|
|
||||||
public abstract void devSetupGameState();
|
|
||||||
public abstract void devTutorForCard();
|
|
||||||
public abstract void devAddCardToHand();
|
|
||||||
public abstract void devAddCounterToPermanent();
|
|
||||||
public abstract void devTapPermanent();
|
|
||||||
public abstract void devUntapPermanent();
|
|
||||||
public abstract void devSetPlayerLife();
|
|
||||||
public abstract void devWinGame();
|
|
||||||
public abstract void devAddCardToBattlefield();
|
|
||||||
public abstract void devRiggedPlanerRoll();
|
|
||||||
public abstract void devPlaneswalkTo();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import forge.game.Game;
|
|||||||
import forge.match.input.Input;
|
import forge.match.input.Input;
|
||||||
import forge.match.input.InputPlaybackControl;
|
import forge.match.input.InputPlaybackControl;
|
||||||
import forge.match.input.InputQueue;
|
import forge.match.input.InputQueue;
|
||||||
|
import forge.player.PlayerControllerHuman.DevModeCheats;
|
||||||
import forge.util.ITriggerEvent;
|
import forge.util.ITriggerEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,51 +110,6 @@ public class WatchLocalGame extends LocalGameView {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dev mode functions
|
|
||||||
@Override
|
|
||||||
public boolean devGetUnlimitedLands() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devSetUnlimitedLands(final boolean b) {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devGenerateMana() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devSetupGameState() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devTutorForCard() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devAddCardToHand() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devAddCounterToPermanent() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devTapPermanent() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devUntapPermanent() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devSetPlayerLife() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devWinGame() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devAddCardToBattlefield() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devRiggedPlanerRoll() {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void devPlaneswalkTo() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<String> getAutoYields() {
|
public Iterable<String> getAutoYields() {
|
||||||
return null;
|
return null;
|
||||||
@@ -190,4 +146,14 @@ public class WatchLocalGame extends LocalGameView {
|
|||||||
public void autoPassCancel() {
|
public void autoPassCancel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayUnlimitedLands() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DevModeCheats cheat() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user