aboutsummaryrefslogtreecommitdiff
path: root/go/ui
diff options
context:
space:
mode:
Diffstat (limited to 'go/ui')
-rw-r--r--go/ui/prompt.go35
-rw-r--r--go/ui/textBox.go2
2 files changed, 7 insertions, 30 deletions
diff --git a/go/ui/prompt.go b/go/ui/prompt.go
index bfcd5d14..704fd05b 100644
--- a/go/ui/prompt.go
+++ b/go/ui/prompt.go
@@ -1,8 +1,6 @@
package ui
import (
- "log"
-
"github.com/hajimehoshi/ebiten/v2"
"muhq.space/muhqs-game/go/game"
@@ -11,53 +9,32 @@ import (
type promptType int
const (
- handCard promptType = iota
-
PROMPT_HEIGHT int = 50
)
type Prompt struct {
- promptType promptType
y, width int
- sel []interface{}
+ promptType promptType
+ 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{NewCenteringFixedTextBox(0, y, width, PROMPT_HEIGHT, promptText)},
}
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().AddTarget(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 58a3e679..80e6186c 100644
--- a/go/ui/textBox.go
+++ b/go/ui/textBox.go
@@ -56,7 +56,7 @@ func NewCenteringAutoTextBox(x, y int, t string) *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())