store variants in an enumset

This commit is contained in:
Maxmtg
2014-01-25 09:45:47 +00:00
parent b6409b11c7
commit ed7369c98f
6 changed files with 16 additions and 11 deletions

View File

@@ -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();
}

View File

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

View File

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