Rename charge command to recharge
This commit is contained in:
parent
7272749614
commit
87af905bc8
7 changed files with 14 additions and 13 deletions
|
@ -10,8 +10,8 @@ const (
|
|||
// CommandRepair Will attempt to repair the rover with an inventory object
|
||||
CommandRepair = "repair"
|
||||
|
||||
// CommandCharge Will use one tick to charge the rover
|
||||
CommandCharge = "charge"
|
||||
// CommandRecharge Will use one tick to charge the rover
|
||||
CommandRecharge = "recharge"
|
||||
)
|
||||
|
||||
// Command represends a single command to execute
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestCommand_Move(t *testing.T) {
|
|||
assert.Equal(t, pos, newPos, "Failed to correctly set position for rover")
|
||||
}
|
||||
|
||||
func TestCommand_Charge(t *testing.T) {
|
||||
func TestCommand_Recharge(t *testing.T) {
|
||||
world := NewWorld(8)
|
||||
a, err := world.SpawnRover()
|
||||
assert.NoError(t, err)
|
||||
|
@ -56,8 +56,8 @@ func TestCommand_Charge(t *testing.T) {
|
|||
rover, _ := world.GetRover(a)
|
||||
assert.Equal(t, rover.MaximumCharge-1, rover.Charge)
|
||||
|
||||
chargeCommand := Command{Command: CommandCharge}
|
||||
assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue charge command")
|
||||
chargeCommand := Command{Command: CommandRecharge}
|
||||
assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue recharge command")
|
||||
|
||||
// Tick the world
|
||||
world.EnqueueAllIncoming()
|
||||
|
|
|
@ -134,8 +134,8 @@ func (w *World) GetRover(rover string) (Rover, error) {
|
|||
return i, nil
|
||||
}
|
||||
|
||||
// ChargeRover charges up a rover
|
||||
func (w *World) ChargeRover(rover string) (int, error) {
|
||||
// RoverRecharge charges up a rover
|
||||
func (w *World) RoverRecharge(rover string) (int, error) {
|
||||
w.worldMutex.Lock()
|
||||
defer w.worldMutex.Unlock()
|
||||
|
||||
|
@ -371,7 +371,7 @@ func (w *World) Enqueue(rover string, commands ...Command) error {
|
|||
}
|
||||
case CommandStash:
|
||||
case CommandRepair:
|
||||
case CommandCharge:
|
||||
case CommandRecharge:
|
||||
// Nothing to verify
|
||||
default:
|
||||
return fmt.Errorf("unknown command: %s", c.Command)
|
||||
|
@ -459,8 +459,8 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) {
|
|||
r.Integrity = r.Integrity + 1
|
||||
w.Rovers[rover] = r
|
||||
}
|
||||
case CommandCharge:
|
||||
_, err := w.ChargeRover(rover)
|
||||
case CommandRecharge:
|
||||
_, err := w.RoverRecharge(rover)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ func TestWorld_RoverStash(t *testing.T) {
|
|||
|
||||
// Recharge the rover
|
||||
for i := 0; i < rover.MaximumCharge; i++ {
|
||||
world.ChargeRover(a)
|
||||
world.RoverRecharge(a)
|
||||
}
|
||||
|
||||
// Place an object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue