aboutsummaryrefslogtreecommitdiff
path: root/go/activities/draft.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-30 20:16:49 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-07-30 20:16:49 +0200
commitf64e8747e287e949ce7cbbb42303ad1cdfabec89 (patch)
treec9e0a03b075e24f724bffaa40e015398db10cd1a /go/activities/draft.go
parentaceaf88ba23480919c6921eda14a761476b417ed (diff)
downloadmuhqs-game-f64e8747e287e949ce7cbbb42303ad1cdfabec89.tar.gz
muhqs-game-f64e8747e287e949ce7cbbb42303ad1cdfabec89.zip
minor code improvements reported by golangci-lint
Diffstat (limited to 'go/activities/draft.go')
-rw-r--r--go/activities/draft.go20
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