diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-12-26 19:14:51 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:57 +0100 |
| commit | 4275eea579aec664763e8c8ad74ced5b8033461f (patch) | |
| tree | 0dc4e39661dd1245d69aac2f870a3b52ecf8b452 | |
| parent | da31a3be2a5ac5d7d9a9d1265065226aea1e85cd (diff) | |
| download | muhqs-game-4275eea579aec664763e8c8ad74ced5b8033461f.tar.gz muhqs-game-4275eea579aec664763e8c8ad74ced5b8033461f.zip | |
support calculating Costs including chosen variadic costs
| -rw-r--r-- | go/game/costs.go | 17 |
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 { |
