diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-11 00:07:56 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-11 00:07:56 +0200 |
commit | 7fca7e65985deb24d51041d30fb8ea6ed2bd8571 (patch) | |
tree | 1c0b918d97b9122a9e1b091654bc5b441609e7c0 /Hex.gd | |
parent | 35b1995824bbc3e35ed2488e4034cc6b47c2bc76 (diff) | |
download | godot-hexgrid-7fca7e65985deb24d51041d30fb8ea6ed2bd8571.zip godot-hexgrid-7fca7e65985deb24d51041d30fb8ea6ed2bd8571.tar.gz |
properly implement road march
Diffstat (limited to 'Hex.gd')
-rw-r--r-- | Hex.gd | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -4,6 +4,7 @@ extends Tile class_name Hex, "res://godot/Tile.png" var type : int = -1 +var roads : int = 0 func _ready() -> void: type = -1 @@ -13,15 +14,20 @@ func inspect() -> String: if type == 0: s = 'city' elif type == 1: s = 'wood' elif type == 2: s = 'mountain' - return "%s e:%d h:%d c:%d\n -> [%d;%d]\n -> (%d;%d)" % [s, elevation(), height(), cost(), coords.x, coords.y, position.x, position.y] + elif type == 3: s = 'impracticable' + return "%s e:%d h:%d c:%d r:%d\n -> [%d;%d]\n -> (%d;%d)" % [s, elevation(), height(), cost(), roads, coords.x, coords.y, position.x, position.y] + +func has_road(o : int) -> bool: + return (o & roads) > 0 func change() -> void: - type = (type + 2) % 4 - 1 - for i in range(3): + type = (type + 2) % 5 - 1 + for i in range(4): enable_overlay(i + 2, i == type) func cost() -> int: if type == -1: return 1 + elif type == 3: return -1 return type + 1 func height() -> int: @@ -51,5 +57,5 @@ func show_los(b) -> void: enable_overlay(1, false) func show_move(b) -> void: - if 5 < get_child_count(): - enable_overlay(5, b) + if 6 < get_child_count(): + enable_overlay(6, b) |