Class Main
Object
Main
Main driver class for the Game.
The game has a number of program arguments, with only two that are **required** to function.
- --data={data filename}
data file needed for the game, contains MOBs and Fortunes - {save filename}
save file needed for the game, contains knights
Examples:
java Main java Main knights.csv java Main --data=data/gamedata.csv java Main --data=gamedata2.csv mygame.csv
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Takes in command line parameters, looks through the program arguments.private static void
processArgs
(String[] args) loops through each each program argument (args).
-
Field Details
-
gamedata
The location of the game data. defaults to gamedata.csv, but the --data={file} arg will reset the value -
saveData
The location of the saved file, with a default (new game) file being knights.csv. The first non-specific/flagged argument replaces this file.
-
-
Constructor Details
-
Main
public Main()
-
-
Method Details
-
main
Takes in command line parameters, looks through the program arguments. Builds the objects to run the game, and passes control over to the GameController. Example code includesprocessArgs(args); // method that parses the args, optional but cleaned up the code GameData data = new CSVGameData(gamedata, saveData); GameView view = new ConsoleView(); CombatEngine engine = new CombatEngine(data, view); GameController controller = new GameController(data, view, engine); controller.start();
Hint: first write a loop that looks at the arguments, and then worry about processing. We also suggest getting the entire programming working first, and work on this part last.- Parameters:
args
- the command line arguments option
-
processArgs
loops through each each program argument (args). checks to see if the argument starts with --data. If it starts with data, takes the substring of the argument (after the = sign) to set the gamedata. else, any other argument sets the saveData value (even if it has been set)- Parameters:
args
-
-