Eigene Schläge pro Kachel zählen

Als Gast kann die Meldung eines Schlags erst nach dem nächsten Schlag
auf dieselbe Kachel ankommen. Ein Merker pro Kachel ging dabei verloren,
und der brechende Schlag zeigte seine Splitter doch zweimal. Die
Hauptszene zählt ihre noch nicht gemeldeten Schläge deshalb pro Kachel
und vergisst sie, wenn die Welt neu abgeglichen wird.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Steven Wroblewski
2026-10-02 12:19:01 +02:00
parent 55c09b0f1f
commit 69b642cc60
2 changed files with 37 additions and 6 deletions
+18 -6
View File
@@ -62,9 +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] = {}
## How many own hits on each tile showed their burst of chips at once and
## are not reported by the core yet. Their burst is not shown a second time.
var _own_hits: Dictionary[Vector2i, int] = {}
func _ready() -> void:
@@ -310,6 +310,7 @@ func _on_notice(notice: Dictionary) -> void:
resyncs += 1
_keep_diverged_recording()
map_view.reload()
_own_hits.clear()
hud.show_stone(session.item_count(GwSession.ITEM_STONE))
hud.flash("RESYNCED")
else:
@@ -409,7 +410,7 @@ func _apply(events: Array[Dictionary]) -> void:
map_view.refresh_tile(tile)
# The own hits showed their burst when they were made.
if event["player"] == local:
_own_hits.erase(tile)
_own_hit_reported(tile)
else:
map_view.hit(tile)
"tile_changed":
@@ -417,7 +418,9 @@ func _apply(events: Array[Dictionary]) -> void:
map_view.refresh_tile(tile)
# The core does not say whose hit broke the tile; an own hit
# showed its burst already.
if not _own_hits.erase(tile):
if _own_hits.has(tile):
_own_hits.erase(tile)
else:
map_view.hit(tile)
"item_gained":
if event["player"] == local:
@@ -465,7 +468,16 @@ func dig_at(tile: Vector2i) -> void:
_next_dig_tick = session.tick() + GwSession.DIG_COOLDOWN_TICKS
if MapView.SOLID.has(session.terrain_at(tile.x, tile.y)):
map_view.hit(tile)
_own_hits[tile] = true
_own_hits[tile] = _own_hits.get(tile, 0) + 1
## Counts one own hit on `tile` as reported by the core.
func _own_hit_reported(tile: Vector2i) -> void:
var left: int = _own_hits.get(tile, 0) - 1
if left > 0:
_own_hits[tile] = left
else:
_own_hits.erase(tile)
## Writes the running world as the save. Returns false if nothing was