java.lang.Object
za.co.wethinkcode.robots.server.world.World

public class World extends Object
The World Class stores all known information about the world World-level configuration: how many seconds a repair takes. Defaults to 3 seconds; can be overridden via the constructor or setter.
  • Constructor Details

    • World

      public World(WorldConfig config)
    • World

      @Deprecated public World(int size, int mazeType, int repairTime, int reloadTime)
      Deprecated.
    • World

      @Deprecated public World(int size, int mazeType)
      Deprecated.
  • Method Details

    • getRepairTime

      public int getRepairTime()
    • getReloadTime

      public int getReloadTime()
    • setRepairTime

      public void setRepairTime(int repairTime)
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getVisibility

      public int getVisibility()
    • getAllRobots

      public Collection<Robot> getAllRobots()
    • getObstacles

      public List<Position> getObstacles()
    • getMaze

      public MazeGenerator getMaze()
    • getMaxShields

      public int getMaxShields()
    • getMaxShots

      public int getMaxShots()
    • getRandomSpawn

      public Optional<Position> getRandomSpawn()
    • addRobot

      public boolean addRobot(Robot robot)
      Returns true if a robot was successfully added to the world

      Please note that the current implementation utilizes a random spawn

      Parameters:
      robot - the robot being added to the world
      Returns:
      if the robot was added
    • getRobot

      public Robot getRobot(String name)
    • removeRobot

      public void removeRobot(String name)
    • removeAllRobots

      public void removeAllRobots()
    • isValidPosition

      public boolean isValidPosition(Position p)
    • isWallAt

      public boolean isWallAt(int x, int y)
    • isObstacleAt

      public boolean isObstacleAt(int x, int y)
    • getRobotAt

      public Robot getRobotAt(int x, int y)
    • getMap

      public WorldMap getMap()
      Returns:
      the WorldMap for this world, for callers that want to work with spatial queries directly rather than through World's delegating methods above.
    • clearForTesting

      public void clearForTesting()
    • printWorld

      @Deprecated public void printWorld()
      Deprecated.
      Maintained for backward compatibility. Shallow call to ServerRenderer.printWorld(World)
    • disconnectRobotsFromClientId

      public void disconnectRobotsFromClientId(ClientID clientId)
      Take in a ClientID and remove all bots from the server associated with this clientID
      Parameters:
      clientId - the of the ConnectedClient who launched these robots;