Class FireCommand
java.lang.Object
za.co.wethinkcode.robots.server.commands.Command
za.co.wethinkcode.robots.server.commands.external.ExternalCommand
za.co.wethinkcode.robots.server.commands.external.FireCommand
Fire Command - fires a bullet in the direction the robot is facing.
Robot must exist and have at least one shot remaining. Bullet travels up to shotDistance cells in the direction the shooter is facing. The bullet stops when it hits a wall or obstacle.
If the bullet hits another robo, that robot takes 1 damage If that robot's shield drops to 0, the robot is destroyed and removed from the world
A robot cannot shoot itself
1 shot is consumed from robots ammo regardless of whether the shot hit or not.
-
Constructor Summary
ConstructorsConstructorDescriptionFireCommand(com.google.gson.JsonObject json) Construct a fire command from the incoming JSONFireCommand(String robotName) -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gson.JsonObjectModern OO implementation of the execute methodexecuteToString(World world) Each command must implement this method It does the work and returns a resultReturn which client command this command implementsgetUsage()Get the way this command is supposed to be used.Methods inherited from class za.co.wethinkcode.robots.server.commands.external.ExternalCommand
getArgsMethods inherited from class za.co.wethinkcode.robots.server.commands.Command
findRobot, getRobotName
-
Constructor Details
-
FireCommand
-
FireCommand
public FireCommand(com.google.gson.JsonObject json) Construct a fire command from the incoming JSON- Parameters:
json- the incoming JSON
-
-
Method Details
-
getCommandName
Return which client command this command implements- Specified by:
getCommandNamein classExternalCommand- Returns:
- the command this child is
-
getUsage
Get the way this command is supposed to be used.- Specified by:
getUsagein classExternalCommand- Returns:
- the string representation of the usage of this command.
-
executeToString
Description copied from class:CommandEach command must implement this method It does the work and returns a result- Specified by:
executeToStringin classCommand
-
execute
Modern OO implementation of the execute method
-