Class WorldState

java.lang.Object
za.co.wethinkcode.robots.server.worldinfo.WorldState

public class WorldState extends Object
A super class that stores a lot of information about the WorldState
  • Constructor Details

    • WorldState

      public WorldState(String worldID, String IPAddress, int reloadTimeInSeconds, int shieldRepairTimeInSeconds, int maximumShieldInHits, int visibilityInKliks, ArrayList<Obstacle> obstacles, ArrayList<Client> clients, KlikGrid klikGrid, org.apache.commons.collections4.bidimap.DualHashBidiMap<Position,WorldObject> whereEverythingIs)
      Iteration1 WorldState Constructor. This will be depreciated and refactored in favor of a WorldConfig Object
      Parameters:
      worldID - ID of the to world
      IPAddress - IP address as a string
      reloadTimeInSeconds - how Long It Takes To Reload
      shieldRepairTimeInSeconds - how Long it Takes to repair a shield
      maximumShieldInHits - how many hits it takes to destroy a shield
      visibilityInKliks - how many Kliks all robots can see
      obstacles - arrayList of obstacles
      clients - clients
      klikGrid - klikGrid of the World
  • Method Details

    • getWorldID

      public String getWorldID()
      WorldID getter
      Returns:
      worldID
    • getObstacles

      public ArrayList<Obstacle> getObstacles()
    • getEmptySpawn

      public Position getEmptySpawn() throws WorldFullException
      Utility method for getting empty spawn points
      Returns:
      a spawn position
      Throws:
      WorldFullException
    • getIPAddress

      public String getIPAddress()
      IP address getter
      Returns:
      IP address
    • getReloadTimeInSeconds

      public int getReloadTimeInSeconds()
      Reload time getter (measured in seconds)
      Returns:
      reload time in seconds
    • getShieldRepairTimeInSeconds

      public int getShieldRepairTimeInSeconds()
      Shield repair time getter (measured in seconds)
      Returns:
      shield repair time
    • getWhereEverythingIs

      public Map<Position,WorldObject> getWhereEverythingIs()
      Obstacles getter
      Returns:
      a list of all obstacles in the world
    • getklikGrid

      public KlikGrid getklikGrid()
      KlikGrid getter
      Returns:
      a klik grid with its width and height
    • getClients

      public ArrayList<Client> getClients()
      ClientMain List getter
      Returns:
      a list of all Clients and their associated robots
    • getWhenCaptured

      public Instant getWhenCaptured()
      Gets when this worldState was made
      Returns:
      the instant the worldState was captured
    • getMaximumShieldInHits

      public int getMaximumShieldInHits()
      Gets Maximum Shield for this world as measured in hits
      Returns:
      the maximum number of a shield as measured in hits
    • getVisibilityInKliks

      public int getVisibilityInKliks()
      Gets visbility for this world state as measured in kliks
      Returns:
      maximum distance all objects can see as measured in kliks
    • checkIfRobotWithThatNameExists

      public boolean checkIfRobotWithThatNameExists(String robotName)
      Checks the worldState to see if the currentWorldState has that Robot
      Parameters:
      robotName - name of the robot being checked
      Returns:
      if a robot with that name exists.
    • getRobotByName

      public @Nullable ServerRobot getRobotByName(String robotName) throws NoSuchRobotException
      Getter for a Robot in the World
      Parameters:
      robotName - name of the robot being looked for
      Returns:
      that robot
      Throws:
      NoSuchRobotException - robot cannot be found in the world
    • hashCode

      public int hashCode()
      How the worlds are hashed. Helps provides logical equality between two worldStates
      Overrides:
      hashCode in class Object
      Returns:
      the objects hash
    • equals

      public boolean equals(Object o)
      Overide of worldEquality
      Overrides:
      equals in class Object
      Parameters:
      o - the second object being made equal
      Returns:
      if two worldStates are equal
    • getWhenCapturedAt

      public Instant getWhenCapturedAt()
      Getter for when a WorldState is captured
      Returns: