aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-05 12:15:25 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-07-06 11:49:26 -0400
commit179f442ba75d13ce8ef30c451404d1c6db712765 (patch)
tree729951f8c584d7d60361b3282cd381aad8b25fc2
parent96c34193d5402523453407a02a1b45d6b41953d5 (diff)
downloadmuhqs-game-179f442ba75d13ce8ef30c451404d1c6db712765.tar.gz
muhqs-game-179f442ba75d13ce8ef30c451404d1c6db712765.zip
show drafted decklist after local draft is done
-rw-r--r--go/activities/draft.go31
1 files changed, 25 insertions, 6 deletions
diff --git a/go/activities/draft.go b/go/activities/draft.go
index e326050d..19436075 100644
--- a/go/activities/draft.go
+++ b/go/activities/draft.go
@@ -21,16 +21,20 @@ type Draft struct {
player *game.Player
ctrl game.PlayerControl
draft *game.Draft
+ done chan struct{}
setInput *ui.TextInput
descInput *ui.TextInput
deckList *ui.PocList
timer *ui.TimerBar
+
+ deckView *ui.CardGrid
}
func NewLocalDraft(width, height int, playerName string) *Draft {
d := &Draft{
Collection: ui.Collection{Width: width, Height: height},
+ done: make(chan struct{}),
}
d.player = game.NewDraftPlayer(playerName)
@@ -131,6 +135,21 @@ func (d *Draft) Update() error {
d.presentPack(n)
}
+ if d.deckView == nil {
+ select {
+ case <-d.done:
+ d.deckView = ui.NewCardGrid(
+ 0,
+ 0,
+ d.Width-SEALED_DECK_STRIP_WIDTH,
+ d.Height,
+ 0.5,
+ d.player.Deck).Columns(3)
+ d.AddWidget(d.deckView)
+ default:
+ }
+ }
+
if err := ui.Update(); err != nil {
return err
}
@@ -167,6 +186,7 @@ func (d *Draft) presentPack(n game.PlayerNotification) {
d.AddWidget(grid)
if d.draft == nil {
+ // TODO: support any deadline
t := time.Duration(pack.Size()*5) * time.Second
timer := ui.NewTimerBar(0, 10, d.Width, 5, t)
d.AddWidget(timer)
@@ -230,14 +250,13 @@ func (d *Draft) startDraft(desc string, setList string, aiN int) {
DRAFT_BUTTON_HEIGHT,
"Done",
func(*ui.SimpleButton) {
- d.done()
+ PopActivity()
}))
- go d.draft.Run()
-}
-
-func (d *Draft) done() {
- PopActivity()
+ go func() {
+ d.draft.Run()
+ close(d.done)
+ }()
}
func (d *Draft) GetDeckList() string {