Skip to content

Commit e30def0

Browse files
committed
move rules definition into game class
1 parent 98a70d6 commit e30def0

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/main/java/scorekeep/RulesFactory.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,7 @@ public class RulesFactory {
88
private final HashMap<String, Rules> allRules = new HashMap<String, Rules>(1);
99

1010
public RulesFactory(){
11-
String id = "TicTacToe";
12-
String name = "Tic Tac Toe";
13-
String[] categories = { "head to head", "quick" };
14-
Integer[] users = { 2 };
15-
Integer teams = 0;
16-
String[] phases = { "Move" };
17-
String[] moves = { "Roll" };
18-
String initialState = "X ";
19-
Rules tictactoe = new Rules(id, name, categories, users, teams, phases, moves, initialState);
20-
11+
Rules tictactoe = TicTacToe.getRules();
2112
allRules.put(tictactoe.getId(), tictactoe);
2213
}
2314

src/main/java/scorekeep/TicTacToe.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
public class TicTacToe {
99
private static final Logger logger = LoggerFactory.getLogger("TicTacToe");
1010

11+
public static Rules getRules() {
12+
String id = "TicTacToe";
13+
String name = "Tic Tac Toe";
14+
String[] categories = { "head to head", "quick" };
15+
Integer[] users = { 2 };
16+
Integer teams = 0;
17+
String[] phases = { "Move" };
18+
String[] moves = { "Roll" };
19+
String initialState = "X ";
20+
Rules tictactoe = new Rules(id, name, categories, users, teams, phases, moves, initialState);
21+
return tictactoe;
22+
}
1123
/* State is a string with one character that indicates the current turn
1224
* (X or O), or win state (A or B). The remaining 9 characters map to spaces
1325
* on the game board.

0 commit comments

Comments
 (0)