aboutsummaryrefslogtreecommitdiff
path: root/go/game/map.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-19 18:44:19 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:25 +0200
commitb40ed097c2c327414b0d6945a231ac3278f00544 (patch)
treead8f1e787c8a4f4bfdc197beb22cf0c015f617c4 /go/game/map.go
parent0be3f6cb2373a71e301bb693fa947d7fa258fba0 (diff)
downloadmuhqs-game-b40ed097c2c327414b0d6945a231ac3278f00544.tar.gz
muhqs-game-b40ed097c2c327414b0d6945a231ac3278f00544.zip
fix king map preparation
Diffstat (limited to 'go/game/map.go')
-rw-r--r--go/game/map.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/go/game/map.go b/go/game/map.go
index b3203bd4..54071933 100644
--- a/go/game/map.go
+++ b/go/game/map.go
@@ -28,7 +28,7 @@ type MapYml struct {
Map string `yaml:"map"`
Symbols map[string]string `yaml:"symbols"`
StartDeckList string `yaml:"start_deck_list"`
- Kings [][]int `yaml:"omitemptt"`
+ Kings [][]int `yaml:"kings,omitempty"`
}
type Map struct {
@@ -95,13 +95,16 @@ func ParseMap(data []byte) (*Map, error) {
m.selectStreets()
- if len(mapYml.Kings) == 0 {
+ if len(mapYml.Kings) > 0 {
m.WinCondition = KingGame
m.Prepare = func(s *LocalState) {
- k := NewCard("misc/king")
for i, kingPos := range mapYml.Kings {
- p := s.PlayerById(i + 1)
- s.addNewUnit(k, Position{kingPos[0], kingPos[1]}, p)
+ card := NewCard("misc/king")
+ owner := s.PlayerById(i + 1)
+ // TODO: Fix position index base.
+ pos := Position{kingPos[0] - 1, kingPos[1] - 1}
+ log.Println(card, pos, owner)
+ s.addNewUnit(card, pos, owner)
}
}
}
@@ -210,9 +213,9 @@ func LoadMap(path string) (*Map, error) {
}
// TileAt returns the tile at a certain position.
-// Id p is an invalid position, nil is returned.
+// If p is an invalid position, nil is returned.
func (m *Map) TileAt(p Position) *Tile {
- if p.Y < 0 || p.Y >= len(m.Tiles) || p.X < 0 || p.X >= len(m.Tiles[p.Y]) {
+ if !p.Valid() || p.Y >= len(m.Tiles) || p.X >= len(m.Tiles[p.Y]) {
return nil
}
return &m.Tiles[p.Y][p.X]