Simplify duplicate command types
This commit is contained in:
parent
97d3583384
commit
e3ce87e964
8 changed files with 28 additions and 56 deletions
|
@ -15,7 +15,6 @@ import (
|
|||
"github.com/mdiluz/rove/pkg/accounts"
|
||||
"github.com/mdiluz/rove/pkg/game"
|
||||
"github.com/mdiluz/rove/pkg/persistence"
|
||||
"github.com/mdiluz/rove/pkg/rove"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -195,19 +194,3 @@ func (s *Server) SpawnRoverForAccount(accountid uuid.UUID) (game.Vector, uuid.UU
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ConvertCommands converts server commands to game commands
|
||||
func (s *Server) ConvertCommands(commands []rove.Command, inst uuid.UUID) ([]game.Command, error) {
|
||||
var cmds []game.Command
|
||||
for _, c := range commands {
|
||||
switch c.Command {
|
||||
case rove.CommandMove:
|
||||
if bearing, err := game.DirectionFromString(c.Bearing); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cmds = append(cmds, s.world.CommandMove(inst, bearing, c.Duration))
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmds, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue