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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks with the user by asking if they want to continue their quest.Displays a "menu" for the player.void
endGame()
Prints a goodbye message for completing the game.void
Printsvoid
listKnights
(List<Knight> knights) Lists the knights by id: name.void
printBattleText
(List<MOB> monsters, List<Knight> activeKnights) Lists a number of knights side by side with their 'foes' (aka monsters).void
printBattleText
(MOB dead) Prints that the MOB was defeated.void
Prints when all knights are defeatedvoid
printFortunes
(List<Knight> activeKnights) Prints fortunes for the knight that they draw at the beginning of the quest.void
Prints the help menu.void
Prints the following message:void
showKnight
(Knight knight) Prints a knight to the console, plus a blank line.void
Prints a splashScreen that is called at the launch of the game.
-
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:
splashScreen
in 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 (look back to Practical 1)
- Specified by:
displayMainMenu
in 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 Ram
If no knights are found, it prints the following:No knights to list
- Specified by:
listKnights
in interfaceGameView
- Parameters:
knights
- a set of knights to list- See Also:
-
knightNotFound
public void knightNotFound()PrintsKnight not found!
To the console.- Specified by:
knightNotFound
in interfaceGameView
-
showKnight
Prints a knight to the console, plus a blank line.- Specified by:
showKnight
in interfaceGameView
- Parameters:
knight
- the knight whose card is meant to print- See Also:
-
setActiveFailed
public void setActiveFailed()Prints the following message:Unable to set active knight. Only four can be active at a time.
- Specified by:
setActiveFailed
in 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
- Specified by:
printBattleText
in interfaceGameView
- Parameters:
monsters
- a list of MOB objectsactiveKnights
- a list of Knight objectsw
-
printBattleText
Prints that the MOB was defeated. ExamplesFrost Giant was defeated!
Arthur was defeated!
- Specified by:
printBattleText
in interfaceGameView
- Parameters:
dead
- the defeated MOB
-
printFortunes
Prints fortunes for the knight that they draw at the beginning of the quest. 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:
printFortunes
in interfaceGameView
- Parameters:
activeKnights
- A List of Knights
-
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:
checkContinue
in interfaceGameView
- Returns:
- true if the client types y, or yes - else false for anything else.
-
printDefeated
public void printDefeated()Prints when all knights are defeatedAll active knights have been defeated!
- Specified by:
printDefeated
in interfaceGameView
-