Class GameController

Object
GameController

public class GameController extends Object
Central point of communication between GameData, GameView and CombatEngine.
  • Constructor Details

    • GameController

      public GameController(GameData data, GameView view, CombatEngine engine)
      The GameController needs all major components of the game to work - view, data and combat
      Parameters:
      data - GameData - does not care the type (CSV, JSON, etc), just the abstract class
      view - GameView - calles the various methods based on feedback from data
      engine - runs combat between an active knight group and MOBs
  • Method Details

    • start

      public void start()
      Starts the game, causing it to run until a client exits. Starts with splashScreen, loops as long as processCommand returns true, prints endgame when loop is done.
      See Also:
    • processCommand

      protected boolean processCommand(String command)
      Setup as a helper method for start() }, processes commands the client passes in through GameView.displayMainMenu(). The following command combinations are allowed:
      • exit or bye (contains) - causes processCommand to return false
      • ls or list all - list all knights. For example, view.listKnights(data.getKnights())
      • list active - list active knights via GameData.getActiveKnights()
      • show (name or id) - if the command starts with show, take the remainder and show the knight card
      • set active (name or id) - if command starts with set active, grabs the remainder of the line, and try to add the knight to the active knight list.
      • remove (name or id) - if command starts with remove, grabs the remainder of the line, attempts to remove the knight from active status.
      • save (filename - optional) - saves the game. If a file name is provided saves the knights to the file. If a file name is left off, saves out to saveData.csv
      • explore, adventure or quest - if any three of these words are used, it starts a combat sequence. For example.
         
                 engine.initialize();
                 engine.runCombat();
                 engine.clear();
             }
      • any other input, print the help menu.
      Parameters:
      command - command to process.
      Returns:
      true unless exit or bye is used.