From d62bf9e06b3fa1418c39928dfcaa882f51473e6a Mon Sep 17 00:00:00 2001 From: Sewmina Date: Fri, 29 May 2026 10:02:24 +0530 Subject: [PATCH] test week rc --- Assets/Log.txt | 64 ++++++++++----------------- Assets/Scenes/Game.unity | 24 +++++----- Assets/Scripts/GameManager.cs | 31 ++++++++++++- Assets/Scripts/GameOverCanvas.cs | 54 +++++++++++++++++++--- Assets/Scripts/NetPlayer.cs | 22 +++++---- ProjectSettings/ProjectSettings.asset | 2 +- 6 files changed, 129 insertions(+), 68 deletions(-) diff --git a/Assets/Log.txt b/Assets/Log.txt index 6c90aff6..6f63dece 100644 --- a/Assets/Log.txt +++ b/Assets/Log.txt @@ -1,41 +1,25 @@ -Logger initiated at 5/27/2026 11:22:24 PM +Logger initiated at 5/29/2026 9:58:40 AM -[5/27/2026 11:22:24 PM] Cupid settings updated -[5/27/2026 11:22:25 PM] Cupid settings updated -[5/27/2026 11:22:27 PM] Starting matchmake as warlock2 -[5/27/2026 11:22:27 PM] Starting matchmake as warlock -[5/27/2026 11:22:29 PM] Still waiting: {"ok":true,"entry_fee":21,"rc_prize":34,"for_red":{"Players":[{"Name":"warlock2","LastSeen":1779904349877,"UserId":3,"l10_wins":3,"l10_losses":5}],"GameName":"soccar","Port":26958,"InitTime":1779904349877,"entry_fee":21,"match_id":118,"rc_prize":34,"your_team":"red"},"for_blue":null} -[5/27/2026 11:22:30 PM] Got into a room -[5/27/2026 11:22:30 PM] {"ok":true,"entry_fee":21,"rc_prize":34,"for_red":{"Players":[{"Name":"warlock2","LastSeen":1779904349877,"UserId":3,"l10_wins":3,"l10_losses":5},{"Name":"warlock","LastSeen":1779904350254,"UserId":2,"l10_wins":4,"l10_losses":2}],"GameName":"soccar","Port":26958,"InitTime":1779904349877,"entry_fee":21,"match_id":118,"instance_started":true,"rc_prize":34,"your_team":"red"},"for_blue":{"Players":[{"Name":"warlock2","LastSeen":1779904349877,"UserId":3,"l10_wins":3,"l10_losses":5},{"Name":"warlock","LastSeen":1779904350254,"UserId":2,"l10_wins":4,"l10_losses":2}],"GameName":"soccar","Port":26958,"InitTime":1779904349877,"entry_fee":21,"match_id":118,"instance_started":true,"rc_prize":34,"your_team":"blue"}} -[5/27/2026 11:22:30 PM] Configured dedicated match reporting for match id 118 with secret 38516e39d3406225b7c3015a66e5d25c54e9b2024c0755212122bdcea3e3a328 and internal api base https://kickkingsapi.playpoolstudios.com -[5/27/2026 11:22:30 PM] Setting cupid to load game scene -[5/27/2026 11:22:30 PM] Loading game scene -[5/27/2026 11:22:31 PM] Got into a room -[5/27/2026 11:22:31 PM] {"ok":true,"entry_fee":21,"rc_prize":34,"for_red":{"Players":[{"Name":"warlock2","LastSeen":1779904351324,"UserId":3,"l10_wins":3,"l10_losses":5},{"Name":"warlock","LastSeen":1779904350254,"UserId":2,"l10_wins":4,"l10_losses":2}],"GameName":"soccar","Port":26958,"InitTime":1779904349877,"entry_fee":21,"match_id":118,"instance_started":true,"rc_prize":34,"your_team":"red"},"for_blue":{"Players":[{"Name":"warlock2","LastSeen":1779904351324,"UserId":3,"l10_wins":3,"l10_losses":5},{"Name":"warlock","LastSeen":1779904350254,"UserId":2,"l10_wins":4,"l10_losses":2}],"GameName":"soccar","Port":26958,"InitTime":1779904349877,"entry_fee":21,"match_id":118,"instance_started":true,"rc_prize":34,"your_team":"blue"}} -[5/27/2026 11:22:31 PM] Configured dedicated match reporting for match id 118 with secret 38516e39d3406225b7c3015a66e5d25c54e9b2024c0755212122bdcea3e3a328 and internal api base https://kickkingsapi.playpoolstudios.com -[5/27/2026 11:22:31 PM] Setting cupid to load game scene -[5/27/2026 11:22:31 PM] Loading game scene -[5/27/2026 11:22:35 PM] Starting client at $kickkingsapi.playpoolstudios.com:26958 -[5/27/2026 11:22:35 PM] Client connected -[5/27/2026 11:22:36 PM] Starting client at $kickkingsapi.playpoolstudios.com:26958 -[5/27/2026 11:22:36 PM] Client connected -[5/27/2026 11:22:43 PM] Selected team changed from Red to Blue -[5/27/2026 11:22:43 PM] Selected team changed from Red to Blue -[5/27/2026 11:22:47 PM] Selected team changed from Blue to Red -[5/27/2026 11:22:47 PM] Score changed from 0 to 1 -[5/27/2026 11:22:47 PM] Selected team changed from Blue to Red -[5/27/2026 11:22:47 PM] Score changed from 0 to 1 -[5/27/2026 11:22:50 PM] Selected team changed from Red to Blue -[5/27/2026 11:22:50 PM] Selected team changed from Red to Blue -[5/27/2026 11:22:56 PM] Selected team changed from Blue to Red -[5/27/2026 11:22:56 PM] Selected team changed from Blue to Red -[5/27/2026 11:22:58 PM] Score changed from 1 to 2 -[5/27/2026 11:22:58 PM] Score changed from 1 to 2 -[5/27/2026 11:23:01 PM] Selected team changed from Red to Blue -[5/27/2026 11:23:01 PM] Selected team changed from Red to Blue -[5/27/2026 11:23:06 PM] Selected team changed from Blue to Red -[5/27/2026 11:23:06 PM] Selected team changed from Blue to Red -[5/27/2026 11:23:08 PM] Score changed from 2 to 3 -[5/27/2026 11:23:08 PM] Score changed from 2 to 3 -[5/27/2026 11:23:59 PM] Client disconnected -[5/27/2026 11:24:01 PM] Client disconnected +[5/29/2026 9:58:40 AM] Cupid settings updated +[5/29/2026 9:58:40 AM] Cupid settings updated +[5/29/2026 9:58:41 AM] Starting matchmake as warlock +[5/29/2026 9:58:44 AM] Got into a room +[5/29/2026 9:58:44 AM] {"ok":true,"entry_fee":21,"rc_prize":34,"for_red":{"Players":[{"Name":"warlock2","LastSeen":1780028923470,"UserId":3,"l10_wins":5,"l10_losses":3},{"Name":"warlock","LastSeen":1780028923874,"UserId":2,"l10_wins":3,"l10_losses":6}],"GameName":"soccar","Port":26438,"InitTime":1780028923470,"entry_fee":21,"match_id":128,"instance_started":true,"rc_prize":34,"your_team":"red"},"for_blue":{"Players":[{"Name":"warlock2","LastSeen":1780028923470,"UserId":3,"l10_wins":5,"l10_losses":3},{"Name":"warlock","LastSeen":1780028923874,"UserId":2,"l10_wins":3,"l10_losses":6}],"GameName":"soccar","Port":26438,"InitTime":1780028923470,"entry_fee":21,"match_id":128,"instance_started":true,"rc_prize":34,"your_team":"blue"}} +[5/29/2026 9:58:44 AM] Configured dedicated match reporting for match id 128 with secret 38516e39d3406225b7c3015a66e5d25c54e9b2024c0755212122bdcea3e3a328 and internal api base https://kickkingsapi.playpoolstudios.com +[5/29/2026 9:58:44 AM] Setting cupid to load game scene +[5/29/2026 9:58:44 AM] Loading game scene +[5/29/2026 9:58:48 AM] Starting client at $kickkingsapi.playpoolstudios.com:26438 +[5/29/2026 9:58:48 AM] Client connected +[5/29/2026 9:58:55 AM] Selected team changed from Red to Blue +[5/29/2026 9:58:58 AM] Score changed from 0 to 1 +[5/29/2026 9:59:01 AM] Selected team changed from Blue to Red +[5/29/2026 9:59:07 AM] Selected team changed from Red to Blue +[5/29/2026 9:59:09 AM] Score changed from 1 to 2 +[5/29/2026 9:59:12 AM] Selected team changed from Blue to Red +[5/29/2026 9:59:15 AM] Selected team changed from Red to Blue +[5/29/2026 9:59:17 AM] Score changed from 2 to 3 +[5/29/2026 9:59:29 AM] Configured dedicated match reporting for match id 129 with secret 38516e39d3406225b7c3015a66e5d25c54e9b2024c0755212122bdcea3e3a328 and internal api base https://kickkingsapi.playpoolstudios.com +[5/29/2026 9:59:29 AM] Client disconnected +[5/29/2026 9:59:33 AM] Starting client at $kickkingsapi.playpoolstudios.com:26658 +[5/29/2026 9:59:34 AM] Client connected +[5/29/2026 9:59:54 AM] Client disconnected diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 142fd644..7d033445 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -623,7 +623,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &23164711 RectTransform: m_ObjectHideFlags: 0 @@ -690,9 +690,9 @@ CanvasGroup: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 23164710} m_Enabled: 1 - m_Alpha: 1 - m_Interactable: 1 - m_BlocksRaycasts: 1 + m_Alpha: 0 + m_Interactable: 0 + m_BlocksRaycasts: 0 m_IgnoreParentGroups: 0 --- !u!1 &30708564 GameObject: @@ -4339,7 +4339,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: afcc176abfdaa9945bc300d4ecfa0e71, type: 3} + m_Sprite: {fileID: 21300000, guid: 7b4541dccf68a5a479d7bc41c620fae2, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -4554,7 +4554,7 @@ MonoBehaviour: preview: 0 isPlaying: 1 loop: 1 - currentFrame: 171 + currentFrame: 89 --- !u!1 &239916595 GameObject: m_ObjectHideFlags: 0 @@ -14797,8 +14797,8 @@ RectTransform: m_Children: [] m_Father: {fileID: 1197229754} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.34615386, y: 0} - m_AnchorMax: {x: 0.34615386, y: 1} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 56.37, y: 0} m_Pivot: {x: 0.5, y: 0.5} @@ -18232,7 +18232,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1506964489 RectTransform: m_ObjectHideFlags: 0 @@ -20895,6 +20895,7 @@ MonoBehaviour: - {fileID: 81707918} - {fileID: 945131285} - {fileID: 1744675599} + - {fileID: 1506964489} p1_name: {fileID: 60724007} p1_l10: {fileID: 1994269188} p2_name: {fileID: 1155938936} @@ -20917,6 +20918,7 @@ MonoBehaviour: txtRewardCC: {fileID: 30708566} countdownTxt: {fileID: 2054440054} returnToMenuCountdown: 25 + txtRcBalance: {fileID: 420458116} txtBetLimitWarning: {fileID: 1506964490} betLimitAdjustPanel: {fileID: 1207271335} betLimitSlider: {fileID: 1932867096} @@ -21314,7 +21316,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1744675599 RectTransform: m_ObjectHideFlags: 0 @@ -24908,7 +24910,7 @@ RectTransform: m_Father: {fileID: 496416183} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0.34615386, y: 1} + m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 10, y: 0} m_Pivot: {x: 0.5, y: 0.5} diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 94b4abb1..81541d79 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -808,8 +808,37 @@ public class GameManager : NetworkBehaviour // LevelLoadManager.LoadLevel("MainMenu"); } - + bool _thirdPlayerLeaveTriggered; + /// + /// Called when the local client spawns into a match. If three instances exist + /// (matchmaker sent an extra client into a full room), disconnect and return to the main menu. + /// + public void OnLocalPlayerJoinedMatch() + { + if (!isClient || _thirdPlayerLeaveTriggered) + return; + StartCoroutine(CoLeaveIfThirdPlayer()); + } + + IEnumerator CoLeaveIfThirdPlayer() + { + const int maxFrames = 30; + for (int i = 0; i < maxFrames; i++) + { + yield return null; + if (FindObjectsByType(FindObjectsSortMode.None).Length >= 3) + { + _thirdPlayerLeaveTriggered = true; + Logger.Log("Third player in a 2-player match (matchmaker bug); leaving to main menu."); + if (LevelLoadManager.instance != null) + LevelLoadManager.instance.Leave(); + else + LevelLoadManager.LoadLevel("MainMenu"); + yield break; + } + } + } public void StopClient(){ try{ diff --git a/Assets/Scripts/GameOverCanvas.cs b/Assets/Scripts/GameOverCanvas.cs index 3470bbb5..32e7e029 100644 --- a/Assets/Scripts/GameOverCanvas.cs +++ b/Assets/Scripts/GameOverCanvas.cs @@ -46,6 +46,7 @@ public class GameOverCanvas : MonoBehaviour const int MinimumRematchRcCoins = 20; [Header("Bet Limit")] + public TMP_Text txtRcBalance; public TMP_Text txtBetLimitWarning; public CanvasGroup betLimitAdjustPanel; //minVal: 2, max Val 500, when its 500, show ∞ on the text @@ -59,6 +60,8 @@ public class GameOverCanvas : MonoBehaviour const int BetLimitMax = 500; const int BetLimitUnlimited = 500; + int rematchOpponentBetLimitCoins = BetLimitUnlimited; + [Header("Rematch panel")] public CanvasGroup rematchPanel; public RectTransform rematchPopup; @@ -130,6 +133,38 @@ public class GameOverCanvas : MonoBehaviour return PlayerPrefs.GetInt(PersonalBetLimitPrefsKey, BetLimitUnlimited); } + static int EffectiveBetLimitCap(int limitCoins) => + limitCoins >= BetLimitUnlimited ? int.MaxValue : limitCoins; + + int GetRematchMaxBetCoins() + { + int maxBet = Mathf.Min( + EffectiveBetLimitCap(rematchOpponentBetLimitCoins), + GetRcCoins(LevelLoadManager.myPlayer), + GetRcCoins(LevelLoadManager.opponentPlayer)); + return Mathf.Max(0, maxBet); + } + + void ApplyRematchBetSliderLimits() + { + if (betSlider == null) + return; + + int maxBet = GetRematchMaxBetCoins(); + betSlider.maxValue = maxBet; + if (maxBet <= 0) + { + betSlider.minValue = 0; + betSlider.value = 0; + } + else + { + betSlider.minValue = Mathf.Clamp(maxBet / 10f, 5, 10000); + betSlider.value = Mathf.Clamp(maxBet / 2, betSlider.minValue, maxBet); + } + OnBetSliderValueChanged(betSlider.value); + } + static void SetPersonalBetLimit(int limitCoins) { limitCoins = Mathf.Clamp(limitCoins, BetLimitMin, BetLimitMax); @@ -221,13 +256,16 @@ public class GameOverCanvas : MonoBehaviour void OnBtnRematchClicked(){ if (!BothPlayersHaveMinimumRematchRc()) return; + if (txtBetLimitWarning != null) + txtBetLimitWarning.gameObject.SetActive(false); NetPlayer.localPlayer.RequestRematch(); SetRematchPendingState(true); } - public void OnRematchRequested(){ + public void OnRematchRequested(int opponentMaxBetLimitCoins){ + rematchOpponentBetLimitCoins = opponentMaxBetLimitCoins; if(winningTeam == myTeam){ - //Only i can initiate the rematch, so here we go + //Only the loser can initiate the rematch; winner sets the stake ShowRematchPanel(); }else{ rematchWarningLoser.text = "Waiting for opponent to accept"; @@ -378,6 +416,7 @@ public class GameOverCanvas : MonoBehaviour } UpdateRematchAvailability(); + ApplyRcBalancesToUi(null); StartCoroutine(CoroutineShow()); @@ -461,11 +500,8 @@ public class GameOverCanvas : MonoBehaviour public void ShowRematchPanel(){ SetRematchPendingState(true); + ApplyRematchBetSliderLimits(); StartCoroutine(CoroutineShowRematchPanel()); - - betSlider.maxValue = (LevelLoadManager.myPlayer.rc < LevelLoadManager.opponentPlayer.rc) ? LevelLoadManager.myPlayer.rc : LevelLoadManager.opponentPlayer.rc; - betSlider.value = betSlider.maxValue / 2; - betSlider.minValue = Mathf.Clamp(betSlider.maxValue /10f,5,10000); } IEnumerator CoroutineShowRematchPanel(){ @@ -528,9 +564,15 @@ public class GameOverCanvas : MonoBehaviour txtMyRCBalance.text = myText; if (txtOpponentRCBalance != null) txtOpponentRCBalance.text = oppText; + if (txtRcBalance != null) + txtRcBalance.text = loadingPlaceholder ?? (my != null ? CoinHelper.FormatString((int)my.rc) + " RC" : "0.0 RC"); if (loadingPlaceholder == null) + { UpdateRematchAvailability(); + if (rematchPanel != null && rematchPanel.alpha > 0.01f) + ApplyRematchBetSliderLimits(); + } } static int GetRcCoins(MatchmadePlayer player) => diff --git a/Assets/Scripts/NetPlayer.cs b/Assets/Scripts/NetPlayer.cs index f0001f3f..68346bc5 100644 --- a/Assets/Scripts/NetPlayer.cs +++ b/Assets/Scripts/NetPlayer.cs @@ -36,6 +36,9 @@ public class NetPlayer : NetworkBehaviour SetMyData(GameManager.MyTeam == Team.Red ? GameManager.RedPlayer.UserId : GameManager.BluePlayer.UserId); #endif TeamSpecificEffects.instance.SetTeamSpecificEffects(myTeam); + + if (GameManager.instance != null) + GameManager.instance.OnLocalPlayerJoinedMatch(); } void SetMyData(int uid){ @@ -419,29 +422,30 @@ public class NetPlayer : NetworkBehaviour /// Request a rematch with the opponent. /// public void RequestRematch(){ + int maxBetLimitCoins = GameOverCanvas.GetPersonalBetLimit(); if(isServer){ - GameOverCanvas.instance.OnRematchRequested(); - RpcRequestRematch(); + GameOverCanvas.instance.OnRematchRequested(maxBetLimitCoins); + RpcRequestRematch(maxBetLimitCoins); }else{ - CmdRequestRematch(); + CmdRequestRematch(maxBetLimitCoins); } } [Command] - void CmdRequestRematch(){ - Logger.Log("Rematch requested"); + void CmdRequestRematch(int maxBetLimitCoins){ + Logger.Log("Rematch requested, max bet limit coins: " + maxBetLimitCoins); if(isServerOnly){ //server }else{ - GameOverCanvas.instance.OnRematchRequested(); + GameOverCanvas.instance.OnRematchRequested(maxBetLimitCoins); } - RpcRequestRematch(); + RpcRequestRematch(maxBetLimitCoins); } [ClientRpc] - void RpcRequestRematch(){ - GameOverCanvas.instance.OnRematchRequested(); + void RpcRequestRematch(int maxBetLimitCoins){ + GameOverCanvas.instance.OnRematchRequested(maxBetLimitCoins); } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index f66d6526..9458cfad 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -141,7 +141,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 1.16 + bundleVersion: 1.18 preloadedAssets: - {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3} metroInputSource: 0