Package wizardquest.gamemanager
Class GameRun
java.lang.Object
wizardquest.gamemanager.GameRun
- All Implemented Interfaces:
GameRunInterface
-
Constructor Summary
ConstructorsConstructorDescriptionGameRun(DifficultyEnum difficulty, int sessionID) Creates a run for the game in the specified difficulty. -
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.
-
Constructor Details
-
GameRun
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:GameRunInterfaceGets the session ID for the current run.- Specified by:
getSessionIDin interfaceGameRunInterface- Returns:
- the session ID of the current run.
-
pickEncounter
Description copied from interface:GameRunInterfacePicks 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:
pickEncounterin interfaceGameRunInterface- 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
Description copied from interface:GameRunInterfacePicks a number of upgrades from the shop determined by the ShopItemCount design parameter and returns an array of references to them.- Specified by:
viewShopin interfaceGameRunInterface- Returns:
- an array of references to the upgrades.
-
purchaseUpgrade
Description copied from interface:GameRunInterfaceAttempts 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:
purchaseUpgradein interfaceGameRunInterface- Parameters:
upgrade- the upgrade being bought from the shop.- Throws:
LackingResourceException- if the player doesn't have enough coins to buy the upgrade.
-
getPlayer
Description copied from interface:GameRunInterfaceReturns a reference to the player.- Specified by:
getPlayerin interfaceGameRunInterface- Returns:
- a reference to the player.
-
nextStage
public void nextStage()Description copied from interface:GameRunInterfaceIncrements the stage count, so the pickEncounter method can draw from the encounter pool for the correct stage.- Specified by:
nextStagein interfaceGameRunInterface
-
getStage
public int getStage()Description copied from interface:GameRunInterfaceGets the current stage's number.- Specified by:
getStagein interfaceGameRunInterface- Returns:
- the current stage number (between 1 and 10 inclusive).
-
getRunStartTime
Description copied from interface:GameRunInterfaceGIves the time when this game run instance was created (and thus the run started).- Specified by:
getRunStartTimein interfaceGameRunInterface- Returns:
- the LocalDateTime of when the run started.
-
getDeathCount
public int getDeathCount()Description copied from interface:GameRunInterfaceReturns the number of deaths the player has had in this run.- Specified by:
getDeathCountin interfaceGameRunInterface- Returns:
- the number of time the player's died this run.
-
incrementDeathCount
public void incrementDeathCount()Description copied from interface:GameRunInterfaceMarks that the player has died, incrementing the death count, reducing the player's lives by 1, and resetting their health.- Specified by:
incrementDeathCountin interfaceGameRunInterface
-
getDifficulty
Description copied from interface:GameRunInterfaceGets the difficulty of the run.- Specified by:
getDifficultyin interfaceGameRunInterface- Returns:
- the difficulty setting for this run.
-