mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
store variants in an enumset
This commit is contained in:
@@ -18,6 +18,11 @@
|
|||||||
<artifactId>forge-core</artifactId>
|
<artifactId>forge-core</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>forge</groupId>
|
||||||
|
<artifactId>forge-game</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1474,7 +1474,6 @@ public class GameAction {
|
|||||||
public void startGame(GameOutcome lastGameOutcome) {
|
public void startGame(GameOutcome lastGameOutcome) {
|
||||||
Player first = determineFirstTurnPlayer(lastGameOutcome);
|
Player first = determineFirstTurnPlayer(lastGameOutcome);
|
||||||
|
|
||||||
List<GameType> variants = game.getRules().getAppliedVariants();
|
|
||||||
GameType gameType = game.getRules().getGameType();
|
GameType gameType = game.getRules().getGameType();
|
||||||
do {
|
do {
|
||||||
if (game.isGameOver()) { break; } // conceded during "play or draw"
|
if (game.isGameOver()) { break; } // conceded during "play or draw"
|
||||||
@@ -1494,7 +1493,7 @@ public class GameAction {
|
|||||||
game.setAge(GameStage.Play);
|
game.setAge(GameStage.Play);
|
||||||
|
|
||||||
//<THIS CODE WILL WORK WITH PHASE = NULL>
|
//<THIS CODE WILL WORK WITH PHASE = NULL>
|
||||||
if (variants.contains(GameType.Planechase)) {
|
if (game.getRules().hasAppliedVariant(GameType.Planechase)) {
|
||||||
first.initPlane();
|
first.initPlane();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package forge.game;
|
package forge.game;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GameRules {
|
public class GameRules {
|
||||||
@@ -10,7 +10,7 @@ public class GameRules {
|
|||||||
private int gamesPerMatch = 3;
|
private int gamesPerMatch = 3;
|
||||||
private int gamesToWinMatch = 2;
|
private int gamesToWinMatch = 2;
|
||||||
private boolean playForAnte = false;
|
private boolean playForAnte = false;
|
||||||
private List<GameType> appliedVariants = new ArrayList<GameType>(4);
|
private EnumSet<GameType> appliedVariants = EnumSet.noneOf(GameType.class);
|
||||||
|
|
||||||
public GameRules(GameType type) {
|
public GameRules(GameType type) {
|
||||||
this.gameType = type;
|
this.gameType = type;
|
||||||
@@ -67,11 +67,11 @@ public class GameRules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAppliedVariants(List<GameType> appliedVariants) {
|
public void setAppliedVariants(List<GameType> appliedVariants) {
|
||||||
this.appliedVariants = appliedVariants;
|
this.appliedVariants = EnumSet.copyOf(appliedVariants);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GameType> getAppliedVariants() {
|
public boolean hasAppliedVariant(GameType variant) {
|
||||||
return appliedVariants;
|
return appliedVariants.contains(variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
// it's a preference, not rule... but I could hardly find a better place for it
|
// it's a preference, not rule... but I could hardly find a better place for it
|
||||||
|
|||||||
@@ -751,7 +751,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
|
|
||||||
Player next = getNextActivePlayer();
|
Player next = getNextActivePlayer();
|
||||||
|
|
||||||
if (game.getRules().getAppliedVariants().contains(GameType.Planechase)) {
|
if (game.getRules().hasAppliedVariant(GameType.Planechase)) {
|
||||||
for (Card p :game.getActivePlanes()) {
|
for (Card p :game.getActivePlanes()) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.setController(next, 0);
|
p.setController(next, 0);
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startMatch(GameType gameType, List<RegisteredPlayer> players) {
|
public void startMatch(GameType gameType, List<RegisteredPlayer> players) {
|
||||||
startMatch(gameType, new ArrayList<GameType>(0), players);
|
startMatch(gameType, null, players);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startMatch(GameType gameType, List<GameType> appliedVariants, List<RegisteredPlayer> players) {
|
public void startMatch(GameType gameType, List<GameType> appliedVariants, List<RegisteredPlayer> players) {
|
||||||
@@ -577,7 +577,8 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameRules rules = new GameRules(gameType);
|
GameRules rules = new GameRules(gameType);
|
||||||
rules.setAppliedVariants(appliedVariants);
|
if( null != appliedVariants )
|
||||||
|
rules.setAppliedVariants(appliedVariants);
|
||||||
rules.setPlayForAnte(Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE));
|
rules.setPlayForAnte(Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE));
|
||||||
rules.setManaBurn(Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_MANABURN));
|
rules.setManaBurn(Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_MANABURN));
|
||||||
rules.canCloneUseTargetsImage = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE);
|
rules.canCloneUseTargetsImage = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE);
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ public final class GuiDisplayUtil {
|
|||||||
|
|
||||||
public static void devModePlaneswalkTo() {
|
public static void devModePlaneswalkTo() {
|
||||||
final Game game = getGame();
|
final Game game = getGame();
|
||||||
if (!game.getRules().getAppliedVariants().contains(GameType.Planechase)) { return; }
|
if (!game.getRules().hasAppliedVariant(GameType.Planechase)) { return; }
|
||||||
final Player p = game.getPhaseHandler().getPlayerTurn();
|
final Player p = game.getPhaseHandler().getPlayerTurn();
|
||||||
|
|
||||||
final List<PaperCard> allPlanars = new ArrayList<PaperCard>();
|
final List<PaperCard> allPlanars = new ArrayList<PaperCard>();
|
||||||
|
|||||||
Reference in New Issue
Block a user