Package cs2110

Class GameEngine

java.lang.Object
cs2110.GameEngine

public class GameEngine extends Object
Manages the state of our game simulation by creating and keeping track of players and monsters and facilitating the turn order.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new game engine with a seeded random number generator and a scanner to process console input.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the next line of console input from the user.
    Returns a reference to an array copy containing references to all living monsters.
    static void
    main(String[] args)
    Runs a game simulation.
    void
    Reports that the given `monster` has been defeated.
    void
    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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public Player randomLivingPlayer()
      Returns a reference to a random player that is currently alive in this simulation.
    • livingMonsters

      public Monster[] 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

      public Random rng()
      Returns the random number generator associated to this game engine.
    • processMonsterDeath

      public void processMonsterDeath(Monster monster)
      Reports that the given `monster` has been defeated.
    • processPlayerDeath

      public void processPlayerDeath(Player player)
      Reports that the given `player` has been defeated.
    • getInputLine

      public String getInputLine()
      Returns the next line of console input from the user.
    • main

      public static void main(String[] args)
      Runs a game simulation.