diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-08 17:50:10 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:49 +0100 |
| commit | 805cbf397589e5cb861f866713c2eb4bec9ce40b (patch) | |
| tree | 084ef7d136f33b87efe5aa02c7401bde50c9d251 /go/ui | |
| parent | 05de94b9d97079ca9a7b23e011516f55056472b3 (diff) | |
| download | muhqs-game-805cbf397589e5cb861f866713c2eb4bec9ce40b.tar.gz muhqs-game-805cbf397589e5cb861f866713c2eb4bec9ce40b.zip | |
intermediate commit
Diffstat (limited to 'go/ui')
| -rw-r--r-- | go/ui/prompt.go | 36 | ||||
| -rw-r--r-- | go/ui/textBox.go | 2 |
2 files changed, 6 insertions, 32 deletions
diff --git a/go/ui/prompt.go b/go/ui/prompt.go index 1d552564..af5fca1d 100644 --- a/go/ui/prompt.go +++ b/go/ui/prompt.go @@ -1,63 +1,37 @@ package ui import ( - "log" - "github.com/hajimehoshi/ebiten/v2" "muhq.space/muhqs-game/go/game" ) -type promptType int - const ( - handCard promptType = iota - PROMPT_HEIGHT int = 50 ) type Prompt struct { - promptType promptType y, width int - sel []interface{} + action game.Action components []Widget } -func NewHandCardPrompt(y, width int, promptText string) *Prompt { +func NewPrompt(y, width int, action game.Action, promptText string) *Prompt { p := &Prompt{ y: y, width: width, - promptType: handCard, + action: action, components: []Widget{NewFixedTextBox(0, y, width, PROMPT_HEIGHT, promptText).Centering(true)}, } return p } func (p *Prompt) Add(obj interface{}) { - var ok bool - switch p.promptType { - case handCard: - _, ok = obj.(HandCard) - } - - if !ok { - log.Fatalf("Invalid type %T for prompt %d", obj, p.promptType) - } - - p.sel = append(p.sel, obj) + p.action.Targets().AddSelection(obj) } func (p *Prompt) Confirm() game.Action { - switch p.promptType { - case handCard: - cards := make([]*game.Card, 0, len(p.sel)) - for _, c := range p.sel { - cards = append(cards, c.(HandCard).C) - } - return game.NewHandCardSelection(cards) - } - - return nil + return p.action } func (p *Prompt) Height() int { diff --git a/go/ui/textBox.go b/go/ui/textBox.go index cc813a4e..7f1ab98c 100644 --- a/go/ui/textBox.go +++ b/go/ui/textBox.go @@ -64,7 +64,7 @@ func (tb *TextBox) Centering(centering bool) *TextBox { func NewUnitInfo(x, y int, u *game.Unit) *TextBox { info := fmt.Sprintf("%s\nDamage: %d\nHealth: %d\nUpkeep: %d", - u.String(), u.Damage(), u.Health, u.Upkeep) + u.String(), u.Damage(), u.Health, u.UpkeepCost()) if u.Movement != game.INVALID_MOVEMENT() { info = fmt.Sprintf("%s\nMovement: %s", info, u.Movement.String()) |
