refactor: func naming

This commit is contained in:
Ilia Denisov
2026-02-10 08:22:44 +02:00
parent 83bcdcbc49
commit b5400bd61e
18 changed files with 379 additions and 378 deletions
+1 -1
View File
@@ -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",
}),
},
+4 -4
View File
@@ -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
}