refactor: func naming
This commit is contained in:
@@ -17,7 +17,7 @@ func TestCommand(t *testing.T) {
|
||||
Actor: "SomeRace",
|
||||
Commands: []json.RawMessage{
|
||||
encodeCommand(&rest.CommandVote{
|
||||
CommandMeta: rest.CommandMeta{Type: rest.CommandTypeVote},
|
||||
CommandMeta: rest.CommandMeta{Type: rest.CommandTypeRaceVote},
|
||||
Recipient: "AnotherRace",
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -43,9 +43,9 @@ func parseCommand(actor string, c json.RawMessage) (Command, error) {
|
||||
return nil, err
|
||||
}
|
||||
switch t := meta.Type; t {
|
||||
case rest.CommandTypeVote:
|
||||
case rest.CommandTypeRaceVote:
|
||||
return giveVotes(actor, c)
|
||||
case rest.CommandTypeRelation:
|
||||
case rest.CommandTypeRaceRelation:
|
||||
return updateRelation(actor, c)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown comman type: %s", t)
|
||||
@@ -57,7 +57,7 @@ func giveVotes(actor string, c json.RawMessage) (Command, error) {
|
||||
if err := json.Unmarshal(c, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return func(c controller.Ctrl) error { return c.GiveVotes(actor, v.Recipient) }, nil
|
||||
return func(c controller.Ctrl) error { return c.RaceVote(actor, v.Recipient) }, nil
|
||||
}
|
||||
|
||||
func updateRelation(actor string, c json.RawMessage) (Command, error) {
|
||||
@@ -65,5 +65,5 @@ func updateRelation(actor string, c json.RawMessage) (Command, error) {
|
||||
if err := json.Unmarshal(c, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return func(c controller.Ctrl) error { return c.UpdateRelation(actor, v.Opponent, v.Relation) }, nil
|
||||
return func(c controller.Ctrl) error { return c.RaceRelation(actor, v.Opponent, v.Relation) }, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user