adding timer cfgs
This commit is contained in:
@@ -31,6 +31,9 @@ var training_bar: ProgressBar
|
||||
var training_started_unix := 0.0
|
||||
var training_completes_unix := 0.0
|
||||
var training_completion_refresh_requested := false
|
||||
var building_started_unix := 0.0
|
||||
var building_completes_unix := 0.0
|
||||
var building_completion_refresh_requested := false
|
||||
var claim_button: Button
|
||||
var build_log_camp_button: Button
|
||||
var selected_q := 0
|
||||
@@ -48,6 +51,7 @@ func _ready() -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
_update_tick_bar()
|
||||
_update_training_bar()
|
||||
_update_building_timer()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
@@ -634,7 +638,13 @@ func _on_build_request_completed(result: int, response_code: int, _headers: Pack
|
||||
|
||||
selected_can_build_log_camp = false
|
||||
build_log_camp_button.disabled = true
|
||||
coordinate_label.text = "Log Camp built. Wood production increased."
|
||||
var parsed = JSON.parse_string(text)
|
||||
if typeof(parsed) == TYPE_DICTIONARY:
|
||||
var location: Dictionary = parsed
|
||||
building_started_unix = _parse_utc_timestamp(str(location.get("buildingStartedAtUtc", "")))
|
||||
building_completes_unix = _parse_utc_timestamp(str(location.get("buildingCompletesAtUtc", "")))
|
||||
building_completion_refresh_requested = false
|
||||
coordinate_label.text = "Log Camp construction started. Completion takes 1 minute."
|
||||
_load_visible_locations()
|
||||
_refresh_player_state()
|
||||
|
||||
@@ -682,6 +692,20 @@ func _update_training_bar() -> void:
|
||||
training_label.text = "Training: %ds" % remaining
|
||||
|
||||
|
||||
func _update_building_timer() -> void:
|
||||
if building_started_unix <= 0.0 or building_completes_unix <= 0.0:
|
||||
return
|
||||
|
||||
var remaining: int = int(max(0, int(ceil(building_completes_unix - Time.get_unix_time_from_system()))))
|
||||
if remaining > 0:
|
||||
return
|
||||
|
||||
if not building_completion_refresh_requested:
|
||||
building_completion_refresh_requested = true
|
||||
_load_visible_locations()
|
||||
_refresh_player_state()
|
||||
|
||||
|
||||
func _parse_utc_timestamp(timestamp: String) -> float:
|
||||
if timestamp.is_empty():
|
||||
return 0.0
|
||||
|
||||
@@ -162,8 +162,11 @@ func _draw_tile(tile: Dictionary) -> void:
|
||||
|
||||
var visible_location: Dictionary = visible_tiles.get(key, {})
|
||||
var building_type: String = str(visible_location.get("buildingType", ""))
|
||||
if building_type == "LogCamp":
|
||||
var building_status: String = str(visible_location.get("buildingStatus", ""))
|
||||
if building_type == "LogCamp" and (building_status == "Built" or building_status.is_empty()):
|
||||
_draw_log_camp_marker(center, height)
|
||||
elif building_type == "LogCamp":
|
||||
_draw_building_marker(center, height)
|
||||
|
||||
|
||||
func _draw_control_regions(sorted_tiles: Array) -> void:
|
||||
@@ -298,6 +301,13 @@ func _draw_log_camp_marker(center: Vector2, height: float) -> void:
|
||||
draw_line(marker_center + Vector2(-width * 0.38, marker_height * 0.86), marker_center + Vector2(width * 0.38, marker_height * 0.86), log_color.darkened(0.12), 3.0 * zoom)
|
||||
|
||||
|
||||
func _draw_building_marker(center: Vector2, height: float) -> void:
|
||||
var marker_center: Vector2 = center + Vector2(0, -height * zoom - 1.0)
|
||||
var radius: float = 7.0 * zoom
|
||||
draw_arc(marker_center, radius, 0.0, TAU, 24, Color(0.95, 0.76, 0.28), 2.0 * zoom)
|
||||
draw_line(marker_center + Vector2(-radius * 0.7, radius * 0.7), marker_center + Vector2(radius * 0.7, -radius * 0.7), Color(0.95, 0.76, 0.28), 2.0 * zoom)
|
||||
|
||||
|
||||
func _tile_data(q: int, r: int) -> Dictionary:
|
||||
for tile in tiles:
|
||||
if int(tile["q"]) == q and int(tile["r"]) == r:
|
||||
@@ -389,9 +399,10 @@ func _neighbor_coordinates(q: int, r: int) -> Array[Vector2i]:
|
||||
func _tile_display_label(key: String, data: Dictionary) -> String:
|
||||
var terrain: String = str(data.get("terrain", "Open"))
|
||||
var building_type: String = str(data.get("buildingType", ""))
|
||||
var building_status: String = str(data.get("buildingStatus", ""))
|
||||
var building_label: String = ""
|
||||
if building_type == "LogCamp":
|
||||
building_label = " | Log Camp"
|
||||
building_label = " | Log Camp" if building_status == "Built" or building_status.is_empty() else " | Log Camp building"
|
||||
|
||||
if home_tile == Vector2i(int(data.get("q", 0)), int(data.get("r", 0))):
|
||||
return "%s | Your home%s" % [terrain, building_label]
|
||||
@@ -444,7 +455,7 @@ func _terrain_color_for_name(terrain: String, _q: int, _r: int, _height: float)
|
||||
"Command":
|
||||
return Color(0.68, 0.58, 0.28)
|
||||
"Forest":
|
||||
return Color(0.24, 0.45, 0.29)
|
||||
return Color(0.12, 0.31, 0.18)
|
||||
"Ore":
|
||||
return Color(0.42, 0.46, 0.5)
|
||||
"Highland":
|
||||
|
||||
Reference in New Issue
Block a user