Class Level

java.lang.Object
nz.ac.vuw.ecs.swen225.gp6.domain.Level

public class Level extends Object
The level class is used to group all information related to a level together. Such as the maze, inventory, direction of players next movement, etc.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Inventory
     
    final int
     
    final Maze
     
    final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Level(Maze maze, int lvl)
    constructor for a level, which takes the maze, and level number.
    Level(Maze maze, Inventory inv, int lvl, int timeLimit, long timeCurrent, Direction heroNextStep)
    constructor for a level which takes, maze, inventory, level number, time limit of level, current time of level, and heros next steps direction.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Get the current time of the level.
    Get the direction of the hero's next step.
    void
    sets the movement direction of hero, which the hero will try to move towards if possible in NEXT ping.
    void
    setCurrentTime(long timeCurrent)
    sets the current time of the level.

    Methods inherited from class java.lang.Object

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

    • maze

      public final Maze maze
    • inv

      public final Inventory inv
    • lvl

      public final int lvl
    • timeLimit

      public final int timeLimit
  • Constructor Details

    • Level

      public Level(Maze maze, Inventory inv, int lvl, int timeLimit, long timeCurrent, Direction heroNextStep)
      constructor for a level which takes, maze, inventory, level number, time limit of level, current time of level, and heros next steps direction.
      Parameters:
      maze - - the maze
      inv - - the inventory
      lvl - - the level number 1,2, ...
      timeLimit - - in seconds, the limit for how long the player has to finish the level
      timeCurrent - - the current time in seconds (should start at 0)
      heroNextStep - - the hero's direction of stepping in next ping
      Throws:
      NullPointerException - if maze, inventory, or direction are null
      IndexOutOfBoundsException - if level is less than 1 or the times are less than 0
    • Level

      public Level(Maze maze, int lvl)
      constructor for a level, which takes the maze, and level number. It default the time limit to 120 s, and the current time to 0 s, inventory to an empty inventory of size 8 and heros direction to None.
      Parameters:
      maze - - the maze of the level
      lvl - - the level number 1,2, ...
  • Method Details

    • getCurrentTime

      public long getCurrentTime()
      Get the current time of the level.
      Returns:
      current time on level
    • setCurrentTime

      public void setCurrentTime(long timeCurrent)
      sets the current time of the level.
      Parameters:
      timeCurrent - - the time to set the level's time to
      Throws:
      IllegalArgumentException - if timeCurrent is negative
    • getHeroNextStep

      public Direction getHeroNextStep()
      Get the direction of the hero's next step.
      Returns:
      direction enum for next step of hero
    • makeHeroStep

      public void makeHeroStep(Direction d)
      sets the movement direction of hero, which the hero will try to move towards if possible in NEXT ping.
      Parameters:
      d - - the direction for hero to step in next unit of time