mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-21 11:18:08 +00:00
Enhance NPC encounter tracking and logging in GamesController
- Added logging for the number of NPCs in a room when loading it, improving visibility into game state. - Ensured NPC encounters are tracked when unlocking doors, even when using cached room data, to maintain accurate encounter statistics.
This commit is contained in:
@@ -208,6 +208,8 @@ module BreakEscape
|
||||
return render_error("Room not found: #{room_id}", :not_found) unless room_data
|
||||
|
||||
# Track NPC encounters BEFORE sending response
|
||||
npc_count = room_data['npcs']&.length || 0
|
||||
Rails.logger.info "[BreakEscape] 📦 Loading room: #{room_id} (NPCs: #{npc_count})"
|
||||
track_npc_encounters(room_id, room_data)
|
||||
|
||||
Rails.logger.debug "[BreakEscape] Serving room data for: #{room_id}"
|
||||
@@ -340,6 +342,10 @@ module BreakEscape
|
||||
|
||||
room_data = @game.filtered_room_data(target_id)
|
||||
|
||||
# Track NPC encounters when unlocking a door (room data is cached by client)
|
||||
# This ensures NPCs are tracked even if loadRoom() uses cached data
|
||||
track_npc_encounters(target_id, room_data)
|
||||
|
||||
render json: {
|
||||
success: true,
|
||||
type: 'door',
|
||||
|
||||
Reference in New Issue
Block a user