From b8123725146c7a20eadcb14caabdb5115a0824e7 Mon Sep 17 00:00:00 2001 From: dingo Date: Sat, 21 Mar 2026 10:22:29 -0400 Subject: [PATCH] Fix rule suggestions + placement highlights - JoinCustomLobbyResponse now includes ActiveRules so the guest's rule editor pre-populates from the lobby's current effective rules instead of hardcoded defaults; previously all fields in a suggestion were sent as defaults, causing accepted suggestions to reset rules to defaults. - game_screen.gd: placement tile highlights are now re-applied on every state update while the player hasn't placed yet, not only on the first entry into PLACEMENT mode; fixes highlights disappearing when the opponent places their ArchSpirit and a delta arrives mid-placement. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../origin-client/scenes/game/game_screen.gd | 6 ++--- Server/src/SOR.Game/GameMessages.cs | 7 +++--- .../Handlers/GameJoinCustomLobbyHandler.cs | 24 +++++++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 57cb98d..55118e2 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -477,7 +477,7 @@ func _fetch_skybox() -> void: Network.request("content.get_skybox_config", {}, func(_type: String, resp: Variant) -> void: var d := resp as Dictionary - var skybox := d.get("skybox", null) + var skybox : Dictionary = d.get("skybox", null) if skybox == null: return # no active skybox — keep procedural sky var cdn_path : String = str(skybox.get("cdnPath", "")) @@ -2952,8 +2952,8 @@ func _update_hud(state: Dictionary) -> void: _phase_lbl.text = "Phase: Placement — click a tile to place your ArchSpirit" if _mode != Mode.PLACEMENT: _set_mode(Mode.PLACEMENT) - _clear_highlights() - _highlight_tiles(_valid_placement_tiles(), HI_GREEN) + _clear_highlights() + _highlight_tiles(_valid_placement_tiles(), HI_GREEN) else: _phase_lbl.text = "Phase: Placement — waiting for opponent…" if _mode == Mode.PLACEMENT: diff --git a/Server/src/SOR.Game/GameMessages.cs b/Server/src/SOR.Game/GameMessages.cs index 878383e..d562715 100644 --- a/Server/src/SOR.Game/GameMessages.cs +++ b/Server/src/SOR.Game/GameMessages.cs @@ -233,9 +233,10 @@ public sealed record CreateCustomLobbyResponse( CustomRulesDto ActiveRules); public sealed record JoinCustomLobbyResponse( - Guid LobbyId, - string Status, // "WaitingForReady" - Guid? GameSessionId); // always null; reserved for future use + Guid LobbyId, + string Status, // "WaitingForReady" + CustomRulesDto ActiveRules, + Guid? GameSessionId); // always null; reserved for future use public sealed record LeaveCustomLobbyResponse(Guid LobbyId); diff --git a/Server/src/SOR.Game/Handlers/GameJoinCustomLobbyHandler.cs b/Server/src/SOR.Game/Handlers/GameJoinCustomLobbyHandler.cs index b21c0af..89740c6 100644 --- a/Server/src/SOR.Game/Handlers/GameJoinCustomLobbyHandler.cs +++ b/Server/src/SOR.Game/Handlers/GameJoinCustomLobbyHandler.cs @@ -66,6 +66,29 @@ internal sealed class GameJoinCustomLobbyHandler : GameHandlerBase, IMessageHand await _gameDb.SaveChangesAsync(ct); + // Build effective rules so the guest can pre-populate their rule editor. + var effective = new GameRules + { + OpeningHandSize = lobby.OpeningHandSizeOverride ?? GameRules.Default.OpeningHandSize, + FirstPlayerSkipsDraw = lobby.FirstPlayerSkipsDrawOverride ?? GameRules.Default.FirstPlayerSkipsDraw, + SpAccumulationPerTurn = lobby.SpAccumulationPerTurnOverride ?? GameRules.Default.SpAccumulationPerTurn, + DrawPerTurn = lobby.DrawPerTurnOverride ?? GameRules.Default.DrawPerTurn, + SpHasCap = lobby.SpHasCapOverride ?? GameRules.Default.SpHasCap, + SpCap = lobby.SpCapOverride ?? GameRules.Default.SpCap, + BoardWidth = lobby.BoardWidthOverride ?? GameRules.Default.BoardWidth, + BoardHeight = lobby.BoardHeightOverride ?? GameRules.Default.BoardHeight, + HandSizeCap = lobby.HandSizeCapOverride ?? GameRules.Default.HandSizeCap, + DiscardOnMaxHand = lobby.DiscardOnMaxHandOverride ?? GameRules.Default.DiscardOnMaxHand, + MaxDeckSize = lobby.MaxDeckSizeOverride ?? GameRules.Default.MaxDeckSize, + MinDeckSize = lobby.MinDeckSizeOverride ?? GameRules.Default.MinDeckSize, + MaxArchTier1 = lobby.MaxArchTier1Override ?? GameRules.Default.MaxArchTier1, + TurnTimerSeconds = lobby.TurnTimerSecondsOverride ?? GameRules.Default.TurnTimerSeconds, + TimeLimitMinutes = lobby.TimeLimitMinutesOverride ?? GameRules.Default.TimeLimitMinutes, + TurnLimit = lobby.TurnLimitOverride ?? GameRules.Default.TurnLimit, + MpBuff = lobby.MpBuffOverride ?? GameRules.Default.MpBuff, + StartingRandomTilePct = lobby.StartingRandomTilePctOverride ?? GameRules.Default.StartingRandomTilePct, + }; + // Notify the host that their guest has arrived. await _clientPush.PushAsync(lobby.HostAccountId.ToString(), ServerMessage.Push("game.custom.lobby.guest_joined", @@ -78,6 +101,7 @@ internal sealed class GameJoinCustomLobbyHandler : GameHandlerBase, IMessageHand new JoinCustomLobbyResponse( LobbyId : lobby.Id, Status : "WaitingForReady", + ActiveRules : GameCreateCustomLobbyHandler.ToDto(effective, lobby.Password != null), GameSessionId: null)); } }