Package wizardquest.gamemanager
Interface GameRunInterface
- All Known Implementing Classes:
GameRun
public interface GameRunInterface
Provides the interface for a game run. A game run stores information about a
single run of the game, including the encounters in that run and the player.
-
Method Summary
Modifier and TypeMethodDescriptionintReturns 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).intGets the session ID for the current run.intgetStage()Gets the current stage's number.voidMarks that the player has died, incrementing the death count, reducing the player's lives by 1, and resetting their health.voidIncrements 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.voidpurchaseUpgrade(UpgradeEnum upgrade) 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.viewShop()Picks a number of upgrades from the shop determined by the ShopItemCount design parameter and returns an array of references to them.
-
Method Details
-
pickEncounter
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.- 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
UpgradeEnum[] viewShop()Picks a number of upgrades from the shop determined by the ShopItemCount design parameter and returns an array of references to them.- Returns:
- an array of references to the upgrades.
-
purchaseUpgrade
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.- Parameters:
upgrade- the upgrade being bought from the shop.- Throws:
LackingResourceException- if the player doesn't have enough coins to buy the upgrade.
-
getPlayer
PlayerInterface getPlayer()Returns a reference to the player.- Returns:
- a reference to the player.
-
nextStage
void nextStage()Increments the stage count, so the pickEncounter method can draw from the encounter pool for the correct stage. -
getStage
int getStage()Gets the current stage's number.- Returns:
- the current stage number (between 1 and 10 inclusive).
-
getRunStartTime
LocalDateTime getRunStartTime()GIves the time when this game run instance was created (and thus the run started).- Returns:
- the LocalDateTime of when the run started.
-
getDeathCount
int getDeathCount()Returns the number of deaths the player has had in this run.- Returns:
- the number of time the player's died this run.
-
incrementDeathCount
void incrementDeathCount()Marks that the player has died, incrementing the death count, reducing the player's lives by 1, and resetting their health. -
getDifficulty
DifficultyEnum getDifficulty()Gets the difficulty of the run.- Returns:
- the difficulty setting for this run.
-
getSessionID
int getSessionID()Gets the session ID for the current run.- Returns:
- the session ID of the current run.
-