mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
store variants in an enumset
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user