aboutsummaryrefslogtreecommitdiff
path: root/go/game
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-08-20 15:57:27 +0200
commit2b31330cb51e9be8960fa7d7dc1d9c6e3bba79eb (patch)
treea5e3879b62fcfcf72460ab1a62d3f51abeec980f /go/game
parent181b38d96fbc13c7d8429eaeef5610b98f99c38c (diff)
downloadmuhqs-game-2b31330cb51e9be8960fa7d7dc1d9c6e3bba79eb.tar.gz
muhqs-game-2b31330cb51e9be8960fa7d7dc1d9c6e3bba79eb.zip
use canonical file names to retrieve card symbols
Diffstat (limited to 'go/game')
-rw-r--r--go/game/card.go10
1 files changed, 8 insertions, 2 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 {