From 55c09b0f1fe32e96a5dcc2b037cd197f15c7f170 Mon Sep 17 00:00:00 2001 From: Steven Wroblewski Date: Fri, 2 Oct 2026 12:04:56 +0200 Subject: [PATCH] Eigener Schlag zeigt beim Brechen keine zweiten Splitter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der Kern meldet einen Schlag, der Fels bricht, nur als geänderte Kachel ohne Spieler. Die Hauptszene merkt sich deshalb die Kacheln ihrer eigenen Schläge, bis der Kern sie meldet, und zeigt dann keinen zweiten Splitterwurf. Als Gast kam der zweite eine Rundreise später und sah wieder verzögert aus. Splitter gibt es nur noch auf Fels, nicht mehr außerhalb der Karte. Co-Authored-By: Claude Haiku 4.5 --- game/scripts/main.gd | 17 ++++++++++++++--- game/tests/test_main.gd | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/game/scripts/main.gd b/game/scripts/main.gd index 2f64871..39e6aed 100644 --- a/game/scripts/main.gd +++ b/game/scripts/main.gd @@ -62,6 +62,9 @@ var _joining := "" ## The host's accepted guests when _process last looked. A new one ends a ## pause. var _known_guests := 0 +## Tiles whose burst of chips the own figure showed when it hit them, until +## the core reports that hit. Their burst is not shown a second time. +var _own_hits: Dictionary[Vector2i, bool] = {} func _ready() -> void: @@ -217,6 +220,7 @@ func _show_world() -> void: hud.show_stone(session.item_count(GwSession.ITEM_STONE)) _update_status() _next_dig_tick = 0 + _own_hits.clear() ## Says in the status line how the game is shared, and with how many. @@ -242,6 +246,7 @@ func _leave(message: String) -> void: map_view.reload() avatar.is_walkable = Callable() figures.clear() + _own_hits.clear() _show_menu(message) @@ -403,12 +408,17 @@ func _apply(events: Array[Dictionary]) -> void: var tile := Vector2i(event["x"], event["y"]) map_view.refresh_tile(tile) # The own hits showed their burst when they were made. - if event["player"] != local: + if event["player"] == local: + _own_hits.erase(tile) + else: map_view.hit(tile) "tile_changed": var tile := Vector2i(event["x"], event["y"]) map_view.refresh_tile(tile) - map_view.hit(tile) + # The core does not say whose hit broke the tile; an own hit + # showed its burst already. + if not _own_hits.erase(tile): + map_view.hit(tile) "item_gained": if event["player"] == local: hud.show_stone(session.item_count(GwSession.ITEM_STONE)) @@ -453,8 +463,9 @@ func dig_at(tile: Vector2i) -> void: return session.dig(tile.x, tile.y) _next_dig_tick = session.tick() + GwSession.DIG_COOLDOWN_TICKS - if session.terrain_at(tile.x, tile.y) != GwSession.TERRAIN_GROUND: + if MapView.SOLID.has(session.terrain_at(tile.x, tile.y)): map_view.hit(tile) + _own_hits[tile] = true ## Writes the running world as the save. Returns false if nothing was diff --git a/game/tests/test_main.gd b/game/tests/test_main.gd index 5cf7f4e..45c51c9 100644 --- a/game/tests/test_main.gd +++ b/game/tests/test_main.gd @@ -392,3 +392,17 @@ func test_an_own_hit_shows_its_burst_at_once() -> void: main.dig_at(rock) check_eq(main.map_view.burst_count(), 1, "the burst shows before the hit lands in a tick") _clean_up([directory]) + + +func test_an_own_hit_that_breaks_the_rock_shows_its_burst_only_once() -> void: + var directory := TestFiles.temporary_dir("break") + var main := _start_main(directory) + main.play(false) + var rock: Vector2i = main.session.spawn_point() + Vector2i(7, -2) + for blow in 3: + main.dig_at(rock) + for tick in GwSession.DIG_COOLDOWN_TICKS + 1: + main._run_tick() + check_eq(main.session.terrain_at(rock.x, rock.y), GwSession.TERRAIN_GROUND, "three own hits break the rock") + check_eq(main.map_view.burst_count(), 3, "one burst per own hit, none more when the rock breaks") + _clean_up([directory])