diff --git a/cmd/rove-server/internal/accounts.go b/cmd/rove-server/internal/accounts.go index 99362ad..9ae6db9 100644 --- a/cmd/rove-server/internal/accounts.go +++ b/cmd/rove-server/internal/accounts.go @@ -21,8 +21,8 @@ type Accountant interface { // Account represents a registered user type Account struct { // Name simply describes the account and must be unique - Name string `json:"name"` + Name string // Data represents internal account data - Data map[string]string `json:"data"` + Data map[string]string } diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 0fb41d8..6cb5a99 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -5,7 +5,6 @@ import ( "fmt" "log" - "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/version" "github.com/mdiluz/rove/proto/roveapi" ) @@ -76,40 +75,7 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon inv = append(inv, byte(i.Type)) } - i, q := s.world.RoverCommands(resp) - var incoming, queued []*roveapi.Command - for _, i := range i { - c := &roveapi.Command{ - Command: i.Command, - } - switch i.Command { - case roveapi.CommandType_move: - c.Data = &roveapi.Command_Bearing{ - Bearing: i.Bearing, - } - case roveapi.CommandType_broadcast: - c.Data = &roveapi.Command_Message{ - Message: i.Message, - } - } - incoming = append(incoming, c) - } - for _, q := range q { - c := &roveapi.Command{ - Command: q.Command, - } - switch q.Command { - case roveapi.CommandType_move: - c.Data = &roveapi.Command_Bearing{ - Bearing: q.Bearing, - } - case roveapi.CommandType_broadcast: - c.Data = &roveapi.Command_Message{ - Message: q.Message, - } - } - queued = append(queued, c) - } + incoming, queued := s.world.RoverCommands(resp) var logs []*roveapi.Log for _, log := range rover.Logs { logs = append(logs, &roveapi.Log{ @@ -124,6 +90,7 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon X: int32(rover.Pos.X), Y: int32(rover.Pos.Y), }, + Bearing: rover.Bearing, Range: int32(rover.Range), Inventory: inv, Capacity: int32(rover.Capacity), @@ -133,7 +100,9 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon MaximumCharge: int32(rover.MaximumCharge), IncomingCommands: incoming, QueuedCommands: queued, + SailPosition: rover.SailPosition, Logs: logs, + Wind: s.world.Wind, } } return response, nil @@ -187,21 +156,7 @@ func (s *Server) Command(ctx context.Context, req *roveapi.CommandRequest) (*rov return nil, err } - var cmds []rove.Command - for _, c := range req.Commands { - n := rove.Command{ - Command: c.Command, - } - switch c.Command { - case roveapi.CommandType_move: - n.Bearing = c.GetBearing() - case roveapi.CommandType_broadcast: - n.Message = c.GetMessage() - } - cmds = append(cmds, n) - } - - if err := s.world.Enqueue(resp, cmds...); err != nil { + if err := s.world.Enqueue(resp, req.Commands...); err != nil { return nil, err } 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/cmd/rove-server/internal/simpleAccountant.go b/cmd/rove-server/internal/simpleAccountant.go index 3168f30..611ff59 100644 --- a/cmd/rove-server/internal/simpleAccountant.go +++ b/cmd/rove-server/internal/simpleAccountant.go @@ -9,7 +9,7 @@ import ( // SimpleAccountant manages a set of accounts type SimpleAccountant struct { - Accounts map[string]Account `json:"accounts"` + Accounts map[string]Account } // NewSimpleAccountant creates a new accountant diff --git a/cmd/rove/main.go b/cmd/rove/main.go index bd98d52..01e16ae 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -33,10 +33,9 @@ func printUsage() { fmt.Fprintln(os.Stderr, "\thelp outputs this usage information") fmt.Fprintln(os.Stderr, "\tversion outputs version info") fmt.Fprintln(os.Stderr, "\nRover commands:") - fmt.Fprintln(os.Stderr, "\tmove BEARING moves the rover in the chosen direction") + fmt.Fprintln(os.Stderr, "\ttoggle toggles the sails, either catching the wind, or charging from the sun") fmt.Fprintln(os.Stderr, "\tstash stores the object at the rover location in the inventory") fmt.Fprintln(os.Stderr, "\trepair uses an inventory object to repair the rover") - fmt.Fprintln(os.Stderr, "\trecharge wait a tick to recharge the rover") fmt.Fprintln(os.Stderr, "\tbroadcast MSG broadcast a simple ASCII triplet to nearby rovers") fmt.Fprintln(os.Stderr, "\nEnvironment") fmt.Fprintln(os.Stderr, "\tROVE_USER_DATA path to user data, defaults to "+defaultDataPath) @@ -46,14 +45,14 @@ const gRPCport = 9090 // Account stores data for an account type Account struct { - Name string `json:"name"` - Secret string `json:"secret"` + Name string + Secret string } // Config is used to store internal data type Config struct { - Host string `json:"host,omitempty"` - Account Account `json:"account,omitempty"` + Host string + Account Account } // ConfigPath returns the configuration path @@ -128,12 +127,20 @@ func BearingFromString(s string) roveapi.Bearing { switch s { case "N": return roveapi.Bearing_North + case "NE": + return roveapi.Bearing_NorthEast case "E": return roveapi.Bearing_East + case "SE": + return roveapi.Bearing_SouthEast case "S": return roveapi.Bearing_South + case "SW": + return roveapi.Bearing_SouthWest case "W": return roveapi.Bearing_West + case "NW": + return roveapi.Bearing_NorthWest } return roveapi.Bearing_BearingUnknown } @@ -225,19 +232,19 @@ func InnerMain(command string, args ...string) error { var commands []*roveapi.Command for i := 0; i < len(args); i++ { switch args[i] { - case "move": + case "turn": i++ if len(args) == i { - return fmt.Errorf("move command must be passed bearing") + return fmt.Errorf("turn command must be passed a compass bearing") } - var b roveapi.Bearing - if b = BearingFromString(args[i]); b == roveapi.Bearing_BearingUnknown { - return fmt.Errorf("unrecognised bearing: %s", args[i]) + b := BearingFromString(args[i]) + if b == roveapi.Bearing_BearingUnknown { + return fmt.Errorf("turn command must be given a valid bearing %s", args[i]) } commands = append(commands, &roveapi.Command{ - Command: roveapi.CommandType_move, - Data: &roveapi.Command_Bearing{Bearing: b}, + Command: roveapi.CommandType_broadcast, + Broadcast: []byte(args[i]), }, ) case "broadcast": @@ -249,8 +256,8 @@ func InnerMain(command string, args ...string) error { } commands = append(commands, &roveapi.Command{ - Command: roveapi.CommandType_broadcast, - Data: &roveapi.Command_Message{Message: []byte(args[i])}, + Command: roveapi.CommandType_broadcast, + Broadcast: []byte(args[i]), }, ) default: diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index dd588e1..2eb564c 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -50,12 +50,12 @@ func Test_InnerMain(t *testing.T) { assert.Error(t, InnerMain("command")) // Give it commands - assert.NoError(t, InnerMain("command", "move", "N")) + assert.NoError(t, InnerMain("command", "toggle")) assert.NoError(t, InnerMain("command", "stash")) assert.NoError(t, InnerMain("command", "repair")) assert.NoError(t, InnerMain("command", "broadcast", "abc")) // Give it malformed commands - assert.Error(t, InnerMain("command", "move", "stash")) + assert.Error(t, InnerMain("command", "unknown")) assert.Error(t, InnerMain("command", "broadcast")) } diff --git a/docker-compose.yml b/docker-compose.yml index 71013b5..f1962a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: - PORT=9090 - DATA_PATH=/mnt/rove-server - WORDS_FILE=data/words_alpha.txt - - TICK_RATE=5 + - TICK_RATE=3 volumes: - persistent-data:/mnt/rove-server:rw command: [ "./rove-server"] diff --git a/pkg/maths/vector.go b/pkg/maths/vector.go index 8a63708..a74ff16 100644 --- a/pkg/maths/vector.go +++ b/pkg/maths/vector.go @@ -8,8 +8,8 @@ import ( // Vector desribes a 3D vector type Vector struct { - X int `json:"x"` - Y int `json:"y"` + X int + Y int } // Add adds one vector to another @@ -89,13 +89,31 @@ func BearingToVector(b roveapi.Bearing) Vector { switch b { case roveapi.Bearing_North: return Vector{Y: 1} + case roveapi.Bearing_NorthEast: + return Vector{X: 1, Y: 1} case roveapi.Bearing_East: return Vector{X: 1} + case roveapi.Bearing_SouthEast: + return Vector{X: 1, Y: -1} case roveapi.Bearing_South: return Vector{Y: -1} + case roveapi.Bearing_SouthWest: + return Vector{X: -1, Y: -1} case roveapi.Bearing_West: return Vector{X: -1} + case roveapi.Bearing_NorthWest: + return Vector{X: -1, Y: 1} } return Vector{} } + +// Dot returns the dot product of two vectors +func Dot(a Vector, b Vector) int { + return a.X*b.X + a.Y*b.Y +} + +// AngleCos returns the cosine of the angle between two vectors +func AngleCos(a Vector, b Vector) float64 { + return float64(Dot(a, b)) / a.Length() * b.Length() +} diff --git a/pkg/rove/chunkAtlas.go b/pkg/rove/chunkAtlas.go index f7ea36c..88f1102 100644 --- a/pkg/rove/chunkAtlas.go +++ b/pkg/rove/chunkAtlas.go @@ -11,27 +11,27 @@ import ( // chunk represents a fixed square grid of tiles type chunk struct { // Tiles represents the tiles within the chunk - Tiles []byte `json:"tiles"` + Tiles []byte // Objects represents the objects within the chunk // only one possible object per tile for now - Objects map[int]Object `json:"objects"` + Objects map[int]Object } // chunkBasedAtlas represents a grid of Chunks type chunkBasedAtlas struct { // Chunks represents all chunks in the world // This is intentionally not a 2D array so it can be expanded in all directions - Chunks []chunk `json:"chunks"` + Chunks []chunk // LowerBound is the origin of the bottom left corner of the current chunks in world space (current chunks cover >= this value) - LowerBound maths.Vector `json:"lowerBound"` + LowerBound maths.Vector // UpperBound is the top left corner of the current chunks (curent chunks cover < this value) - UpperBound maths.Vector `json:"upperBound"` + UpperBound maths.Vector // ChunkSize is the x/y dimensions of each square chunk - ChunkSize int `json:"chunksize"` + ChunkSize int // worldGen is the internal world generator worldGen WorldGen diff --git a/pkg/rove/command.go b/pkg/rove/command.go deleted file mode 100644 index e64d646..0000000 --- a/pkg/rove/command.go +++ /dev/null @@ -1,17 +0,0 @@ -package rove - -import "github.com/mdiluz/rove/proto/roveapi" - -// Command represends a single command to execute -type Command struct { - Command roveapi.CommandType `json:"command"` - - // Used in the move command - Bearing roveapi.Bearing `json:"bearing,omitempty"` - - // Used in the broadcast command - Message []byte `json:"message,omitempty"` -} - -// CommandStream is a list of commands to execute in order -type CommandStream []Command diff --git a/pkg/rove/command_test.go b/pkg/rove/command_test.go index 337782f..536f656 100644 --- a/pkg/rove/command_test.go +++ b/pkg/rove/command_test.go @@ -3,68 +3,65 @@ package rove import ( "testing" - "github.com/mdiluz/rove/pkg/maths" "github.com/mdiluz/rove/proto/roveapi" "github.com/stretchr/testify/assert" ) -func TestCommand_Move(t *testing.T) { - world := NewWorld(8) - a, err := world.SpawnRover() +func TestCommand_Toggle(t *testing.T) { + w := NewWorld(8) + a, err := w.SpawnRover() assert.NoError(t, err) - pos := maths.Vector{ - X: 1.0, - Y: 2.0, - } - err = world.WarpRover(a, pos) - assert.NoError(t, err, "Failed to set position for rover") + r, err := w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_SolarCharging, r.SailPosition) - // Try the move command - moveCommand := Command{Command: roveapi.CommandType_move, Bearing: roveapi.Bearing_North} - assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to execute move command") + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) + assert.NoError(t, err) + w.EnqueueAllIncoming() + w.Tick() - // Tick the world - world.EnqueueAllIncoming() - world.ExecuteCommandQueues() + r, err = w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_CatchingWind, r.SailPosition) - newPos, err := world.RoverPosition(a) - assert.NoError(t, err, "Failed to set position for rover") - pos.Add(maths.Vector{X: 0.0, Y: 1}) - assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_toggle}) + assert.NoError(t, err) + w.EnqueueAllIncoming() + w.Tick() + + r, err = w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_SolarCharging, r.SailPosition) } -func TestCommand_Recharge(t *testing.T) { - world := NewWorld(8) - a, err := world.SpawnRover() +func TestCommand_Turn(t *testing.T) { + w := NewWorld(8) + a, err := w.SpawnRover() assert.NoError(t, err) - pos := maths.Vector{ - X: 1.0, - Y: 2.0, - } - err = world.WarpRover(a, pos) - assert.NoError(t, err, "Failed to set position for rover") - - // Move to use up some charge - moveCommand := Command{Command: roveapi.CommandType_move, Bearing: roveapi.Bearing_North} - assert.NoError(t, world.Enqueue(a, moveCommand), "Failed to queue move command") - - // Tick the world - world.EnqueueAllIncoming() - world.ExecuteCommandQueues() - - rover, _ := world.GetRover(a) - assert.Equal(t, rover.MaximumCharge-1, rover.Charge) - - chargeCommand := Command{Command: roveapi.CommandType_recharge} - assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue recharge command") - - // Tick the world - world.EnqueueAllIncoming() - world.ExecuteCommandQueues() - - rover, _ = world.GetRover(a) - assert.Equal(t, rover.MaximumCharge, rover.Charge) + err = w.Enqueue(a, &roveapi.Command{Command: roveapi.CommandType_turn, Turn: roveapi.Bearing_NorthWest}) + assert.NoError(t, err) + w.EnqueueAllIncoming() + w.Tick() + r, err := w.GetRover(a) + assert.NoError(t, err) + assert.Equal(t, roveapi.Bearing_NorthWest, r.Bearing) +} + +func TestCommand_Stash(t *testing.T) { + // TODO: Test the stash command +} + +func TestCommand_Repair(t *testing.T) { + // TODO: Test the repair command +} + +func TestCommand_Broadcast(t *testing.T) { + // TODO: Test the stash command +} + +func TestCommand_Invalid(t *testing.T) { + // TODO: Test an invalid command } diff --git a/pkg/rove/objects.go b/pkg/rove/objects.go index 94595df..f1ce227 100644 --- a/pkg/rove/objects.go +++ b/pkg/rove/objects.go @@ -7,10 +7,10 @@ import ( // Object represents an object in the world type Object struct { // The type of the object - Type roveapi.Object `json:"type"` + Type roveapi.Object // Data is an internal type used for certain types of object - Data []byte `json:"data"` + Data []byte } // IsBlocking checks if an object is a blocking object diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index 6968c57..fb13ddc 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -10,59 +10,71 @@ import ( "github.com/google/uuid" "github.com/mdiluz/rove/pkg/maths" + "github.com/mdiluz/rove/proto/roveapi" ) // RoverLogEntry describes a single log entry for the rover type RoverLogEntry struct { // Time is the timestamp of the entry - Time time.Time `json:"time"` + Time time.Time // Text contains the information in this log entry - Text string `json:"text"` + Text string } // Rover describes a single rover in the world type Rover struct { // Unique name of this rover - Name string `json:"name"` + Name string // Pos represents where this rover is in the world - Pos maths.Vector `json:"pos"` + Pos maths.Vector + + // Bearing is the current direction the rover is facing + Bearing roveapi.Bearing // Range represents the distance the unit's radar can see - Range int `json:"range"` + Range int // Inventory represents any items the rover is carrying - Inventory []Object `json:"inventory"` + Inventory []Object // Capacity is the maximum number of inventory items - Capacity int `json:"capacity"` + Capacity int // Integrity represents current rover health - Integrity int `json:"integrity"` + Integrity int // MaximumIntegrity is the full integrity of the rover - MaximumIntegrity int `json:"maximum-integrity"` + MaximumIntegrity int // Charge is the amount of energy the rover has - Charge int `json:"charge"` + Charge int // MaximumCharge is the maximum charge able to be stored - MaximumCharge int `json:"maximum-Charge"` + MaximumCharge int + + // SailPosition is the current position of the sails + SailPosition roveapi.SailPosition + + // Current number of ticks in this move, used for sailing speeds + MoveTicks int // Logs Stores log of information - Logs []RoverLogEntry `json:"logs"` + Logs []RoverLogEntry } // DefaultRover returns a default rover object with default settings -func DefaultRover() Rover { - return Rover{ +func DefaultRover() *Rover { + return &Rover{ Range: 4, Integrity: 10, MaximumIntegrity: 10, Capacity: 10, Charge: 10, MaximumCharge: 10, + Bearing: roveapi.Bearing_North, + SailPosition: roveapi.SailPosition_SolarCharging, Name: GenerateRoverName(), } } diff --git a/pkg/rove/world.go b/pkg/rove/world.go index 25aa933..1fa166d 100644 --- a/pkg/rove/world.go +++ b/pkg/rove/world.go @@ -10,24 +10,35 @@ import ( "github.com/mdiluz/rove/proto/roveapi" ) +const ( + TicksPerNormalMove = 4 +) + +// CommandStream is a list of commands to execute in order +type CommandStream []*roveapi.Command + // World describes a self contained universe and everything in it type World struct { + // TicksPerDay is the amount of ticks in a single day - TicksPerDay int `json:"ticks-per-day"` + TicksPerDay int // Current number of ticks from the start - CurrentTicks int `json:"current-ticks"` + CurrentTicks int // Rovers is a id->data map of all the rovers in the game - Rovers map[string]Rover `json:"rovers"` + Rovers map[string]*Rover // Atlas represends the world map of chunks and tiles - Atlas Atlas `json:"atlas"` + Atlas Atlas + + // Wind is the current wind direction + Wind roveapi.Bearing // Commands is the set of currently executing command streams per rover - CommandQueue map[string]CommandStream `json:"commands"` + CommandQueue map[string]CommandStream // Incoming represents the set of commands to add to the queue at the end of the current tick - CommandIncoming map[string]CommandStream `json:"incoming"` + CommandIncoming map[string]CommandStream // Mutex to lock around all world operations worldMutex sync.RWMutex @@ -38,7 +49,7 @@ type World struct { // NewWorld creates a new world object func NewWorld(chunkSize int) *World { return &World{ - Rovers: make(map[string]Rover), + Rovers: make(map[string]*Rover), CommandQueue: make(map[string]CommandStream), CommandIncoming: make(map[string]CommandStream), Atlas: NewChunkAtlas(chunkSize), @@ -91,7 +102,7 @@ func (w *World) GetRover(rover string) (Rover, error) { if !ok { return Rover{}, fmt.Errorf("Failed to find rover with name: %s", rover) } - return i, nil + return *i, nil } // RoverRecharge charges up a rover @@ -114,7 +125,6 @@ func (w *World) RoverRecharge(rover string) (int, error) { i.Charge++ i.AddLogEntryf("recharged to %d", i.Charge) } - w.Rovers[rover] = i return i.Charge, nil } @@ -149,7 +159,6 @@ func (w *World) RoverBroadcast(rover string, message []byte) (err error) { } i.AddLogEntryf("broadcasted %s", string(message)) - w.Rovers[rover] = i return } @@ -190,7 +199,6 @@ func (w *World) SetRoverPosition(rover string, pos maths.Vector) error { } i.Pos = pos - w.Rovers[rover] = i return nil } @@ -227,12 +235,11 @@ func (w *World) WarpRover(rover string, pos maths.Vector) error { } i.Pos = pos - w.Rovers[rover] = i return nil } -// MoveRover attempts to move a rover in a specific direction -func (w *World) MoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) { +// TryMoveRover attempts to move a rover in a specific direction +func (w *World) TryMoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) { w.worldMutex.Lock() defer w.worldMutex.Unlock() @@ -241,12 +248,6 @@ func (w *World) MoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) return maths.Vector{}, fmt.Errorf("no rover matching id") } - // Ensure the rover has energy - if i.Charge <= 0 { - return i.Pos, nil - } - i.Charge-- - // Try the new move position newPos := i.Pos.Added(maths.BearingToVector(b)) @@ -256,17 +257,14 @@ func (w *World) MoveRover(rover string, b roveapi.Bearing) (maths.Vector, error) i.AddLogEntryf("moved %s to %+v", b.String(), newPos) // Perform the move i.Pos = newPos - w.Rovers[rover] = i } else { // If it is a blocking tile, reduce the rover integrity i.AddLogEntryf("tried to move %s to %+v", b.String(), newPos) i.Integrity = i.Integrity - 1 i.AddLogEntryf("had a collision, new integrity %d", i.Integrity) - if i.Integrity == 0 { - // TODO: The rover needs to be left dormant with the player - } else { - w.Rovers[rover] = i - } + // TODO: The rover needs to be left dormant with the player + //if i.Integrity == 0 { + //} } return i.Pos, nil @@ -300,11 +298,72 @@ func (w *World) RoverStash(rover string) (roveapi.Object, error) { r.AddLogEntryf("stashed %c", obj.Type) r.Inventory = append(r.Inventory, obj) - w.Rovers[rover] = r w.Atlas.SetObject(r.Pos, Object{Type: roveapi.Object_ObjectUnknown}) return obj.Type, nil } +// RoverToggle will toggle the sail position +func (w *World) RoverToggle(rover string) (roveapi.SailPosition, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + r, ok := w.Rovers[rover] + if !ok { + return roveapi.SailPosition_UnknownSailPosition, fmt.Errorf("no rover matching id") + } + + // Swap the sail position + switch r.SailPosition { + case roveapi.SailPosition_CatchingWind: + r.SailPosition = roveapi.SailPosition_SolarCharging + case roveapi.SailPosition_SolarCharging: + r.SailPosition = roveapi.SailPosition_CatchingWind + } + + // Reset the movement ticks + r.MoveTicks = 0 + + return r.SailPosition, nil +} + +// RoverTurn will turn the rover +func (w *World) RoverTurn(rover string, bearing roveapi.Bearing) (roveapi.Bearing, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + r, ok := w.Rovers[rover] + if !ok { + return roveapi.Bearing_BearingUnknown, fmt.Errorf("no rover matching id") + } + + // Set the new bearing + r.Bearing = bearing + // Reset the movement ticks + r.MoveTicks = 0 + + return r.Bearing, nil +} + +// RoverRepair will turn the rover +func (w *World) RoverRepair(rover string) (int, error) { + w.worldMutex.Lock() + defer w.worldMutex.Unlock() + + r, ok := w.Rovers[rover] + if !ok { + return 0, fmt.Errorf("no rover matching id") + } + + // Consume an inventory item to repair if possible + if len(r.Inventory) > 0 && r.Integrity < r.MaximumIntegrity { + r.Inventory = r.Inventory[:len(r.Inventory)-1] + r.Integrity = r.Integrity + 1 + r.AddLogEntryf("repaired self to %d", r.Integrity) + } + + return r.Integrity, nil +} + // RadarFromRover can be used to query what a rover can currently see func (w *World) RadarFromRover(rover string) (radar []roveapi.Tile, objs []roveapi.Object, err error) { w.worldMutex.RLock() @@ -364,7 +423,7 @@ func (w *World) RadarFromRover(rover string) (radar []roveapi.Tile, objs []rovea } // RoverCommands returns current commands for the given rover -func (w *World) RoverCommands(rover string) (incoming []Command, queued []Command) { +func (w *World) RoverCommands(rover string) (incoming CommandStream, queued CommandStream) { if c, ok := w.CommandIncoming[rover]; ok { incoming = c } @@ -375,27 +434,27 @@ func (w *World) RoverCommands(rover string) (incoming []Command, queued []Comman } // Enqueue will queue the commands given -func (w *World) Enqueue(rover string, commands ...Command) error { +func (w *World) Enqueue(rover string, commands ...*roveapi.Command) error { // First validate the commands for _, c := range commands { switch c.Command { - case roveapi.CommandType_move: - if c.Bearing == roveapi.Bearing_BearingUnknown { - return fmt.Errorf("bearing must be valid") - } case roveapi.CommandType_broadcast: - if len(c.Message) > 3 { - return fmt.Errorf("too many characters in message (limit 3): %d", len(c.Message)) + if len(c.GetBroadcast()) > 3 { + return fmt.Errorf("too many characters in message (limit 3): %d", len(c.GetBroadcast())) } - for _, b := range c.Message { + for _, b := range c.GetBroadcast() { if b < 37 || b > 126 { return fmt.Errorf("invalid message character: %c", b) } } + case roveapi.CommandType_turn: + if c.GetTurn() == roveapi.Bearing_BearingUnknown { + return fmt.Errorf("turn command given unknown bearing") + } + case roveapi.CommandType_toggle: case roveapi.CommandType_stash: case roveapi.CommandType_repair: - case roveapi.CommandType_recharge: // Nothing to verify default: return fmt.Errorf("unknown command: %s", c.Command) @@ -406,7 +465,6 @@ func (w *World) Enqueue(rover string, commands ...Command) error { w.cmdMutex.Lock() defer w.cmdMutex.Unlock() - // Override the incoming command set w.CommandIncoming[rover] = commands return nil @@ -423,24 +481,24 @@ 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() // Iterate through all the current commands for rover, cmds := range w.CommandQueue { if len(cmds) != 0 { - // Extract the first command in the queue - c := cmds[0] - w.CommandQueue[rover] = cmds[1:] // Execute the command - if err := w.ExecuteCommand(&c, rover); err != nil { + if err := w.ExecuteCommand(cmds[0], rover); err != nil { log.Println(err) // TODO: Report this error somehow } + // Extract the first command in the queue + w.CommandQueue[rover] = cmds[1:] + } else { // Clean out the empty entry delete(w.CommandQueue, rover) @@ -450,46 +508,97 @@ func (w *World) ExecuteCommandQueues() { // Add any incoming commands from this tick and clear that queue w.EnqueueAllIncoming() + // Change the wind every day + if (w.CurrentTicks % w.TicksPerDay) == 0 { + w.Wind = roveapi.Bearing((rand.Int() % 8) + 1) // Random cardinal bearing + } + + // Move all the rovers based on current wind and sails + for n, r := range w.Rovers { + // Skip if we're not catching the wind + if r.SailPosition != roveapi.SailPosition_CatchingWind { + continue + } + + // Increment the current move ticks + r.MoveTicks++ + + // Get the difference between the two bearings + // Normalise, we don't care about clockwise/anticlockwise + diff := maths.Abs(int(w.Wind - r.Bearing)) + if diff > 4 { + diff = 8 - diff + } + + // Calculate the travel "ticks" + var ticksToMove int + switch diff { + case 0: + // Going with the wind, travel at base speed of once every 4 ticks + ticksToMove = TicksPerNormalMove + case 1: + // At a slight angle, we can go a little faster + ticksToMove = TicksPerNormalMove / 2 + case 2: + // Perpendicular to wind, max speed + ticksToMove = 1 + case 3: + // Heading at 45 degrees into the wind, back to min speed + ticksToMove = TicksPerNormalMove + case 4: + // Heading durectly into the wind, no movement at all + default: + log.Fatalf("bearing difference of %d should be impossible", diff) + } + + // If we've incremented over the current move ticks on the rover, we can try and make the move + if ticksToMove != 0 && r.MoveTicks >= ticksToMove { + _, err := w.TryMoveRover(n, r.Bearing) + if err != nil { + log.Println(err) + // TODO: Report this error somehow + } + + // Reset the move ticks + r.MoveTicks = 0 + } + + log.Print(ticksToMove) + } + // Increment the current tick count w.CurrentTicks++ } // ExecuteCommand will execute a single command -func (w *World) ExecuteCommand(c *Command, rover string) (err error) { - log.Printf("Executing command: %+v for %s\n", *c, rover) +func (w *World) ExecuteCommand(c *roveapi.Command, rover string) (err error) { + log.Printf("Executing command: %+v for %s\n", c.Command, rover) switch c.Command { - case roveapi.CommandType_move: - if _, err := w.MoveRover(rover, c.Bearing); err != nil { + case roveapi.CommandType_toggle: + if _, err := w.RoverToggle(rover); err != nil { return err } - case roveapi.CommandType_stash: if _, err := w.RoverStash(rover); err != nil { return err } case roveapi.CommandType_repair: - r, err := w.GetRover(rover) - if err != nil { - return err - } - // Consume an inventory item to repair if possible - if len(r.Inventory) > 0 && r.Integrity < r.MaximumIntegrity { - r.Inventory = r.Inventory[:len(r.Inventory)-1] - r.Integrity = r.Integrity + 1 - r.AddLogEntryf("repaired self to %d", r.Integrity) - w.Rovers[rover] = r - } - case roveapi.CommandType_recharge: - _, err := w.RoverRecharge(rover) - if err != nil { + if _, err := w.RoverRepair(rover); err != nil { return err } + case roveapi.CommandType_broadcast: - if err := w.RoverBroadcast(rover, c.Message); err != nil { + if err := w.RoverBroadcast(rover, c.GetBroadcast()); err != nil { return err } + + case roveapi.CommandType_turn: + if _, err := w.RoverTurn(rover, c.GetTurn()); err != nil { + return err + } + default: return fmt.Errorf("unknown command: %s", c.Command) } diff --git a/pkg/rove/world_test.go b/pkg/rove/world_test.go index f393f3d..a3c2f47 100644 --- a/pkg/rove/world_test.go +++ b/pkg/rove/world_test.go @@ -78,25 +78,20 @@ func TestWorld_GetSetMovePosition(t *testing.T) { assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") b := roveapi.Bearing_North - newPos, err = world.MoveRover(a, b) + newPos, err = world.TryMoveRover(a, b) assert.NoError(t, err, "Failed to set position for rover") pos.Add(maths.Vector{X: 0, Y: 1}) assert.Equal(t, pos, newPos, "Failed to correctly move position for rover") rover, err := world.GetRover(a) assert.NoError(t, err, "Failed to get rover information") - assert.Equal(t, rover.MaximumCharge-1, rover.Charge, "Rover should have lost charge for moving") assert.Contains(t, rover.Logs[len(rover.Logs)-1].Text, "moved", "Rover logs should contain the move") // Place a tile in front of the rover world.Atlas.SetObject(maths.Vector{X: 0, Y: 2}, Object{Type: roveapi.Object_RockLarge}) - newPos, err = world.MoveRover(a, b) + newPos, err = world.TryMoveRover(a, b) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, newPos, "Failed to correctly not move position for rover into wall") - - rover, err = world.GetRover(a) - assert.NoError(t, err, "Failed to get rover information") - assert.Equal(t, rover.MaximumCharge-2, rover.Charge, "Rover should have lost charge for move attempt") } func TestWorld_RadarFromRover(t *testing.T) { @@ -224,7 +219,7 @@ func TestWorld_RoverDamage(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, Object{Type: roveapi.Object_RockLarge}) - vec, err := world.MoveRover(a, roveapi.Bearing_North) + vec, err := world.TryMoveRover(a, roveapi.Bearing_North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -261,7 +256,7 @@ func TestWorld_RoverRepair(t *testing.T) { world.Atlas.SetObject(maths.Vector{X: 0.0, Y: 1.0}, Object{Type: roveapi.Object_RockLarge}) // Try and bump into the rock - vec, err := world.MoveRover(a, roveapi.Bearing_North) + vec, err := world.TryMoveRover(a, roveapi.Bearing_North) assert.NoError(t, err, "Failed to move rover") assert.Equal(t, pos, vec, "Rover managed to move into large rock") @@ -269,7 +264,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "couldn't get rover info") assert.Equal(t, originalInfo.Integrity-1, newinfo.Integrity, "rover should have lost integrity") - err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) + err = world.ExecuteCommand(&roveapi.Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") newinfo, err = world.GetRover(a) @@ -283,7 +278,7 @@ func TestWorld_RoverRepair(t *testing.T) { assert.NoError(t, err, "Failed to stash") assert.Equal(t, roveapi.Object_RockSmall, o, "Failed to get correct object") - err = world.ExecuteCommand(&Command{Command: roveapi.CommandType_repair}, a) + err = world.ExecuteCommand(&roveapi.Command{Command: roveapi.CommandType_repair}, a) assert.NoError(t, err, "Failed to repair rover") newinfo, err = world.GetRover(a) @@ -291,39 +286,6 @@ func TestWorld_RoverRepair(t *testing.T) { assert.Equal(t, originalInfo.Integrity, newinfo.Integrity, "rover should have kept the same integrity") } -func TestWorld_Charge(t *testing.T) { - world := NewWorld(4) - a, err := world.SpawnRover() - assert.NoError(t, err) - - // Get the rover information - rover, err := world.GetRover(a) - assert.NoError(t, err, "Failed to get rover information") - assert.Equal(t, rover.MaximumCharge, rover.Charge, "Rover should start with maximum charge") - - // Use up all the charge - for i := 0; i < rover.MaximumCharge; i++ { - // Get the initial position - initialPos, err := world.RoverPosition(a) - assert.NoError(t, err, "Failed to get position for rover") - - // Ensure the path ahead is empty - world.Atlas.SetTile(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), roveapi.Tile_Rock) - world.Atlas.SetObject(initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), Object{Type: roveapi.Object_ObjectUnknown}) - - // Try and move north (along unblocked path) - newPos, err := world.MoveRover(a, roveapi.Bearing_North) - assert.NoError(t, err, "Failed to set position for rover") - assert.Equal(t, initialPos.Added(maths.BearingToVector(roveapi.Bearing_North)), newPos, "Failed to correctly move position for rover") - - // Ensure rover lost charge - rover, err := world.GetRover(a) - assert.NoError(t, err, "Failed to get rover information") - assert.Equal(t, rover.MaximumCharge-(i+1), rover.Charge, "Rover should have lost charge") - } - -} - func TestWorld_Daytime(t *testing.T) { world := NewWorld(1) @@ -343,7 +305,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 +321,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() } } @@ -426,3 +388,81 @@ func TestWorld_Broadcast(t *testing.T) { assert.NoError(t, err) assert.Contains(t, rb.Logs[len(rb.Logs)-1].Text, "HJK", "Rover A should have logged it's broadcast") } + +func TestWorld_Sailing(t *testing.T) { + world := NewWorld(8) + world.Tick() // One initial tick to set the wind direction the first time + world.Wind = roveapi.Bearing_North // Set the wind direction to north + + name, err := world.SpawnRover() + assert.NoError(t, err) + + // Warp the rover to 0,0 after clearing it + world.Atlas.SetObject(maths.Vector{X: 0, Y: 0}, Object{Type: roveapi.Object_ObjectUnknown}) + assert.NoError(t, world.WarpRover(name, maths.Vector{X: 0, Y: 0})) + + s, err := world.RoverToggle(name) + assert.NoError(t, err) + assert.Equal(t, roveapi.SailPosition_CatchingWind, s) + + b, err := world.RoverTurn(name, roveapi.Bearing_North) + assert.NoError(t, err) + assert.Equal(t, roveapi.Bearing_North, b) + + // Clear the space to the north + world.Atlas.SetObject(maths.Vector{X: 0, Y: 1}, Object{Type: roveapi.Object_ObjectUnknown}) + + // Tick the world and check we've moved not moved + world.Tick() + info, err := world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{Y: 0}, info.Pos) + + // Loop a few more times + for i := 0; i < TicksPerNormalMove-2; i++ { + world.Tick() + info, err := world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{Y: 0}, info.Pos) + } + + // Now check we've moved (after the TicksPerNormalMove number of ticks) + world.Tick() + info, err = world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{Y: 1}, info.Pos) + + // Reset the world ticks back to stop any wind changes etc. + world.CurrentTicks = 1 + + // Face the rover south, into the wind + b, err = world.RoverTurn(name, roveapi.Bearing_South) + assert.NoError(t, err) + assert.Equal(t, roveapi.Bearing_South, b) + + // Tick a bunch, we should never move + for i := 0; i < TicksPerNormalMove*2; i++ { + world.Tick() + info, err := world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{Y: 1}, info.Pos) + } + + // Reset the world ticks back to stop any wind changes etc. + world.CurrentTicks = 1 + world.Wind = roveapi.Bearing_SouthEast // Set up a south easternly wind + + // Turn the rover perpendicular + b, err = world.RoverTurn(name, roveapi.Bearing_NorthEast) + assert.NoError(t, err) + assert.Equal(t, roveapi.Bearing_NorthEast, b) + + // Clear a space + world.Atlas.SetObject(maths.Vector{X: 1, Y: 2}, Object{Type: roveapi.Object_ObjectUnknown}) + + // Now check we've moved immediately + world.Tick() + info, err = world.GetRover(name) + assert.NoError(t, err) + assert.Equal(t, maths.Vector{X: 1, Y: 2}, info.Pos) +} diff --git a/proto/roveapi/roveapi.pb.go b/proto/roveapi/roveapi.pb.go index 783325f..a9bf133 100644 --- a/proto/roveapi/roveapi.pb.go +++ b/proto/roveapi/roveapi.pb.go @@ -39,15 +39,15 @@ type CommandType int32 const ( CommandType_none CommandType = 0 - // Move the rover in a direction, requires bearing - CommandType_move CommandType = 1 + // Toggles the sails, either catching the wind, or charging from the sun + CommandType_toggle CommandType = 1 + // Turns the rover in the specified bearing, requires data + CommandType_turn CommandType = 2 // Stashes item at current location in rover inventory - CommandType_stash CommandType = 2 + CommandType_stash CommandType = 3 // Repairs the rover using an inventory object - CommandType_repair CommandType = 3 - // Waits a tick to add more charge to the rover - CommandType_recharge CommandType = 4 - // Broadcasts a message to nearby rovers + CommandType_repair CommandType = 4 + // Broadcasts a message to nearby rovers, requires data CommandType_broadcast CommandType = 5 ) @@ -55,18 +55,18 @@ const ( var ( CommandType_name = map[int32]string{ 0: "none", - 1: "move", - 2: "stash", - 3: "repair", - 4: "recharge", + 1: "toggle", + 2: "turn", + 3: "stash", + 4: "repair", 5: "broadcast", } CommandType_value = map[string]int32{ "none": 0, - "move": 1, - "stash": 2, - "repair": 3, - "recharge": 4, + "toggle": 1, + "turn": 2, + "stash": 3, + "repair": 4, "broadcast": 5, } ) @@ -98,15 +98,20 @@ func (CommandType) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{0} } +// Bearing represents a compass direction type Bearing int32 const ( // BearingUnknown an unknown invalid bearing Bearing_BearingUnknown Bearing = 0 Bearing_North Bearing = 1 - Bearing_East Bearing = 2 - Bearing_South Bearing = 3 - Bearing_West Bearing = 4 + Bearing_NorthEast Bearing = 2 + Bearing_East Bearing = 3 + Bearing_SouthEast Bearing = 4 + Bearing_South Bearing = 5 + Bearing_SouthWest Bearing = 6 + Bearing_West Bearing = 7 + Bearing_NorthWest Bearing = 8 ) // Enum value maps for Bearing. @@ -114,16 +119,24 @@ var ( Bearing_name = map[int32]string{ 0: "BearingUnknown", 1: "North", - 2: "East", - 3: "South", - 4: "West", + 2: "NorthEast", + 3: "East", + 4: "SouthEast", + 5: "South", + 6: "SouthWest", + 7: "West", + 8: "NorthWest", } Bearing_value = map[string]int32{ "BearingUnknown": 0, "North": 1, - "East": 2, - "South": 3, - "West": 4, + "NorthEast": 2, + "East": 3, + "SouthEast": 4, + "South": 5, + "SouthWest": 6, + "West": 7, + "NorthWest": 8, } ) @@ -271,6 +284,58 @@ func (Tile) EnumDescriptor() ([]byte, []int) { return file_roveapi_roveapi_proto_rawDescGZIP(), []int{3} } +// SailPosition represents the position of the sola sail +type SailPosition int32 + +const ( + SailPosition_UnknownSailPosition SailPosition = 0 + // CatchingWind means the sail is catching the wind and moving the rover + SailPosition_CatchingWind SailPosition = 1 + // SolarCharging means the sail is facing the sun and charging + SailPosition_SolarCharging SailPosition = 2 +) + +// Enum value maps for SailPosition. +var ( + SailPosition_name = map[int32]string{ + 0: "UnknownSailPosition", + 1: "CatchingWind", + 2: "SolarCharging", + } + SailPosition_value = map[string]int32{ + "UnknownSailPosition": 0, + "CatchingWind": 1, + "SolarCharging": 2, + } +) + +func (x SailPosition) Enum() *SailPosition { + p := new(SailPosition) + *p = x + return p +} + +func (x SailPosition) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SailPosition) Descriptor() protoreflect.EnumDescriptor { + return file_roveapi_roveapi_proto_enumTypes[4].Descriptor() +} + +func (SailPosition) Type() protoreflect.EnumType { + return &file_roveapi_roveapi_proto_enumTypes[4] +} + +func (x SailPosition) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SailPosition.Descriptor instead. +func (SailPosition) EnumDescriptor() ([]byte, []int) { + return file_roveapi_roveapi_proto_rawDescGZIP(), []int{4} +} + // ServerStatusRequest is an empty placeholder type ServerStatusRequest struct { state protoimpl.MessageState @@ -559,10 +624,11 @@ type Command struct { // The command type Command CommandType `protobuf:"varint,1,opt,name=command,proto3,enum=roveapi.CommandType" json:"command,omitempty"` - // Types that are assignable to Data: - // *Command_Bearing - // *Command_Message - Data isCommand_Data `protobuf_oneof:"data"` + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + Broadcast []byte `protobuf:"bytes,2,opt,name=broadcast,proto3" json:"broadcast,omitempty"` + // The bearing for the rover to turn to + Turn Bearing `protobuf:"varint,3,opt,name=turn,proto3,enum=roveapi.Bearing" json:"turn,omitempty"` } func (x *Command) Reset() { @@ -604,48 +670,20 @@ func (x *Command) GetCommand() CommandType { return CommandType_none } -func (m *Command) GetData() isCommand_Data { - if m != nil { - return m.Data +func (x *Command) GetBroadcast() []byte { + if x != nil { + return x.Broadcast } return nil } -func (x *Command) GetBearing() Bearing { - if x, ok := x.GetData().(*Command_Bearing); ok { - return x.Bearing +func (x *Command) GetTurn() Bearing { + if x != nil { + return x.Turn } return Bearing_BearingUnknown } -func (x *Command) GetMessage() []byte { - if x, ok := x.GetData().(*Command_Message); ok { - return x.Message - } - return nil -} - -type isCommand_Data interface { - isCommand_Data() -} - -type Command_Bearing struct { - // A bearing - // Used with MOVE - Bearing Bearing `protobuf:"varint,2,opt,name=bearing,proto3,enum=roveapi.Bearing,oneof"` -} - -type Command_Message struct { - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - // Used with BROADCAST - Message []byte `protobuf:"bytes,3,opt,name=message,proto3,oneof"` -} - -func (*Command_Bearing) isCommand_Data() {} - -func (*Command_Message) isCommand_Data() {} - // CommandRequest describes a set of commands to be requested for the rover type CommandRequest struct { state protoimpl.MessageState @@ -1033,26 +1071,32 @@ type StatusResponse struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Position of the rover in world coordinates Position *Vector `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + // The current direction of the rover + Bearing Bearing `protobuf:"varint,3,opt,name=bearing,proto3,enum=roveapi.Bearing" json:"bearing,omitempty"` // The range of this rover's radar and broadcasting - Range int32 `protobuf:"varint,3,opt,name=range,proto3" json:"range,omitempty"` + Range int32 `protobuf:"varint,4,opt,name=range,proto3" json:"range,omitempty"` // The items in the rover inventory - Inventory []byte `protobuf:"bytes,4,opt,name=inventory,proto3" json:"inventory,omitempty"` + Inventory []byte `protobuf:"bytes,5,opt,name=inventory,proto3" json:"inventory,omitempty"` // The capacity of the inventory - Capacity int32 `protobuf:"varint,5,opt,name=capacity,proto3" json:"capacity,omitempty"` + Capacity int32 `protobuf:"varint,6,opt,name=capacity,proto3" json:"capacity,omitempty"` // The current health of the rover - Integrity int32 `protobuf:"varint,6,opt,name=integrity,proto3" json:"integrity,omitempty"` + Integrity int32 `protobuf:"varint,7,opt,name=integrity,proto3" json:"integrity,omitempty"` // The maximum health of the rover - MaximumIntegrity int32 `protobuf:"varint,7,opt,name=maximumIntegrity,proto3" json:"maximumIntegrity,omitempty"` + MaximumIntegrity int32 `protobuf:"varint,8,opt,name=maximumIntegrity,proto3" json:"maximumIntegrity,omitempty"` // The energy stored in the rover - Charge int32 `protobuf:"varint,8,opt,name=charge,proto3" json:"charge,omitempty"` + Charge int32 `protobuf:"varint,9,opt,name=charge,proto3" json:"charge,omitempty"` // The max energy the rover can store - MaximumCharge int32 `protobuf:"varint,9,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` + MaximumCharge int32 `protobuf:"varint,10,opt,name=maximumCharge,proto3" json:"maximumCharge,omitempty"` + // The current position of the sails + SailPosition SailPosition `protobuf:"varint,11,opt,name=sailPosition,proto3,enum=roveapi.SailPosition" json:"sailPosition,omitempty"` // The set of currently incoming commands for this tick - IncomingCommands []*Command `protobuf:"bytes,10,rep,name=incomingCommands,proto3" json:"incomingCommands,omitempty"` + IncomingCommands []*Command `protobuf:"bytes,12,rep,name=incomingCommands,proto3" json:"incomingCommands,omitempty"` // The set of currently queued commands - QueuedCommands []*Command `protobuf:"bytes,11,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` + QueuedCommands []*Command `protobuf:"bytes,13,rep,name=queuedCommands,proto3" json:"queuedCommands,omitempty"` // The most recent logs - Logs []*Log `protobuf:"bytes,12,rep,name=logs,proto3" json:"logs,omitempty"` + Logs []*Log `protobuf:"bytes,14,rep,name=logs,proto3" json:"logs,omitempty"` + // The current wind direction + Wind Bearing `protobuf:"varint,15,opt,name=wind,proto3,enum=roveapi.Bearing" json:"wind,omitempty"` } func (x *StatusResponse) Reset() { @@ -1101,6 +1145,13 @@ func (x *StatusResponse) GetPosition() *Vector { return nil } +func (x *StatusResponse) GetBearing() Bearing { + if x != nil { + return x.Bearing + } + return Bearing_BearingUnknown +} + func (x *StatusResponse) GetRange() int32 { if x != nil { return x.Range @@ -1150,6 +1201,13 @@ func (x *StatusResponse) GetMaximumCharge() int32 { return 0 } +func (x *StatusResponse) GetSailPosition() SailPosition { + if x != nil { + return x.SailPosition + } + return SailPosition_UnknownSailPosition +} + func (x *StatusResponse) GetIncomingCommands() []*Command { if x != nil { return x.IncomingCommands @@ -1171,6 +1229,13 @@ func (x *StatusResponse) GetLogs() []*Log { return nil } +func (x *StatusResponse) GetWind() Bearing { + if x != nil { + return x.Wind + } + return Bearing_BearingUnknown +} + var File_roveapi_roveapi_proto protoreflect.FileDescriptor var file_roveapi_roveapi_proto_rawDesc = []byte{ @@ -1197,116 +1262,132 @@ var file_roveapi_roveapi_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x8b, 0x01, 0x0a, 0x07, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2c, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, - 0x69, 0x6e, 0x67, 0x12, 0x1a, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, - 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, - 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, 0x6c, - 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, - 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x29, - 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, - 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, + 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x7d, 0x0a, 0x07, 0x43, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, + 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, + 0x6e, 0x67, 0x52, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, 0x0a, - 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, - 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, - 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xc3, 0x03, 0x0a, 0x0e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x56, - 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, - 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, - 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, - 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, - 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, - 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, - 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, - 0x72, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, - 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, - 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, - 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, - 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, - 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, - 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, - 0x73, 0x2a, 0x55, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x08, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x6d, 0x6f, - 0x76, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x02, 0x12, - 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x61, 0x69, 0x72, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x72, - 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, - 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x10, 0x05, 0x2a, 0x47, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, - 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, - 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, - 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, - 0x53, 0x6f, 0x75, 0x74, 0x68, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, - 0x04, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, - 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, - 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, - 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, - 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, - 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, - 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, - 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, - 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x0a, 0x0c, 0x52, 0x61, 0x64, 0x61, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x75, 0x0a, 0x0d, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x69, + 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x54, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x74, 0x69, 0x6c, 0x65, 0x73, 0x12, + 0x29, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, + 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x24, 0x0a, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, + 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, + 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xd0, 0x04, 0x0a, + 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x07, 0x62, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, + 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x61, 0x6e, + 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, + 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x61, + 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x49, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x12, 0x24, + 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x43, 0x68, + 0x61, 0x72, 0x67, 0x65, 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x6f, 0x76, + 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x0c, 0x73, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x3c, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, + 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x63, + 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x38, 0x0a, + 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, + 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x75, 0x65, 0x64, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, + 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, + 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, 0x24, 0x0a, 0x04, 0x77, 0x69, 0x6e, + 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, + 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x77, 0x69, 0x6e, 0x64, 0x2a, + 0x53, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, + 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x6f, 0x67, 0x67, + 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x74, 0x75, 0x72, 0x6e, 0x10, 0x02, 0x12, 0x09, + 0x0a, 0x05, 0x73, 0x74, 0x61, 0x73, 0x68, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x72, 0x65, 0x70, + 0x61, 0x69, 0x72, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, + 0x73, 0x74, 0x10, 0x05, 0x2a, 0x83, 0x01, 0x0a, 0x07, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, + 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, + 0x77, 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x10, 0x01, 0x12, + 0x0d, 0x0a, 0x09, 0x4e, 0x6f, 0x72, 0x74, 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x02, 0x12, 0x08, + 0x0a, 0x04, 0x45, 0x61, 0x73, 0x74, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, + 0x68, 0x45, 0x61, 0x73, 0x74, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6f, 0x75, 0x74, 0x68, + 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, + 0x06, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x65, 0x73, 0x74, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x4e, + 0x6f, 0x72, 0x74, 0x68, 0x57, 0x65, 0x73, 0x74, 0x10, 0x08, 0x2a, 0x5a, 0x0a, 0x06, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x76, 0x65, 0x72, + 0x4c, 0x69, 0x76, 0x65, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x6f, 0x76, 0x65, 0x72, 0x44, + 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, + 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x6f, 0x63, 0x6b, 0x4c, + 0x61, 0x72, 0x67, 0x65, 0x10, 0x04, 0x2a, 0x37, 0x0a, 0x04, 0x54, 0x69, 0x6c, 0x65, 0x12, 0x0f, + 0x0a, 0x0b, 0x54, 0x69, 0x6c, 0x65, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, + 0x08, 0x0a, 0x04, 0x52, 0x6f, 0x63, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x72, 0x61, + 0x76, 0x65, 0x6c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x2a, + 0x4c, 0x0a, 0x0c, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x17, 0x0a, 0x13, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x61, 0x69, 0x6c, 0x50, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x63, + 0x68, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x6f, + 0x6c, 0x61, 0x72, 0x43, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0xcf, 0x02, + 0x0a, 0x04, 0x52, 0x6f, 0x76, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x12, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x6f, + 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x12, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, - 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, - 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, - 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, - 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x05, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x12, 0x15, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, + 0x70, 0x69, 0x2e, 0x52, 0x61, 0x64, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x72, + 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x64, + 0x69, 0x6c, 0x75, 0x7a, 0x2f, 0x72, 0x6f, 0x76, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x72, 0x6f, 0x76, 0x65, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1321,57 +1402,61 @@ func file_roveapi_roveapi_proto_rawDescGZIP() []byte { return file_roveapi_roveapi_proto_rawDescData } -var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_roveapi_roveapi_proto_enumTypes = make([]protoimpl.EnumInfo, 5) var file_roveapi_roveapi_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_roveapi_roveapi_proto_goTypes = []interface{}{ (CommandType)(0), // 0: roveapi.CommandType (Bearing)(0), // 1: roveapi.Bearing (Object)(0), // 2: roveapi.Object (Tile)(0), // 3: roveapi.Tile - (*ServerStatusRequest)(nil), // 4: roveapi.ServerStatusRequest - (*ServerStatusResponse)(nil), // 5: roveapi.ServerStatusResponse - (*RegisterRequest)(nil), // 6: roveapi.RegisterRequest - (*Account)(nil), // 7: roveapi.Account - (*RegisterResponse)(nil), // 8: roveapi.RegisterResponse - (*Command)(nil), // 9: roveapi.Command - (*CommandRequest)(nil), // 10: roveapi.CommandRequest - (*CommandResponse)(nil), // 11: roveapi.CommandResponse - (*RadarRequest)(nil), // 12: roveapi.RadarRequest - (*RadarResponse)(nil), // 13: roveapi.RadarResponse - (*StatusRequest)(nil), // 14: roveapi.StatusRequest - (*Log)(nil), // 15: roveapi.Log - (*Vector)(nil), // 16: roveapi.Vector - (*StatusResponse)(nil), // 17: roveapi.StatusResponse + (SailPosition)(0), // 4: roveapi.SailPosition + (*ServerStatusRequest)(nil), // 5: roveapi.ServerStatusRequest + (*ServerStatusResponse)(nil), // 6: roveapi.ServerStatusResponse + (*RegisterRequest)(nil), // 7: roveapi.RegisterRequest + (*Account)(nil), // 8: roveapi.Account + (*RegisterResponse)(nil), // 9: roveapi.RegisterResponse + (*Command)(nil), // 10: roveapi.Command + (*CommandRequest)(nil), // 11: roveapi.CommandRequest + (*CommandResponse)(nil), // 12: roveapi.CommandResponse + (*RadarRequest)(nil), // 13: roveapi.RadarRequest + (*RadarResponse)(nil), // 14: roveapi.RadarResponse + (*StatusRequest)(nil), // 15: roveapi.StatusRequest + (*Log)(nil), // 16: roveapi.Log + (*Vector)(nil), // 17: roveapi.Vector + (*StatusResponse)(nil), // 18: roveapi.StatusResponse } var file_roveapi_roveapi_proto_depIdxs = []int32{ - 7, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account + 8, // 0: roveapi.RegisterResponse.account:type_name -> roveapi.Account 0, // 1: roveapi.Command.command:type_name -> roveapi.CommandType - 1, // 2: roveapi.Command.bearing:type_name -> roveapi.Bearing - 7, // 3: roveapi.CommandRequest.account:type_name -> roveapi.Account - 9, // 4: roveapi.CommandRequest.commands:type_name -> roveapi.Command - 7, // 5: roveapi.RadarRequest.account:type_name -> roveapi.Account + 1, // 2: roveapi.Command.turn:type_name -> roveapi.Bearing + 8, // 3: roveapi.CommandRequest.account:type_name -> roveapi.Account + 10, // 4: roveapi.CommandRequest.commands:type_name -> roveapi.Command + 8, // 5: roveapi.RadarRequest.account:type_name -> roveapi.Account 3, // 6: roveapi.RadarResponse.tiles:type_name -> roveapi.Tile 2, // 7: roveapi.RadarResponse.objects:type_name -> roveapi.Object - 7, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account - 16, // 9: roveapi.StatusResponse.position:type_name -> roveapi.Vector - 9, // 10: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command - 9, // 11: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command - 15, // 12: roveapi.StatusResponse.logs:type_name -> roveapi.Log - 4, // 13: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest - 6, // 14: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest - 10, // 15: roveapi.Rove.Command:input_type -> roveapi.CommandRequest - 12, // 16: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest - 14, // 17: roveapi.Rove.Status:input_type -> roveapi.StatusRequest - 5, // 18: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse - 8, // 19: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse - 11, // 20: roveapi.Rove.Command:output_type -> roveapi.CommandResponse - 13, // 21: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse - 17, // 22: roveapi.Rove.Status:output_type -> roveapi.StatusResponse - 18, // [18:23] is the sub-list for method output_type - 13, // [13:18] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 8, // 8: roveapi.StatusRequest.account:type_name -> roveapi.Account + 17, // 9: roveapi.StatusResponse.position:type_name -> roveapi.Vector + 1, // 10: roveapi.StatusResponse.bearing:type_name -> roveapi.Bearing + 4, // 11: roveapi.StatusResponse.sailPosition:type_name -> roveapi.SailPosition + 10, // 12: roveapi.StatusResponse.incomingCommands:type_name -> roveapi.Command + 10, // 13: roveapi.StatusResponse.queuedCommands:type_name -> roveapi.Command + 16, // 14: roveapi.StatusResponse.logs:type_name -> roveapi.Log + 1, // 15: roveapi.StatusResponse.wind:type_name -> roveapi.Bearing + 5, // 16: roveapi.Rove.ServerStatus:input_type -> roveapi.ServerStatusRequest + 7, // 17: roveapi.Rove.Register:input_type -> roveapi.RegisterRequest + 11, // 18: roveapi.Rove.Command:input_type -> roveapi.CommandRequest + 13, // 19: roveapi.Rove.Radar:input_type -> roveapi.RadarRequest + 15, // 20: roveapi.Rove.Status:input_type -> roveapi.StatusRequest + 6, // 21: roveapi.Rove.ServerStatus:output_type -> roveapi.ServerStatusResponse + 9, // 22: roveapi.Rove.Register:output_type -> roveapi.RegisterResponse + 12, // 23: roveapi.Rove.Command:output_type -> roveapi.CommandResponse + 14, // 24: roveapi.Rove.Radar:output_type -> roveapi.RadarResponse + 18, // 25: roveapi.Rove.Status:output_type -> roveapi.StatusResponse + 21, // [21:26] is the sub-list for method output_type + 16, // [16:21] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_roveapi_roveapi_proto_init() } @@ -1549,16 +1634,12 @@ func file_roveapi_roveapi_proto_init() { } } } - file_roveapi_roveapi_proto_msgTypes[5].OneofWrappers = []interface{}{ - (*Command_Bearing)(nil), - (*Command_Message)(nil), - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_roveapi_roveapi_proto_rawDesc, - NumEnums: 4, + NumEnums: 5, NumMessages: 14, NumExtensions: 0, NumServices: 1, diff --git a/proto/roveapi/roveapi.proto b/proto/roveapi/roveapi.proto index 566bcfd..c45f29c 100644 --- a/proto/roveapi/roveapi.proto +++ b/proto/roveapi/roveapi.proto @@ -89,25 +89,30 @@ message RegisterResponse { // CommandType defines the type of a command to give to the rover enum CommandType { none = 0; - // Move the rover in a direction, requires bearing - move = 1; + // Toggles the sails, either catching the wind, or charging from the sun + toggle = 1; + // Turns the rover in the specified bearing, requires data + turn = 2; // Stashes item at current location in rover inventory - stash = 2; + stash = 3; // Repairs the rover using an inventory object - repair = 3; - // Waits a tick to add more charge to the rover - recharge = 4; - // Broadcasts a message to nearby rovers + repair = 4; + // Broadcasts a message to nearby rovers, requires data broadcast = 5; } +// Bearing represents a compass direction enum Bearing { // BearingUnknown an unknown invalid bearing BearingUnknown = 0; North = 1; - East = 2; - South = 3; - West = 4; + NorthEast = 2; + East = 3; + SouthEast = 4; + South = 5; + SouthWest = 6; + West = 7; + NorthWest = 8; } // Command is a single command for a rover @@ -115,16 +120,12 @@ message Command { // The command type CommandType command = 1; - oneof data { - // A bearing - // Used with MOVE - Bearing bearing = 2; + // A simple message, must be composed of printable ASCII glyphs (32-126) + // maximum of three characters + bytes broadcast = 2; - // A simple message, must be composed of printable ASCII glyphs (32-126) - // maximum of three characters - // Used with BROADCAST - bytes message = 3; - } + // The bearing for the rover to turn to + Bearing turn = 3; } // CommandRequest describes a set of commands to be requested for the rover @@ -219,6 +220,17 @@ message Vector { int32 y = 2; } +// SailPosition represents the position of the sola sail +enum SailPosition { + UnknownSailPosition = 0; + + // CatchingWind means the sail is catching the wind and moving the rover + CatchingWind = 1; + + // SolarCharging means the sail is facing the sun and charging + SolarCharging = 2; +} + // StatusResponse is the response given to a status request message StatusResponse { // The name of the rover @@ -227,33 +239,42 @@ message StatusResponse { // Position of the rover in world coordinates Vector position = 2; + // The current direction of the rover + Bearing bearing = 3; + // The range of this rover's radar and broadcasting - int32 range = 3; + int32 range = 4; // The items in the rover inventory - bytes inventory = 4; + bytes inventory = 5; // The capacity of the inventory - int32 capacity = 5; + int32 capacity = 6; // The current health of the rover - int32 integrity = 6; + int32 integrity = 7; // The maximum health of the rover - int32 maximumIntegrity = 7; + int32 maximumIntegrity = 8; // The energy stored in the rover - int32 charge = 8; + int32 charge = 9; // The max energy the rover can store - int32 maximumCharge = 9; + int32 maximumCharge = 10; + + // The current position of the sails + SailPosition sailPosition = 11; // The set of currently incoming commands for this tick - repeated Command incomingCommands = 10; + repeated Command incomingCommands = 12; // The set of currently queued commands - repeated Command queuedCommands = 11; + repeated Command queuedCommands = 13; // The most recent logs - repeated Log logs = 12; + repeated Log logs = 14; + + // The current wind direction + Bearing wind = 15; } \ No newline at end of file