From 73db75d40a3da8615e911833e00f6bcc6f3924cc Mon Sep 17 00:00:00 2001 From: Jesus Castro Date: Fri, 19 Dec 2025 15:55:13 +0800 Subject: [PATCH] Update BombService - L and T shapes will be considered as 4+ --- Assets/Scripts/Services/BombService.cs | 24 ++++++++++++++++--- .../Services/Interfaces/IMatchService.cs | 4 +++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Services/BombService.cs b/Assets/Scripts/Services/BombService.cs index 502a479..6b0d32d 100644 --- a/Assets/Scripts/Services/BombService.cs +++ b/Assets/Scripts/Services/BombService.cs @@ -83,9 +83,9 @@ namespace Services if (currentMatches == null || !currentMatches.Contains(pivotGem)) return; - // Only create a bomb if the pivot is part of a straight 4+ line of the SAME color. - int longestLine = GetLongestMatchedLineThroughPivot(pivot, pivotGem.MatchColor); - if (longestLine < 4) + // Create a bomb if it's a 4+ line OR an L/T shape (both horizontal and vertical >= 3) + bool isEligibleForBomb = IsEligibleForBomb(pivot, pivotGem.MatchColor); + if (!isEligibleForBomb) return; // Prevent duplicates for the same cell. @@ -94,6 +94,24 @@ namespace Services this.pendingBombSpawn = new BombSpawnRequest(pivot, pivotGem.MatchColor); } + + private bool IsEligibleForBomb(Vector2Int pivot, GemType color) { + int horizontal = 1 + CountSameColorInDirection(pivot, Vector2Int.left, color) + + CountSameColorInDirection(pivot, Vector2Int.right, color); + + int vertical = 1 + CountSameColorInDirection(pivot, Vector2Int.up, color) + + CountSameColorInDirection(pivot, Vector2Int.down, color); + + // Straight line of 4 or more + if (horizontal >= 4 || vertical >= 4) + return true; + + // L or T shape: both directions have at least a 3-match intersecting at this pivot + if (horizontal >= 3 && vertical >= 3) + return true; + + return false; + } public async UniTask DetonateChainAsync( IReadOnlyList initialBombs, diff --git a/Assets/Scripts/Services/Interfaces/IMatchService.cs b/Assets/Scripts/Services/Interfaces/IMatchService.cs index 7074839..70f1a05 100644 --- a/Assets/Scripts/Services/Interfaces/IMatchService.cs +++ b/Assets/Scripts/Services/Interfaces/IMatchService.cs @@ -24,7 +24,9 @@ namespace Services.Interfaces { /// /// Type of gem to check. /// - /// + /// + /// True if there are matches, false otherwise. + /// bool MatchesAt(Vector2Int positionToCheck, GemType gemTypeToCheck); void FindAllMatches(); }