aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-12-26 19:14:51 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:12 +0200
commit53e1912c7464cf49e527045aa4fffbbdc322d0b9 (patch)
tree5d0280d85c0bf34be1193ba98d7a5ff9f6147adf
parenta5422afa267c368815b7916ae3ec717aacb05108 (diff)
downloadmuhqs-game-53e1912c7464cf49e527045aa4fffbbdc322d0b9.tar.gz
muhqs-game-53e1912c7464cf49e527045aa4fffbbdc322d0b9.zip
support calculating Costs including chosen variadic costs
-rw-r--r--go/game/costs.go17
1 files changed, 14 insertions, 3 deletions
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 {