diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-30 20:16:49 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:33 +0200 |
| commit | 81e9ab9db504e09e24523482b169726a25d9a3b1 (patch) | |
| tree | fc52f0a18a9556c6f285f519f0df3379d2de6612 /go/activities | |
| parent | ed4c9d377b218453c5d4272ad50c958603ccb0f1 (diff) | |
| download | muhqs-game-81e9ab9db504e09e24523482b169726a25d9a3b1.tar.gz muhqs-game-81e9ab9db504e09e24523482b169726a25d9a3b1.zip | |
minor code improvements reported by golangci-lint
Diffstat (limited to 'go/activities')
| -rw-r--r-- | go/activities/draft.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/go/activities/draft.go b/go/activities/draft.go index f1b3fb58..e2af5f5c 100644 --- a/go/activities/draft.go +++ b/go/activities/draft.go @@ -83,7 +83,9 @@ func NewLocalDraft(width, height int, playerName string) *Draft { 30, "?", func(*ui.SimpleButton) { - ui.OpenUrl("https://muhq.space/muhqs-game/build/en/rules.html#draft-notation") + if err := ui.OpenUrl("https://muhq.space/muhqs-game/build/en/rules.html#draft-notation"); err != nil { + // TODO: present the error + } })) d.AddWidget(ui.NewFixedTextBox( @@ -109,14 +111,14 @@ func NewLocalDraft(width, height int, playerName string) *Draft { DRAFT_BUTTON_HEIGHT, "Start", func(*ui.SimpleButton) { - d.startDraft(d.descInput.TextOrLabel(), d.setInput.TextOrLabel(), aiNInput.GetChoosen()) + d.startDraftSafe(d.descInput.TextOrLabel(), d.setInput.TextOrLabel(), aiNInput.GetChoosen()) })) return d } -// StartNewLocalDraft creates a new draft from its inputs and immediatly starts it. -// The started draft activiry is returned or any occured error. +// StartNewLocalDraft creates a new draft from its inputs and immediately starts it. +// The started draft activity is returned or any occurred error. func StartNewLocalDraft(width, height int, playerName string, desc string, sets string, aiN int) (*Draft, error) { d := &Draft{ Collection: ui.Collection{Width: width, Height: height}, @@ -149,7 +151,7 @@ func (d *Draft) Update() error { } if n.Valid() { - log.Println("Received draft pick: %v\n", n) + log.Printf("Received draft pick: %v\n", n) d.presentPack(n) } @@ -193,7 +195,10 @@ func (d *Draft) presentPack(n game.PlayerNotification) { } card := _card.(*game.Card) - d.ctrl.SendAction(game.NewDraftPick(d.player, pack, card)) + err := d.ctrl.SendAction(game.NewDraftPick(d.player, pack, card)) + if err != nil { + // FIXME: handle error + } d.RemoveWidget(grid) if d.timer != nil { d.timer = nil @@ -229,7 +234,7 @@ func (d *Draft) startDraft(desc string, setList string, aiN int) error { return err } - for _ = range aiN { + for range aiN { d.draft.AddRandomAi() } @@ -276,7 +281,6 @@ func (d *Draft) startDraft(desc string, setList string, aiN int) error { } func (d *Draft) startDraftSafe(desc string, setList string, aiN int) { - err := d.startDraft(desc, setList, aiN) if err == nil { return |
