aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-09-03 12:36:30 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-09-03 12:39:41 +0200
commitfb755f3d325720b1e42df5bea049781b538afa5c (patch)
treeb32adb1b83fb311692c5b95053741eb53bc544d1
parent4c3e641243ee0ce712dbdd6da7085253b4bdcc91 (diff)
downloadmuhqs-game-fb755f3d325720b1e42df5bea049781b538afa5c.tar.gz
muhqs-game-fb755f3d325720b1e42df5bea049781b538afa5c.zip
fix String method of free action using nil targets
-rw-r--r--go/game/action.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/go/game/action.go b/go/game/action.go
index 5bb8bd67..856ea6bc 100644
--- a/go/game/action.go
+++ b/go/game/action.go
@@ -682,13 +682,22 @@ func NewFreeAction(p Permanent, resolveProto ActionFuncPrototype, costFunc Actio
func (a *FreeAction) Speed() ActionSpeed { return fast }
-func (a *FreeAction) String() string {
- p := a.source.(Permanent)
- if a.targets.RequireSelection() {
- return fmt.Sprintf("free_action %s", a.desc)
+func (a *FreeAction) String() (s string) {
+ switch src := a.source.(type) {
+ case *Card:
+ s += fmt.Sprintf("%v: %s ", a.Controller(), src.Name)
+ default:
+ s += fmt.Sprintf("%s", src)
}
- return fmt.Sprintf("%v: %s free_action@%v", p.Controller(), p.Card().Name, a.targets)
+ s += " free_action"
+ if a.targets == nil || a.targets.RequireSelection() {
+ s += fmt.Sprintf(" %s", a.desc)
+ } else {
+ s += fmt.Sprintf("@%v", a.targets)
+ }
+
+ return
}
var buyActionTargetDesc = TargetDesc{"store card", "?"}