Package cs2110
Class GameEngine
java.lang.Object
cs2110.GameEngine
Manages the state of our game simulation by creating and keeping track of players and monsters
and facilitating the turn order.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new game engine with a seeded random number generator and a scanner to process console input. -
Method Summary
Modifier and TypeMethodDescriptionReturns the next line of console input from the user.Monster[]Returns a reference to an array copy containing references to all living monsters.static voidRuns a game simulation.voidprocessMonsterDeath(Monster monster) Reports that the given `monster` has been defeated.voidprocessPlayerDeath(Player player) Reports that the given `player` has been defeated.Returns a reference to a random player that is currently alive in this simulation.rng()Returns the random number generator associated to this game engine.
-
Constructor Details
-
GameEngine
public GameEngine()Constructs a new game engine with a seeded random number generator and a scanner to process console input.
-
-
Method Details
-
randomLivingPlayer
Returns a reference to a random player that is currently alive in this simulation. -
livingMonsters
Returns a reference to an array copy containing references to all living monsters. Client code is free to make modifications to this array. -
rng
Returns the random number generator associated to this game engine. -
processMonsterDeath
Reports that the given `monster` has been defeated. -
processPlayerDeath
Reports that the given `player` has been defeated. -
getInputLine
Returns the next line of console input from the user. -
main
Runs a game simulation.
-