Labyrinth
A labyrinth game assignment
|
Go to the documentation of this file.
40 package host.labyrinth;
42 import java.util.Scanner;
52 scan =
new Scanner(System.in);
68 System.out.println(
"Press enter to continue...");
95 for (
int i =0 ; i<args.length ; ++i) {
99 if (i+1 < args.length)
105 if (i+1 < args.length)
111 if (i+1 < args.length)
120 case "--interactive":
127 System.out.println(
"Labyrinth Game");
128 System.out.println(
"");
129 System.out.println(
"Usage:");
130 System.out.println(
"labyrinth [-b|--board <Num>] [-s|--supplies <Num>] [-r|--rounds <Num>] [--norooms] [-i|--interactive]");
131 System.out.println(
"or");
132 System.out.println(
"labyrinth -h|--help");
133 System.out.println(
"\nOptions\n");
134 System.out.println(
"-b | --board:\n Sets the size of board's edge.\n");
135 System.out.println(
"-s | --supplies:\n Sets the number of supplies on the board.\n");
136 System.out.println(
"-r | --rounds:\n Sets the maximum number of rounds of the game.\n");
137 System.out.println(
"--norooms:\n Prevents the creation of closed rooms inside the board.\n");
138 System.out.println(
"-i | --interactive:\n Each round requires user input in order to continue.\n");
139 System.out.println(
"-h | --help:\n Print this and exits.");
150 public static void main(String[] args) {
165 System.out.println(
"Initial board: " + (game.
round()));
173 System.out.println();
174 System.out.println(
"State after round: " + (game.
round()+1));
178 System.out.println(T.
getName() +
":\t tileId =" + m[0] +
" (" + m[1] +
", " + m[2] +
")");
180 System.out.println(M.
getName() +
":\t tileId =" + m[0] +
" (" + m[1] +
", " + m[2] +
")");
195 System.out.println(
"New day has come... Tie!!!");
201 catch (Exception e) {
203 System.out.println(e.getMessage());
static int maxRounds
Default number of rounds per game (if no one set it via command line)
int round()
Utility to get current round of the game.
String[][] getStringRepresentation(int theseusTile, int minotaurTile)
Returns a 2-D array with the string representation of the board.
int round
Holds the round of the game.
Scanner scan
Input handle used in interactive mode.
Application wide object to hold settings like values for the session.
void createBoard(int theseusTile, int minotaurTile)
Creates the board with all the requested walls and supplies.
void waitUser()
Utility to hold the execution of the program waiting for user input.
int nextRound()
Utility to increase and get the increased round of the game.
int[] move(int id)
Player's move.
static int boardSize
Default board's size (if no one set it via command line)
int playerTileId()
Utility to access player's tileID.
An Application wide board position implementation holding just the id coordinate.
This class is the representation of the games's board.
static int supplySize
Default board's supply size (if no one set it via command line)
static boolean getArguments(String[] args)
Command line argument handler.
Game()
< An empty constructor
static boolean loopGuard
When true a wall creation guard is added to prevent closed rooms inside the board.
This class represents the game's player.
void printBoard(String[][] sBoard)
Print board utility.
static void main(String[] args)
Main game loop.
static int toID(int row, int col)
Takes row and column coordinates and return the calculated Id coordinate.
static boolean interactive
When true each round of the game requires user input.