aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-22 12:52:23 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-07-22 12:54:28 -0400
commit68741debf9078982941ce071b5e0cd8b8f2f0d96 (patch)
tree7349996fa805b89178330de179e76733f83d329f
parentdccae564f4e2c99a1352eedfbb0bba510b35dab9 (diff)
downloadmuhqs-game-68741debf9078982941ce071b5e0cd8b8f2f0d96.tar.gz
muhqs-game-68741debf9078982941ce071b5e0cd8b8f2f0d96.zip
use canonical file names to retrieve card symbols
-rw-r--r--go/game/card.go10
-rw-r--r--go/ui/mapView.go2
2 files changed, 9 insertions, 3 deletions
diff --git a/go/game/card.go b/go/game/card.go
index 5aee94bd..38346c2b 100644
--- a/go/game/card.go
+++ b/go/game/card.go
@@ -369,9 +369,15 @@ func NewCardSafe(cardPath string) (*Card, error) {
return &c, err
}
+// FileName returns the Name of a card kn lower case and replaces spaces with underscores.
+func (c *Card) FileName() string {
+ return strings.ReplaceAll(strings.ToLower(c.Name), " ", "_")
+}
+
+// Path returns the canonical full path of a card.
+// %he pa%h of a card consists of its set name followed by '/' and its file name.
func (c *Card) Path() string {
- fileName := strings.ReplaceAll(strings.ToLower(c.Name), " ", "_")
- return path.Join(c.Set.String(), fileName)
+ return path.Join(c.Set.String(), c.FileName())
}
func (c *Card) IsPermanent() bool {
diff --git a/go/ui/mapView.go b/go/ui/mapView.go
index 9b1cd206..f716278c 100644
--- a/go/ui/mapView.go
+++ b/go/ui/mapView.go
@@ -282,7 +282,7 @@ func (vw *MapView) drawMapLayer(screen *ebiten.Image) {
}
func getPermanentSymbol(p game.Permanent, i int) *ebiten.Image {
- permanentSymbol := assets.GetSymbol(strings.ToLower(p.Card().Name))
+ permanentSymbol := assets.GetSymbol(p.Card().FileName())
if permanentSymbol == nil {
symbol := fmt.Sprintf("%c%d", unicode.ToUpper(rune(p.Card().Type.String()[0])), i)
permanentSymbol = assets.GetGenericSymbol(symbol)