Record Class WorldKnowledge

java.lang.Object
java.lang.Record
za.co.wethinkcode.robots.client.memory.WorldKnowledge
Record Components:
ipAddress - IpAddress of the Server the Client is connected to
port - Port number of the Server the client is connected to on
dimensions - size of the world (measured in steps)
visibility - how far into the world a given robot can see
reloadTime - how long it takes for a robot to reload
repairTime - how long it takes for a robot to repair
mineTime - how long it takes for a robot to place a mine
maxShields - maximum number of shields that this world allows
maxShots - maximum number of shots that this world allows

public record WorldKnowledge(String map, String ipAddress, int port, int[] dimensions, int visibility, int reloadTime, int repairTime, int mineTime, int maxShields, int maxShots) extends Record
Local record class that stores the knowledge the client has of the world it is connected to.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Utility constant for establishing an unknown world
    static final String
    Utility constant for rendering world knowledge that is unknown
  • Constructor Summary

    Constructors
    Constructor
    Description
    WorldKnowledge(String map, String ipAddress, int port, int[] dimensions, int visibility, int reloadTime, int repairTime, int mineTime, int maxShields, int maxShots)
    Creates an instance of a WorldKnowledge record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    Returns the value of the dimensions record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the ipAddress record component.
    map()
    Returns the value of the map record component.
    int
    Returns the value of the maxShields record component.
    int
    Returns the value of the maxShots record component.
    int
    Returns the value of the mineTime record component.
    int
    Returns the value of the port record component.
    int
    Returns the value of the reloadTime record component.
    int
    Returns the value of the repairTime record component.
    Returns a string representation of this record class.
    int
    Returns the value of the visibility record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • UNKNOWN

      public static final int UNKNOWN
      Utility constant for establishing an unknown world
      See Also:
    • unknownString

      public static final String unknownString
      Utility constant for rendering world knowledge that is unknown
      See Also:
  • Constructor Details

    • WorldKnowledge

      public WorldKnowledge(String map, String ipAddress, int port, int[] dimensions, int visibility, int reloadTime, int repairTime, int mineTime, int maxShields, int maxShots)
      Creates an instance of a WorldKnowledge record class.
      Parameters:
      map - the value for the map record component
      ipAddress - the value for the ipAddress record component
      port - the value for the port record component
      dimensions - the value for the dimensions record component
      visibility - the value for the visibility record component
      reloadTime - the value for the reloadTime record component
      repairTime - the value for the repairTime record component
      mineTime - the value for the mineTime record component
      maxShields - the value for the maxShields record component
      maxShots - the value for the maxShots record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • map

      public String map()
      Returns the value of the map record component.
      Returns:
      the value of the map record component
    • ipAddress

      public String ipAddress()
      Returns the value of the ipAddress record component.
      Returns:
      the value of the ipAddress record component
    • port

      public int port()
      Returns the value of the port record component.
      Returns:
      the value of the port record component
    • dimensions

      public int[] dimensions()
      Returns the value of the dimensions record component.
      Returns:
      the value of the dimensions record component
    • visibility

      public int visibility()
      Returns the value of the visibility record component.
      Returns:
      the value of the visibility record component
    • reloadTime

      public int reloadTime()
      Returns the value of the reloadTime record component.
      Returns:
      the value of the reloadTime record component
    • repairTime

      public int repairTime()
      Returns the value of the repairTime record component.
      Returns:
      the value of the repairTime record component
    • mineTime

      public int mineTime()
      Returns the value of the mineTime record component.
      Returns:
      the value of the mineTime record component
    • maxShields

      public int maxShields()
      Returns the value of the maxShields record component.
      Returns:
      the value of the maxShields record component
    • maxShots

      public int maxShots()
      Returns the value of the maxShots record component.
      Returns:
      the value of the maxShots record component