From 53e1912c7464cf49e527045aa4fffbbdc322d0b9 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 26 Dec 2024 19:14:51 +0100 Subject: support calculating Costs including chosen variadic costs --- go/game/costs.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'go') diff --git a/go/game/costs.go b/go/game/costs.go index 6bdb98f2..06e394ab 100644 --- a/go/game/costs.go +++ b/go/game/costs.go @@ -1,6 +1,7 @@ package game import ( + "log" "strconv" "strings" ) @@ -27,7 +28,7 @@ func ParseResourceCosts(costsStr string) *ResourceCosts { return &costs } -func (c *ResourceCosts) Costs(s *State) int { +func (c *ResourceCosts) Costs(s *State, choosenVariadicCosts ...int) int { if !c.IsVariadic() { return c.fixed } @@ -36,8 +37,18 @@ func (c *ResourceCosts) Costs(s *State) int { return c.fixed + c.variadicConstraintFunc(s) } - // TODO: implement variadic costs - return 0 + costs := c.fixed + if len(choosenVariadicCosts) == 1 { + vc := choosenVariadicCosts[0] + if vc >= 0 { + costs = costs + c.variadicComponents*vc + } else { + log.Println("Invalid variadic costs choosen") + } + } else { + log.Println("Unambigous variadic costs choosen") + } + return costs } func ParseCardResourceCosts(_costs interface{}, effects []string) *ResourceCosts { -- cgit v1.2.3