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>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-game</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -1474,7 +1474,6 @@ public class GameAction {
|
||||
public void startGame(GameOutcome lastGameOutcome) {
|
||||
Player first = determineFirstTurnPlayer(lastGameOutcome);
|
||||
|
||||
List<GameType> variants = game.getRules().getAppliedVariants();
|
||||
GameType gameType = game.getRules().getGameType();
|
||||
do {
|
||||
if (game.isGameOver()) { break; } // conceded during "play or draw"
|
||||
@@ -1494,7 +1493,7 @@ public class GameAction {
|
||||
game.setAge(GameStage.Play);
|
||||
|
||||
//<THIS CODE WILL WORK WITH PHASE = NULL>
|
||||
if (variants.contains(GameType.Planechase)) {
|
||||
if (game.getRules().hasAppliedVariant(GameType.Planechase)) {
|
||||
first.initPlane();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package forge.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
public class GameRules {
|
||||
@@ -10,7 +10,7 @@ public class GameRules {
|
||||
private int gamesPerMatch = 3;
|
||||
private int gamesToWinMatch = 2;
|
||||
private boolean playForAnte = false;
|
||||
private List<GameType> appliedVariants = new ArrayList<GameType>(4);
|
||||
private EnumSet<GameType> appliedVariants = EnumSet.noneOf(GameType.class);
|
||||
|
||||
public GameRules(GameType type) {
|
||||
this.gameType = type;
|
||||
@@ -67,11 +67,11 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public void setAppliedVariants(List<GameType> appliedVariants) {
|
||||
this.appliedVariants = appliedVariants;
|
||||
this.appliedVariants = EnumSet.copyOf(appliedVariants);
|
||||
}
|
||||
|
||||
public List<GameType> getAppliedVariants() {
|
||||
return appliedVariants;
|
||||
public boolean hasAppliedVariant(GameType variant) {
|
||||
return appliedVariants.contains(variant);
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
if (game.getRules().getAppliedVariants().contains(GameType.Planechase)) {
|
||||
if (game.getRules().hasAppliedVariant(GameType.Planechase)) {
|
||||
for (Card p :game.getActivePlanes()) {
|
||||
if (p != null) {
|
||||
p.setController(next, 0);
|
||||
|
||||
@@ -567,7 +567,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -577,7 +577,8 @@ public enum FControl implements KeyEventDispatcher {
|
||||
}
|
||||
|
||||
GameRules rules = new GameRules(gameType);
|
||||
rules.setAppliedVariants(appliedVariants);
|
||||
if( null != appliedVariants )
|
||||
rules.setAppliedVariants(appliedVariants);
|
||||
rules.setPlayForAnte(Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE));
|
||||
rules.setManaBurn(Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_MANABURN));
|
||||
rules.canCloneUseTargetsImage = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE);
|
||||
|
||||
@@ -445,7 +445,7 @@ public final class GuiDisplayUtil {
|
||||
|
||||
public static void devModePlaneswalkTo() {
|
||||
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 List<PaperCard> allPlanars = new ArrayList<PaperCard>();
|
||||
|
||||
Reference in New Issue
Block a user