diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-09-03 15:00:05 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-09-03 15:00:05 +0200 |
| commit | b0d2ca8ccb8b42d8da23ae014d154dfde9f1cf08 (patch) | |
| tree | 09c936d9deddc903e2555f93441fa804d92817dd | |
| parent | d292115061b793c8fe959a3eecb0fd3c226f70f9 (diff) | |
| download | muhqs-game-b0d2ca8ccb8b42d8da23ae014d154dfde9f1cf08.tar.gz muhqs-game-b0d2ca8ccb8b42d8da23ae014d154dfde9f1cf08.zip | |
special case the formatting of free and full actions in choice
| -rw-r--r-- | go/font/font.go | 2 | ||||
| -rw-r--r-- | go/game/action.go | 17 | ||||
| -rw-r--r-- | go/ui/choice.go | 10 |
3 files changed, 20 insertions, 9 deletions
diff --git a/go/font/font.go b/go/font/font.go index e594c39f..9e016045 100644 --- a/go/font/font.go +++ b/go/font/font.go @@ -9,6 +9,8 @@ import ( "github.com/hajimehoshi/ebiten/v2/text/v2" ) +// TODO: use a font that supports our tap symbol + var fontSource *text.GoTextFaceSource var Font24 *text.GoTextFace var Font18 *text.GoTextFace diff --git a/go/game/action.go b/go/game/action.go index 91ea223c..f371aae6 100644 --- a/go/game/action.go +++ b/go/game/action.go @@ -623,7 +623,7 @@ func (a *ArtifactMoveAction) String() string { type FullAction struct { ActionBase - desc string + Desc string tag string } @@ -634,7 +634,7 @@ func newFullAction(u *Unit, proto ActionFuncPrototype, desc string) *FullAction Card: u.Card(), }, - desc: desc, + Desc: desc, } a.resolveFunc = func(s *LocalState) { @@ -649,7 +649,7 @@ func newFullAction(u *Unit, proto ActionFuncPrototype, desc string) *FullAction func (a *FullAction) String() string { u := a.source.(*Unit) if a.targets == nil || a.targets.RequireSelection() { - return fmt.Sprintf("↻ %s", a.desc) + return fmt.Sprintf("↻ %s", a.Desc) } return fmt.Sprintf("%v↻@%v", u, a.targets) @@ -657,7 +657,7 @@ func (a *FullAction) String() string { type FreeAction struct { ActionBase - desc string + Desc string } // newControllerCostFunc returns a new cost function checking the controller's resource and decreasing it accordingly. @@ -695,18 +695,19 @@ func NewFreeAction(p Permanent, resolveProto ActionFuncPrototype, costFunc Actio func (a *FreeAction) Speed() ActionSpeed { return fast } func (a *FreeAction) String() (s string) { + // Format the source switch src := a.source.(type) { case *Card: - s += fmt.Sprintf("%v: %s ", a.Controller(), src.Name) + s += fmt.Sprintf("%v: %s", a.Controller(), src.Name) default: s += fmt.Sprintf("%s", src) } - s += " free_action" + // Format the description and potential targets if a.targets == nil || a.targets.RequireSelection() { - s += fmt.Sprintf(" %s", a.desc) + s += fmt.Sprintf(" %s", a.Desc) } else { - s += fmt.Sprintf("@%v", a.targets) + s += fmt.Sprintf(" %s@%v", a.Desc, a.targets) } return diff --git a/go/ui/choice.go b/go/ui/choice.go index 5954c1fa..80902606 100644 --- a/go/ui/choice.go +++ b/go/ui/choice.go @@ -32,7 +32,15 @@ func (c *Choice) setText() { c.Width, c.Height = -1, -1 t := "" for _, choice := range c.choices { - t = fmt.Sprintf("%s%v\n", t, choice) + switch c := choice.(type) { + // Special case Free and FullActions + case *game.FreeAction: + t = fmt.Sprintf("%s%v\n", t, c.Desc) + case *game.FullAction: + t = fmt.Sprintf("%s↻%v\n", t, c.Desc) + default: + t = fmt.Sprintf("%s%v\n", t, choice) + } } c.text = t[:len(t)-1] |
