Class ConsoleView
Object
ConsoleView
- All Implemented Interfaces:
GameView
The console view provides a specific implementation of writing output to the
the Console / System.out The only methods implemented are those that
match the GameView interface.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks with the user by asking if they want to continue their quest.Displays a "menu" for the player.voidendGame()Prints a goodbye message for completing the game.voidPrintsvoidlistKnights(List<Knight> knights) Lists the knights by id: name.voidprintBattleText(List<MOB> monsters, List<Knight> activeKnights) Lists a number of knights side by side with their 'foes' (aka monsters).voidprintBattleText(MOB dead) Prints that the MOB was defeated.voidPrints when all knights are defeated, followed by an empty line.voidprintFortunes(List<Knight> activeKnights) Prints fortunes for the knight that they draw at the beginning of the quest by cycling through the provided list of knights.voidPrints the help menu.voidPrints the following message followed by a blank line:voidshowKnight(Knight knight) Prints a knight to the console, plus a blank line.voidPrints a splashScreen that is called at the launch of the game.
-
Field Details
-
in
Initialized at the class level to prevent conflicts with System.in
-
-
Constructor Details
-
ConsoleView
public ConsoleView()
-
-
Method Details
-
splashScreen
public void splashScreen()Prints a splashScreen that is called at the launch of the game. Students: you can make the splashScreen anything you want.- Specified by:
splashScreenin interfaceGameView
-
endGame
public void endGame()Prints a goodbye message for completing the game. -
displayMainMenu
Displays a "menu" for the player. Really, for text based games this was often just a simple question. The following question will be displayedWhat would you like to do?The clients response will be recorded, and returned out of the method.Remember that Scanner connected to System.in, should be a class instance variable to prevent conflicts.
- Specified by:
displayMainMenuin interfaceGameView- Returns:
- the clients response, as an entire line.
- See Also:
-
printHelp
public void printHelp()Prints the help menu. The options are as follows.Unsure what to do, here are some options: ls or list all - listing the knights list active - list the active knights knights only show name or id - show the knight details card set active name or id - set knight as active (note: only 4 knights can be active) remove active name or id - remove a knight from active status (heals knight) explore or adventure or quest - find random monsters to fight save filename - save the game to the file name (default: saveData.csv) exit or goodbye - to leave the game Game rules: You can have four active knights. As long as they are active, they won't heal, but they can gain XP by going on adventures. When you make a knight inactive, they will heal. How many monsters can you defeat before, you have to heal?Note the space before the options is the tab character. -
listKnights
Lists the knights by id: name. Example:1: Guinevere 2: Morrigan Ravenskind 3: Eriu 4: Danu of Ireland 5: Fodla 6: Banba 7: Igraine of the Lake 8: Anna of the Mountains 9: Morgan la Fay 10: Elaine Pendragon 11: Morgawse 12: Arthur 13: Lancelot 14: Gwain 15: Argodras the Red 16: The Green Knight 17: Cam the RamIf no knights are found, it prints the following:No knights to list
- Specified by:
listKnightsin interfaceGameView- Parameters:
knights- a set of knights to list- See Also:
-
knightNotFound
public void knightNotFound()PrintsKnight not found!To the console.- Specified by:
knightNotFoundin interfaceGameView
-
showKnight
Prints a knight to the console, plus a blank line.- Specified by:
showKnightin interfaceGameView- Parameters:
knight- the knight whose card is meant to print- See Also:
-
setActiveFailed
public void setActiveFailed()Prints the following message followed by a blank line:Unable to set active knight. Only four can be active at a time.- Specified by:
setActiveFailedin interfaceGameView
-
printBattleText
Lists a number of knights side by side with their 'foes' (aka monsters). Example:Our heroes come across the following monsters. Prepare for battle! Knights Foes Guinevere Umber Hulk Danu of Ireland Arthur
Our heroes come across the following monsters. Prepare for battle! Knights Foes Danu of Ireland Frost Giant Arthur Orc Gwain Frost Giant
The spacing between does not matter. We used %-27s %n for our formatting. Be careful when a list of monsters is less than the list of activeKnights, you may need to think about different if conditions to make it work out without an IndexOutOfBoundsException
- Specified by:
printBattleTextin interfaceGameView- Parameters:
monsters- a list of MOB objectsactiveKnights- a list of Knight objects
-
printBattleText
Prints that the MOB was defeated. ExamplesFrost Giant was defeated!Arthur was defeated!- Specified by:
printBattleTextin interfaceGameView- Parameters:
dead- the defeated MOB- See Also:
-
printFortunes
Prints fortunes for the knight that they draw at the beginning of the quest by cycling through the provided list of knights. You do not have to worry about a special message if the fortune is null. Examples:For this quest, our knights drew the following fortunes! Danu of Ireland drew +======================+ |Justice | |HP Bonus: +5| |AC Bonus: +2| |Hit Bonus: +1| |Damage Adj: -| +======================+ Arthur drew +======================+ |Nobility | |HP Bonus: +10| |AC Bonus: +1| |Hit Bonus: +1| |Damage Adj: -| +======================+ Gwain drew +======================+ |Obedience | |HP Bonus: +0| |AC Bonus: +3| |Hit Bonus: +1| |Damage Adj: -| +======================+
- Specified by:
printFortunesin interfaceGameView- Parameters:
activeKnights- A List of Knights- See Also:
-
checkContinue
public boolean checkContinue()Checks with the user by asking if they want to continue their quest.Would you like to continue on your quest (y/n)?- Specified by:
checkContinuein interfaceGameView- Returns:
- true if the client types y, or yes (case ignored) - else false for anything else.
-
printDefeated
public void printDefeated()Prints when all knights are defeated, followed by an empty line.All active knights have been defeated!- Specified by:
printDefeatedin interfaceGameView
-