aboutsummaryrefslogtreecommitdiff
path: root/go/game
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-09-04 15:26:03 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-09-04 18:10:35 +0200
commit8425522026477c0a0f74127ff441dba3933c92c9 (patch)
treebf5a8df8a2a3f765e1c038edcf2e9c9fa193ea8c /go/game
parent6746771b8f8490c6e10f7f0d35226cdd7719f231 (diff)
downloadmuhqs-game-8425522026477c0a0f74127ff441dba3933c92c9.tar.gz
muhqs-game-8425522026477c0a0f74127ff441dba3933c92c9.zip
replace yaml.v3 with goccy/go-yaml
Diffstat (limited to 'go/game')
-rw-r--r--go/game/attack.go4
-rw-r--r--go/game/attack_test.go2
-rw-r--r--go/game/card.go6
-rw-r--r--go/game/costs.go4
-rw-r--r--go/game/equipment.go2
-rw-r--r--go/game/map.go10
-rw-r--r--go/game/movement.go4
-rw-r--r--go/game/unit.go2
8 files changed, 18 insertions, 16 deletions
diff --git a/go/game/attack.go b/go/game/attack.go
index 9fa71087..0e5c66ab 100644
--- a/go/game/attack.go
+++ b/go/game/attack.go
@@ -98,8 +98,8 @@ func (a Attack) String() string {
}
func parseAttack(attack any) Attack {
- if damage, ok := attack.(int); ok {
- return Attack{attacks: []int{damage}}
+ if damage, ok := attack.(uint64); ok {
+ return Attack{attacks: []int{int(damage)}}
}
attackStr := attack.(string)
diff --git a/go/game/attack_test.go b/go/game/attack_test.go
index 52ba41a0..0a6113c6 100644
--- a/go/game/attack_test.go
+++ b/go/game/attack_test.go
@@ -5,7 +5,7 @@ import (
)
func TestParseIntAttack(t *testing.T) {
- a := parseAttack(1)
+ a := parseAttack(uint64(1))
if a.MaxRange() != 1 {
t.Fatal("unexpected max range (1):", a.MaxRange())
}
diff --git a/go/game/card.go b/go/game/card.go
index fe7f6ca8..bdacd51b 100644
--- a/go/game/card.go
+++ b/go/game/card.go
@@ -9,7 +9,7 @@ import (
"strconv"
"strings"
- "gopkg.in/yaml.v3"
+ "github.com/goccy/go-yaml"
"muhq.space/muhqs-game/go/assets"
"muhq.space/muhqs-game/go/log"
)
@@ -295,8 +295,8 @@ func (card *Card) getCanonicalValues(key string) []string {
}
case string:
values = []string{typedValues}
- case int:
- values = []string{strconv.Itoa(typedValues)}
+ case uint64:
+ values = []string{strconv.Itoa(int(typedValues))}
case []string:
values = typedValues
}
diff --git a/go/game/costs.go b/go/game/costs.go
index 38064e8c..daa2c213 100644
--- a/go/game/costs.go
+++ b/go/game/costs.go
@@ -54,8 +54,8 @@ func (c *ResourceCosts) Costs(s *LocalState, choosenVariadicCosts ...int) int {
func ParseCardResourceCosts(_costs any, effects []string) *ResourceCosts {
switch c := _costs.(type) {
- case int:
- return &ResourceCosts{fixed: c}
+ case uint64:
+ return &ResourceCosts{fixed: int(c)}
case string:
costs := ParseResourceCosts(c)
if !costs.IsVariadic() {
diff --git a/go/game/equipment.go b/go/game/equipment.go
index ce21750f..4dcfad41 100644
--- a/go/game/equipment.go
+++ b/go/game/equipment.go
@@ -17,7 +17,7 @@ func newEquipmentFromPath(cardPath string, containing any, owner *Player) *Equip
func newEquipment(card *Card, containing any, owner *Player) *Equipment {
e := &Equipment{
*NewArtifact(card, nil, owner),
- card.Values["durability"].(int),
+ int(card.Values["durability"].(uint64)),
}
if containing != nil {
diff --git a/go/game/map.go b/go/game/map.go
index ea733833..6002eb96 100644
--- a/go/game/map.go
+++ b/go/game/map.go
@@ -11,7 +11,7 @@ import (
"strconv"
"strings"
- "gopkg.in/yaml.v3"
+ "github.com/goccy/go-yaml"
"muhq.space/muhqs-game/go/assets"
"muhq.space/muhqs-game/go/log"
@@ -74,9 +74,11 @@ func ParseMap(data []byte) (*Map, error) {
m.StartDeckList = mapYml.StartDeckList
}
- rows := strings.Split(mapYml.Map, "\n")
- for y := range len(rows) {
- row := rows[y]
+ // Trim trailing newlines
+ mapDef := strings.TrimRight(mapYml.Map, "\n")
+
+ rows := strings.Split(mapDef, "\n")
+ for y, row := range rows {
m.Tiles = append(m.Tiles, []Tile{})
for x := range len(rows[y]) {
pos := Position{x, y}
diff --git a/go/game/movement.go b/go/game/movement.go
index c7a5d9ff..fc2b4961 100644
--- a/go/game/movement.go
+++ b/go/game/movement.go
@@ -19,8 +19,8 @@ func INVALID_MOVEMENT() Movement {
func parseMovement(desc any) Movement {
var movementStr string
switch typedDesc := desc.(type) {
- case int:
- return Movement{typedDesc, false}
+ case uint64:
+ return Movement{int(typedDesc), false}
case string:
movementStr = typedDesc
case map[string]any:
diff --git a/go/game/unit.go b/go/game/unit.go
index b77c1974..2ab9fcf8 100644
--- a/go/game/unit.go
+++ b/go/game/unit.go
@@ -50,7 +50,7 @@ func NewUnit(card *Card, tile *Tile, owner *Player) *Unit {
u := &Unit{
permanentBase: newPermanentBase(card, tile, owner),
- Health: card.Values["health"].(int),
+ Health: int(card.Values["health"].(uint64)),
Movement: movement,
Attack: attack,
upkeep: upkeep,