public class FireCommand extends ExternalCommand
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 Details

    • FireCommand

      public FireCommand(String robotName)
    • FireCommand

      public FireCommand(com.google.gson.JsonObject json)
      Construct a fire command from the incoming JSON
      Parameters:
      json - the incoming JSON
  • Method Details

    • getCommandName

      public ImplementedClientCommands getCommandName()
      Return which client command this command implements
      Specified by:
      getCommandName in class ExternalCommand
      Returns:
      the command this child is
    • getUsage

      public String getUsage()
      Get the way this command is supposed to be used.
      Specified by:
      getUsage in class ExternalCommand
      Returns:
      the string representation of the usage of this command.
    • executeToString

      public String executeToString(World world)
      Description copied from class: Command
      Each command must implement this method It does the work and returns a result
      Specified by:
      executeToString in class Command
    • execute

      public com.google.gson.JsonObject execute(World world)
      Modern OO implementation of the execute method
      Specified by:
      execute in class Command
      Parameters:
      world -