From 87af905bc8b85b214a33cdf7a1b803e7cce25613 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 4 Jul 2020 22:56:58 +0100 Subject: [PATCH] Rename charge command to recharge --- pkg/game/command.go | 4 ++-- pkg/game/command_test.go | 6 +++--- pkg/game/world.go | 10 +++++----- pkg/game/world_test.go | 2 +- pkg/rove/rove.pb.go | 1 + pkg/rove/rove.swagger.json | 2 +- proto/rove/rove.proto | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/pkg/game/command.go b/pkg/game/command.go index caecaec..11428c3 100644 --- a/pkg/game/command.go +++ b/pkg/game/command.go @@ -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 diff --git a/pkg/game/command_test.go b/pkg/game/command_test.go index a809753..45cb182 100644 --- a/pkg/game/command_test.go +++ b/pkg/game/command_test.go @@ -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() diff --git a/pkg/game/world.go b/pkg/game/world.go index 7e9147c..a3f1e10 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -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 } diff --git a/pkg/game/world_test.go b/pkg/game/world_test.go index b19ce97..9b4e696 100644 --- a/pkg/game/world_test.go +++ b/pkg/game/world_test.go @@ -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 diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index 38c507c..2bee993 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -43,6 +43,7 @@ type Command struct { // "move" - Move the rover in a direction, requires bearing // "stash" - Stashes item at current location in rover inventory // "repair" - Repairs the rover using an inventory object + // "recharge" - Waits a tick to add more charge to the rover Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` // The bearing, example: NE Bearing string `protobuf:"bytes,2,opt,name=bearing,proto3" json:"bearing,omitempty"` diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index 90b97fb..4e55cab 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -212,7 +212,7 @@ "properties": { "command": { "type": "string", - "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object" + "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object\n\"recharge\" - Waits a tick to add more charge to the rover" }, "bearing": { "type": "string", diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index 35b658f..73659f2 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -65,7 +65,7 @@ message Command { // "move" - Move the rover in a direction, requires bearing // "stash" - Stashes item at current location in rover inventory // "repair" - Repairs the rover using an inventory object - // "charge" - Waits a tick to add more charge to the rover + // "recharge" - Waits a tick to add more charge to the rover string command = 1; // The bearing, example: NE