Class GameRun

java.lang.Object
wizardquest.gamemanager.GameRun
All Implemented Interfaces:
GameRunInterface

public class GameRun extends Object implements GameRunInterface
  • Constructor Summary

    Constructors
    Constructor
    Description
    GameRun(DifficultyEnum difficulty, int sessionID)
    Creates a run for the game in the specified difficulty.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of deaths the player has had in this run.
    Gets the difficulty of the run.
    Returns a reference to the player.
    GIves the time when this game run instance was created (and thus the run started).
    int
    Gets the session ID for the current run.
    int
    Gets the current stage's number.
    void
    Marks that the player has died, incrementing the death count, reducing the player's lives by 1, and resetting their health.
    void
    Increments the stage count, so the pickEncounter method can draw from the encounter pool for the correct stage.
    Picks a random encounter for the current stage from the encounter pool for that stage and returns a reference to it.
    void
    Attempts to buy the selected upgrade, throwing an error if the player doesn't have enough coins, and otherwise reducing their number of coins by the upgrade's price.
    Picks a number of upgrades from the shop determined by the ShopItemCount design parameter and returns an array of references to them.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GameRun

      public GameRun(DifficultyEnum difficulty, int sessionID)
      Creates a run for the game in the specified difficulty. Also takes note of when the run started.
      Parameters:
      difficulty - the difficulty setting for the run.
  • Method Details

    • getSessionID

      public int getSessionID()
      Description copied from interface: GameRunInterface
      Gets the session ID for the current run.
      Specified by:
      getSessionID in interface GameRunInterface
      Returns:
      the session ID of the current run.
    • pickEncounter

      public EncounterInterface pickEncounter() throws IllegalStateException
      Description copied from interface: GameRunInterface
      Picks a random encounter for the current stage from the encounter pool for that stage and returns a reference to it. It is the responsibility of the caller to keep track of the encounter, mark it as complete when it is finished, and reset it if the player retries it after dying.
      Specified by:
      pickEncounter in interface GameRunInterface
      Returns:
      a reference to the chosen encounter.
      Throws:
      IllegalStateException - if it is asked to pick an encounter for a stage where all encounters have already been completed.
    • viewShop

      public UpgradeEnum[] viewShop()
      Description copied from interface: GameRunInterface
      Picks a number of upgrades from the shop determined by the ShopItemCount design parameter and returns an array of references to them.
      Specified by:
      viewShop in interface GameRunInterface
      Returns:
      an array of references to the upgrades.
    • purchaseUpgrade

      public void purchaseUpgrade(UpgradeEnum upgrade) throws LackingResourceException
      Description copied from interface: GameRunInterface
      Attempts to buy the selected upgrade, throwing an error if the player doesn't have enough coins, and otherwise reducing their number of coins by the upgrade's price. It then removes the upgrade from the poo of upgrades the shop selects from and decorates the player with it.
      Specified by:
      purchaseUpgrade in interface GameRunInterface
      Parameters:
      upgrade - the upgrade being bought from the shop.
      Throws:
      LackingResourceException - if the player doesn't have enough coins to buy the upgrade.
    • getPlayer

      public PlayerInterface getPlayer()
      Description copied from interface: GameRunInterface
      Returns a reference to the player.
      Specified by:
      getPlayer in interface GameRunInterface
      Returns:
      a reference to the player.
    • nextStage

      public void nextStage()
      Description copied from interface: GameRunInterface
      Increments the stage count, so the pickEncounter method can draw from the encounter pool for the correct stage.
      Specified by:
      nextStage in interface GameRunInterface
    • getStage

      public int getStage()
      Description copied from interface: GameRunInterface
      Gets the current stage's number.
      Specified by:
      getStage in interface GameRunInterface
      Returns:
      the current stage number (between 1 and 10 inclusive).
    • getRunStartTime

      public LocalDateTime getRunStartTime()
      Description copied from interface: GameRunInterface
      GIves the time when this game run instance was created (and thus the run started).
      Specified by:
      getRunStartTime in interface GameRunInterface
      Returns:
      the LocalDateTime of when the run started.
    • getDeathCount

      public int getDeathCount()
      Description copied from interface: GameRunInterface
      Returns the number of deaths the player has had in this run.
      Specified by:
      getDeathCount in interface GameRunInterface
      Returns:
      the number of time the player's died this run.
    • incrementDeathCount

      public void incrementDeathCount()
      Description copied from interface: GameRunInterface
      Marks that the player has died, incrementing the death count, reducing the player's lives by 1, and resetting their health.
      Specified by:
      incrementDeathCount in interface GameRunInterface
    • getDifficulty

      public DifficultyEnum getDifficulty()
      Description copied from interface: GameRunInterface
      Gets the difficulty of the run.
      Specified by:
      getDifficulty in interface GameRunInterface
      Returns:
      the difficulty setting for this run.