From 6b5d5abea174039e17efe1de2ee26aaa897158f6 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 22 Jul 2020 19:24:36 +0100 Subject: [PATCH] Rename the world tick function and set the tick rate back to default --- cmd/rove-server/internal/server.go | 4 ++-- docker-compose.yml | 1 - pkg/rove/command_test.go | 6 +++--- pkg/rove/world.go | 4 ++-- pkg/rove/world_test.go | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/rove-server/internal/server.go b/cmd/rove-server/internal/server.go index 102c30d..786eb00 100644 --- a/cmd/rove-server/internal/server.go +++ b/cmd/rove-server/internal/server.go @@ -131,8 +131,8 @@ func (s *Server) Run() { log.Println("Executing server tick") - // Run the command queues - s.world.ExecuteCommandQueues() + // Tick the world + s.world.Tick() // Save out the new world state if err := s.SaveWorld(); err != nil { diff --git a/docker-compose.yml b/docker-compose.yml index 71013b5..509af03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,6 @@ services: - PORT=9090 - DATA_PATH=/mnt/rove-server - WORDS_FILE=data/words_alpha.txt - - TICK_RATE=5 volumes: - persistent-data:/mnt/rove-server:rw command: [ "./rove-server"] diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 26c5e56..773b098 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -18,7 +18,7 @@ func TestCommand_Toggle(t *testing.T) { w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) w.EnqueueAllIncoming() - w.ExecuteCommandQueues() + w.Tick() r, err = w.GetRover(a) assert.NoError(t, err) @@ -26,7 +26,7 @@ func TestCommand_Toggle(t *testing.T) { w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) w.EnqueueAllIncoming() - w.ExecuteCommandQueues() + w.Tick() r, err = w.GetRover(a) assert.NoError(t, err) @@ -40,7 +40,7 @@ func TestCommand_Turn(t *testing.T) { w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest}) w.EnqueueAllIncoming() - w.ExecuteCommandQueues() + w.Tick() r, err := w.GetRover(a) assert.NoError(t, err) diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 5e8483f..e50fa6f 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -464,8 +464,8 @@ func (w *World) EnqueueAllIncoming() { w.CommandIncoming = make(map[string]CommandStream) } -// ExecuteCommandQueues will execute any commands in the current command queue -func (w *World) ExecuteCommandQueues() { +// Tick will execute any commands in the current command queue and tick the world +func (w *World) Tick() { w.cmdMutex.Lock() defer w.cmdMutex.Unlock() diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index ffac1af..785baa2 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -343,7 +343,7 @@ func TestWorld_Daytime(t *testing.T) { // Loop for half the day for i := 0; i < world.TicksPerDay/2; i++ { assert.True(t, world.Daytime()) - world.ExecuteCommandQueues() + world.Tick() } // Remove rover charge again @@ -359,7 +359,7 @@ func TestWorld_Daytime(t *testing.T) { // Loop for half the day for i := 0; i < world.TicksPerDay/2; i++ { assert.False(t, world.Daytime()) - world.ExecuteCommandQueues() + world.Tick() } }