aboutsummaryrefslogtreecommitdiff
path: root/go/game/tile.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-01-24 00:27:50 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:44 +0100
commit73d40903aecad3efcf7c6055c133f0db86558203 (patch)
treee9c8f00fb186e270da92f273f570579f2d0b0d95 /go/game/tile.go
parentfbba48698d8f8b83dfd7d914b0e37338e0d4e2ef (diff)
downloadmuhqs-game-73d40903aecad3efcf7c6055c133f0db86558203.tar.gz
muhqs-game-73d40903aecad3efcf7c6055c133f0db86558203.zip
intermediate commit
Diffstat (limited to 'go/game/tile.go')
-rw-r--r--go/game/tile.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/go/game/tile.go b/go/game/tile.go
index f66b4fb0..cbceb6f7 100644
--- a/go/game/tile.go
+++ b/go/game/tile.go
@@ -64,18 +64,25 @@ type Tile struct {
Position Position
Permanent Permanent
Type TileType
+ Water bool
Raw string
}
func INVALID_TILE() Tile {
- return Tile{INVALID_POSITION(), nil, 0, ""}
+ return Tile{INVALID_POSITION(), nil, 0, false, ""}
}
-func NewTileFromString(tile string, pos Position) (Tile, error) {
+func NewTileFromString(t string, pos Position) (Tile, error) {
+ tile := strings.ToLower(t)
tokens := strings.Split(tile, " ")
- tileType := TileNames[strings.ToLower(tokens[0])]
- t := Tile{pos, nil, tileType, tile}
- return t, nil
+ tileType, found:= TileNames[tokens[0]]
+ if !found {
+ if strings.Contains(tile, "spawn") {
+ tileType = spawn
+ }
+ }
+ water := strings.Contains(tile, "water")
+ return Tile{pos, nil, tileType, water, t}, nil
}
func (t *Tile) IsFree() bool {