diff --git a/src/net/hoo2/auth/labyrinth/Common.java b/src/net/hoo2/auth/labyrinth/Common.java index 20f3cad..673f757 100644 --- a/src/net/hoo2/auth/labyrinth/Common.java +++ b/src/net/hoo2/auth/labyrinth/Common.java @@ -22,6 +22,8 @@ class Const { */ class Session { static int boardSize = 15; /**< Default board's size (if no one set it via command line) */ + static int supplySize = 4; /**< Default board's supply size (if no one set it via command line) */ + static int wallSize = 4*15-1; /**< Default board's wall size (if no one set it via command line) */ } /** diff --git a/src/net/hoo2/auth/labyrinth/Game.java b/src/net/hoo2/auth/labyrinth/Game.java index 20733a1..e7e00f7 100644 --- a/src/net/hoo2/auth/labyrinth/Game.java +++ b/src/net/hoo2/auth/labyrinth/Game.java @@ -15,6 +15,9 @@ public class Game { Game() {} /**< An empty constructor */ + int round () { return round; } + int nextRound() { return ++round; } + /** * @name Accessor/Mutator interface * @note @@ -34,20 +37,69 @@ public class Game { /** * Main game loop */ + static boolean getArguments (String[] args) { + boolean ret = true; + + for (int i =0 ; i] [-w|--walls ] [-s|--supplies ]"); + System.out.println("or"); + System.out.println("labyrinth -h|--help"); + System.out.println(""); + System.out.println("\t-b | --board: Sets the size of board's edge."); + System.out.println("\t-w | --walls: Sets the number of walls on the board."); + System.out.println("\t-s | --supplies: Sets the number of supplies on the board."); + System.out.println("\t-h | --help: Print this and exit"); + break; + } + } + return ret; + } + public static void main(String[] args) { try { + // Get command line options + Game.getArguments(args); + // Create a game, a board and 2 players. - Game game = new Game(); - Board board = new Board(11, 4, 82); - Player T = new Player(1, "Theseus", board, 0); - Player M = new Player(2, "Minotaur", board, Position.toID(3, 3)); + Game game = new Game(); + Board board = new Board(Session.boardSize, Session.supplySize, Session.wallSize); + Player T = new Player(1, "Theseus", board, 0); + Player M = new Player(2, "Minotaur", board, Position.toID(Session.boardSize/2, Session.boardSize/2)); + // Populate data to the board board.createBoard(T.playerTileId(), M.playerTileId()); + // The game while (true) { int[] m; System.out.println(); - System.out.println("Round: " + (game.getRound()+1)); + System.out.println("Round: " + (game.round()+1)); m = T.move(T.playerTileId()); System.out.println(T.getName() + ":\t tileId =" + m[0] + " (" + m[1] + ", " + m[2] + ")"); @@ -66,8 +118,7 @@ public class Game { System.out.println(M.getName() + " Wins!!! Score =" + M.getScore()); System.exit(0); } - game.setRound(game.getRound()+1); - if (!(game.getRound() < 100)) { + if (!(game.nextRound() < 100)) { System.out.println("New day has come... Tie!!!"); System.exit(0); }