Class Memory
java.lang.Object
za.co.wethinkcode.robots.client.memory.Memory
This class stores the memory of the currently running client
The currently selected robot as well as all the robots launched
The memory is best thought of as it's own runtime that abstracts state out of the currently connected client
The Memory Class also contains the WorldKnowledge record,
which stores all the currently known info about the world the client has
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAndSetCurrentRobot(ClientRobot currentRobot) Add and automatically set a newClientRobotthat commands will be sent fromvoidaddWorldKnowledge(com.google.gson.JsonObject worldCommandResponseFull) Accept the input of a World Command.Optional<com.google.gson.JsonObject> Return the last response from the serverbooleanvoidsetCurrentRobot(ClientRobot currentRobot) Set the current robot that commands will be sent from to a robot that is displayed herevoidupdateMemory(InputParser parsedInput, com.google.gson.JsonObject request, com.google.gson.JsonObject response, AtomicBoolean running) Take in the parsed input from the user, the response from the server, and update theMemoryaccordingly
-
Constructor Details
-
Memory
Standard constructor for aMemoryinstance- Parameters:
ipAddress- ipAddress that is associated with this clientport- that this Client is connected onclient- the client that is associated with this memory
-
-
Method Details
-
getClient
-
getWorldKnowledge
-
getLastRequestResponse
-
getRobotNames
- Returns:
- Simple getter for all the client bots the client is aware of
-
hasCurrentRobot
public boolean hasCurrentRobot()- Returns:
- if a
currentRobothas been set
-
addAndSetCurrentRobot
Add and automatically set a newClientRobotthat commands will be sent from- Parameters:
currentRobot- the newClientRobot
-
setCurrentRobot
Set the current robot that commands will be sent from to a robot that is displayed here- Parameters:
currentRobot- the robot being switched to
-
addWorldKnowledge
public void addWorldKnowledge(com.google.gson.JsonObject worldCommandResponseFull) Accept the input of a World Command.- Parameters:
worldCommandResponseFull- response
-
getCurrentRobot
-
getLastResponse
Return the last response from the server -
updateMemory
public void updateMemory(InputParser parsedInput, com.google.gson.JsonObject request, com.google.gson.JsonObject response, AtomicBoolean running) Take in the parsed input from the user, the response from the server, and update theMemoryaccordingly- Parameters:
parsedInput- syntactically valid input from a clientresponse- the parsed and syntactically valid response from the server
-