Remove move and recharge commands in favor of toggle command for the sails
This commit is contained in:
parent
89123394cd
commit
6c75f07aff
8 changed files with 169 additions and 280 deletions
|
@ -83,10 +83,6 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon
|
|||
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,
|
||||
|
@ -99,10 +95,6 @@ func (s *Server) Status(ctx context.Context, req *roveapi.StatusRequest) (respon
|
|||
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,
|
||||
|
@ -193,8 +185,6 @@ func (s *Server) Command(ctx context.Context, req *roveapi.CommandRequest) (*rov
|
|||
Command: c.Command,
|
||||
}
|
||||
switch c.Command {
|
||||
case roveapi.CommandType_move:
|
||||
n.Bearing = c.GetBearing()
|
||||
case roveapi.CommandType_broadcast:
|
||||
n.Message = c.GetMessage()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
@ -225,21 +224,6 @@ func InnerMain(command string, args ...string) error {
|
|||
var commands []*roveapi.Command
|
||||
for i := 0; i < len(args); i++ {
|
||||
switch args[i] {
|
||||
case "move":
|
||||
i++
|
||||
if len(args) == i {
|
||||
return fmt.Errorf("move command must be passed bearing")
|
||||
}
|
||||
var b roveapi.Bearing
|
||||
if b = BearingFromString(args[i]); b == roveapi.Bearing_BearingUnknown {
|
||||
return fmt.Errorf("unrecognised bearing: %s", args[i])
|
||||
}
|
||||
commands = append(commands,
|
||||
&roveapi.Command{
|
||||
Command: roveapi.CommandType_move,
|
||||
Data: &roveapi.Command_Bearing{Bearing: b},
|
||||
},
|
||||
)
|
||||
case "broadcast":
|
||||
i++
|
||||
if len(args) == i {
|
||||
|
|
|
@ -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"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue