diff --git a/src/include/Tetris.h b/src/include/Tetris.h index 73c62e8..3f32e80 100644 --- a/src/include/Tetris.h +++ b/src/include/Tetris.h @@ -54,6 +54,8 @@ struct PlayerStats int sweeperLevel; int sweeperCharge; int explosiveLevel; + int chainBlastLevel; + int chainBombLevel; int stableStructureLevel; int doubleGrowthLevel; int gamblerLevel; diff --git a/src/source/TetrisLogic.cpp b/src/source/TetrisLogic.cpp index dd08783..e0f1bc2 100644 --- a/src/source/TetrisLogic.cpp +++ b/src/source/TetrisLogic.cpp @@ -23,6 +23,8 @@ int nextTypes[3] = { 0, 0, 0 }; int holdType = -1; bool holdUsedThisTurn = false; bool currentPieceIsExplosive = false; +Point pendingChainBombCenter = { 0, 0 }; +bool pendingChainBombFollowup = false; enum UpgradeId { @@ -39,7 +41,9 @@ enum UpgradeId UPGRADE_STABLE_STRUCTURE = 10, UPGRADE_DOUBLE_GROWTH = 11, UPGRADE_PIECE_TUNING = 12, - UPGRADE_GAMBLER = 13 + UPGRADE_GAMBLER = 13, + UPGRADE_CHAIN_BLAST = 14, + UPGRADE_CHAIN_BOMB = 15 }; static const UpgradeEntry kUpgradePool[] = @@ -54,6 +58,8 @@ static const UpgradeEntry kUpgradePool[] = { UPGRADE_PRESSURE_RELIEF, -1, true, _T("\u51cf\u538b"), _T("\u7279\u6b8a"), _T("\u7acb\u5373\u6e05\u9664\u5f53\u524d\u6700\u9ad8\u5360\u7528\u884c\uff0c\u4e3a\u76d8\u9762\u817e\u51fa\u547c\u5438\u7a7a\u95f4\u3002") }, { UPGRADE_SWEEPER, -1, true, _T("\u6e05\u626b\u8005"), _T("\u7279\u6b8a"), _T("\u7d2f\u8ba1\u6d88\u884c\u5145\u80fd\uff0c\u6536\u6ee1\u540e\u81ea\u52a8\u6e05\u9664\u5e95\u90e8 1 \u884c\u3002") }, { UPGRADE_EXPLOSIVE_PIECE, -1, true, _T("\u7206\u7834\u65b9\u5757"), _T("\u7279\u6b8a"), _T("\u63d0\u9ad8\u7206\u7834\u65b9\u5757\u51fa\u73b0\u6982\u7387\uff0c\u843d\u5730\u65f6\u89e6\u53d1 3x3 \u6e05\u9664\u3002") }, + { UPGRADE_CHAIN_BLAST, 1, false, _T("\u8fde\u9501\u7206\u7834"), _T("\u8fdb\u9636"), _T("\u6d88\u884c\u540e\u5bf9\u88ab\u6e05\u9664\u884c\u9644\u8fd1\u968f\u673a\u6e05\u6389\u51e0\u683c\u3002") }, + { UPGRADE_CHAIN_BOMB, 1, false, _T("\u8fde\u73af\u70b8\u5f39"), _T("\u8fdb\u5316"), _T("\u7206\u7834\u8303\u56f4\u63d0\u5347\u4e3a 5x5\uff0c\u82e5\u5f15\u53d1\u6d88\u884c\u5219\u8ffd\u52a0\u4e00\u6b21\u5c0f\u7206\u70b8\u3002") }, { UPGRADE_STABLE_STRUCTURE, -1, true, _T("\u7a33\u5b9a\u7ed3\u6784"), _T("\u7279\u6b8a"), _T("\u843d\u5730\u540e\u5c0f\u6982\u7387\u81ea\u52a8\u586b\u8865\u90bb\u8fd1\u7a7a\u6d1e\uff0c\u63d0\u9ad8\u76d8\u9762\u7ed3\u6784\u7a33\u5b9a\u6027\u3002") }, { UPGRADE_DOUBLE_GROWTH, -1, true, _T("\u53cc\u500d\u6210\u957f"), _T("\u7279\u6b8a"), _T("\u989d\u5916\u63d0\u9ad8\u6d88\u884c\u5f97\u5206\u4e0e EXP \u6536\u76ca\uff0c\u6bcf\u5c42\u518d\u8ffd\u52a0 15%\u3002") }, { UPGRADE_PIECE_TUNING, -1, true, _T("\u65b9\u5757\u6539\u9020"), _T("\u7279\u6b8a"), _T("\u9009\u62e9\u4e00\u79cd\u65b9\u5757\uff0c\u964d\u4f4e\u5176\u540e\u7eed\u51fa\u73b0\u6982\u7387\u3002") }, @@ -213,6 +219,8 @@ static void ResetPlayerStats(PlayerStats& stats, bool useRogueRules) stats.sweeperLevel = 0; stats.sweeperCharge = 0; stats.explosiveLevel = 0; + stats.chainBlastLevel = 0; + stats.chainBombLevel = 0; stats.stableStructureLevel = 0; stats.doubleGrowthLevel = 0; stats.gamblerLevel = 0; @@ -266,6 +274,10 @@ static int GetUpgradeCurrentLevel(int upgradeId) return rogueStats.sweeperLevel; case UPGRADE_EXPLOSIVE_PIECE: return rogueStats.explosiveLevel; + case UPGRADE_CHAIN_BLAST: + return rogueStats.chainBlastLevel; + case UPGRADE_CHAIN_BOMB: + return rogueStats.chainBombLevel; case UPGRADE_STABLE_STRUCTURE: return rogueStats.stableStructureLevel; case UPGRADE_DOUBLE_GROWTH: @@ -300,6 +312,16 @@ static const TCHAR* GetPieceShortName(int pieceType) static bool IsUpgradeSelectable(const UpgradeEntry& entry) { + if (entry.id == UPGRADE_CHAIN_BLAST) + { + return rogueStats.explosiveLevel > 0 && rogueStats.chainBlastLevel == 0; + } + + if (entry.id == UPGRADE_CHAIN_BOMB) + { + return rogueStats.explosiveLevel > 0 && rogueStats.chainBlastLevel > 0 && rogueStats.chainBombLevel == 0; + } + if (entry.repeatable) { return true; @@ -390,11 +412,12 @@ static bool RollExplosivePiece() static int ClearExplosiveAreaAt(int centerY, int centerX) { + int radius = (currentMode == MODE_ROGUE && rogueStats.chainBombLevel > 0) ? 2 : 1; int clearedCellCount = 0; - for (int y = centerY - 1; y <= centerY + 1; y++) + for (int y = centerY - radius; y <= centerY + radius; y++) { - for (int x = centerX - 1; x <= centerX + 1; x++) + for (int x = centerX - radius; x <= centerX + radius; x++) { if (y >= 0 && y < nGameHeight && x >= 0 && x < nGameWidth) { @@ -410,6 +433,40 @@ static int ClearExplosiveAreaAt(int centerY, int centerX) return clearedCellCount; } +static int TriggerChainBlast(int lineAnchor) +{ + if (currentMode != MODE_ROGUE || rogueStats.chainBlastLevel <= 0) + { + return 0; + } + + int clearedCellCount = 0; + int blastCount = 2 + rogueStats.chainBlastLevel; + + for (int blastIndex = 0; blastIndex < blastCount; blastIndex++) + { + int randomY = lineAnchor + (rand() % 3) - 1; + int randomX = rand() % nGameWidth; + + if (randomY < 0) + { + randomY = 0; + } + if (randomY >= nGameHeight) + { + randomY = nGameHeight - 1; + } + + if (workRegion[randomY][randomX] != 0) + { + workRegion[randomY][randomX] = 0; + clearedCellCount++; + } + } + + return clearedCellCount; +} + static int RollNextPieceType() { int weights[7] = { 100, 100, 100, 100, 100, 100, 100 }; @@ -682,6 +739,12 @@ static void ApplyUpgradeById(int upgradeId, int targetPieceType, int applyCount) case UPGRADE_EXPLOSIVE_PIECE: rogueStats.explosiveLevel += applyCount; break; + case UPGRADE_CHAIN_BLAST: + rogueStats.chainBlastLevel = 1; + break; + case UPGRADE_CHAIN_BOMB: + rogueStats.chainBombLevel = 1; + break; case UPGRADE_STABLE_STRUCTURE: rogueStats.stableStructureLevel += applyCount; break; @@ -758,6 +821,34 @@ static void ApplyLineClearResult(int linesCleared) rogueStats.score += scoreGain; rogueStats.exp += expGain; + if (rogueStats.chainBlastLevel > 0) + { + int chainBlastCells = 0; + for (int i = 0; i < linesCleared; i++) + { + chainBlastCells += TriggerChainBlast(nGameHeight - 1 - i); + } + + if (chainBlastCells > 0) + { + int chainBlastScore = chainBlastCells * rogueStats.scoreMultiplierPercent / 100; + if (chainBlastScore < chainBlastCells) + { + chainBlastScore = chainBlastCells; + } + rogueStats.score += chainBlastScore; + tScore = rogueStats.score; + + TCHAR blastDetail[128]; + _stprintf_s( + blastDetail, + _T("\u989d\u5916\u6e05\u9664 %d \u683c +%d Score"), + chainBlastCells, + chainBlastScore); + SetFeedbackMessage(_T("\u8fde\u9501\u7206\u7834\u89e6\u53d1"), blastDetail, 12); + } + } + if (rogueStats.sweeperLevel > 0) { rogueStats.sweeperCharge += linesCleared; @@ -1048,6 +1139,7 @@ void Fixing() bool overflowTop = false; Point explosiveCells[4] = {}; int explosiveCellCount = 0; + pendingChainBombFollowup = false; for (int i = 0; i < 4; i++) { @@ -1125,6 +1217,12 @@ void Fixing() explosiveScoreGain > 0 ? explosiveScoreGain * 100 / rogueStats.scoreMultiplierPercent : 0, explosiveScoreGain); SetFeedbackMessage(_T("\u7206\u7834\u65b9\u5757\u89e6\u53d1"), explosiveDetail, 12); + + if (rogueStats.chainBombLevel > 0 && explosiveCellCount > 0) + { + pendingChainBombCenter = explosiveCells[0]; + pendingChainBombFollowup = true; + } } if (TryStabilizeBoard() > 0) @@ -1202,6 +1300,51 @@ int DeleteLines() } ApplyLineClearResult(clearedLines); + + if (pendingChainBombFollowup && clearedLines > 0) + { + pendingChainBombFollowup = false; + + int followupCleared = 0; + int centerY = pendingChainBombCenter.y; + int centerX = pendingChainBombCenter.x; + + for (int y = centerY - 1; y <= centerY + 1; y++) + { + for (int x = centerX - 1; x <= centerX + 1; x++) + { + if (y >= 0 && y < nGameHeight && x >= 0 && x < nGameWidth && workRegion[y][x] != 0) + { + workRegion[y][x] = 0; + followupCleared++; + } + } + } + + if (currentMode == MODE_ROGUE && followupCleared > 0) + { + int followupScore = followupCleared * rogueStats.scoreMultiplierPercent / 100; + if (followupScore < followupCleared) + { + followupScore = followupCleared; + } + rogueStats.score += followupScore; + tScore = rogueStats.score; + + TCHAR followupDetail[128]; + _stprintf_s( + followupDetail, + _T("\u8ffd\u52a0\u5c0f\u7206\u70b8\u6e05\u9664 %d \u683c +%d Score"), + followupCleared, + followupScore); + SetFeedbackMessage(_T("\u8fde\u73af\u70b8\u5f39\u89e6\u53d1"), followupDetail, 12); + } + } + else + { + pendingChainBombFollowup = false; + } + return clearedLines; } diff --git a/src/source/TetrisRender.cpp b/src/source/TetrisRender.cpp index 7a8701d..dcdd6ee 100644 --- a/src/source/TetrisRender.cpp +++ b/src/source/TetrisRender.cpp @@ -362,7 +362,7 @@ void TDrawScreen(HDC hdc, HWND hWnd) hdc, _T("\u7ecf\u5178\u6a21\u5f0f\uff1a\u4fdd\u6301\u539f\u7248\u4fc4\u7f57\u65af\u65b9\u5757\u73a9\u6cd5\uff0c\u4ee5\u6d88\u884c\u548c\u751f\u5b58\u4e3a\u4e3b\u3002\r\n\r\n") _T("Rogue \u6a21\u5f0f\uff1a\u6d88\u884c\u540e\u9664\u4e86\u83b7\u5f97\u5206\u6570\uff0c\u8fd8\u4f1a\u83b7\u5f97 EXP\u3002EXP \u8fbe\u5230\u9608\u503c\u540e\u89e6\u53d1\u5347\u7ea7\uff0c\u4ece\u4e09\u4e2a\u5f3a\u5316\u4e2d\u9009\u4e00\u4e2a\u3002\r\n\r\n") - _T("\u5f53\u524d\u5df2\u63a5\u5165\uff1a\u5206\u6570\u500d\u7387\u3001EXP \u500d\u7387\u3001\u6162\u901f\u4e0b\u843d\u3001Hold \u89e3\u9501\u3001\u51cf\u538b\u3001\u6e05\u626b\u8005\u3001\u7206\u7834\u65b9\u5757\u3001\u7a33\u5b9a\u7ed3\u6784\u3001\u53cc\u500d\u6210\u957f\u3001\u65b9\u5757\u6539\u9020\u3001\u8d4c\u5f92\u3002\r\n\r\n") + _T("\u5f53\u524d\u5df2\u63a5\u5165\uff1a\u7206\u7834\u65b9\u5757\u3001\u8fde\u9501\u7206\u7834\u3001\u8fde\u73af\u70b8\u5f39\u53ca\u591a\u79cd Rogue \u7279\u6b8a\u5f3a\u5316\u3002\r\n\r\n") _T("\u63d0\u793a\uff1a\u6682\u505c\u3001\u5931\u8d25\u548c\u5347\u7ea7\u4f1a\u8fdb\u5165\u4e0d\u540c\u754c\u9762\uff0c\u8bf7\u6839\u636e\u5c4f\u5e55\u63d0\u793a\u64cd\u4f5c\u3002"), -1, &rulesBody, @@ -692,6 +692,16 @@ void TDrawScreen(HDC hdc, HWND hWnd) TextOut(hdc, combatRect.left + SS(18), combatRect.top + SS(146), explosiveText, lstrlen(explosiveText)); } + if (rogueStats.chainBlastLevel > 0) + { + TextOut(hdc, combatRect.left + SS(18), combatRect.top + SS(274), _T("\u8fde\u9501\u7206\u7834 \u5df2\u89e3\u9501"), lstrlen(_T("\u8fde\u9501\u7206\u7834 \u5df2\u89e3\u9501"))); + } + + if (rogueStats.chainBombLevel > 0) + { + TextOut(hdc, combatRect.left + SS(18), combatRect.top + SS(306), _T("\u8fde\u73af\u70b8\u5f39 5x5 + \u4e8c\u6b21\u7206\u70b8"), lstrlen(_T("\u8fde\u73af\u70b8\u5f39 5x5 + \u4e8c\u6b21\u7206\u70b8"))); + } + if (rogueStats.doubleGrowthLevel > 0) { TCHAR growthText[96]; @@ -788,6 +798,14 @@ void TDrawScreen(HDC hdc, HWND hWnd) { _stprintf_s(upgradeSummary + lstrlen(upgradeSummary), 512 - lstrlen(upgradeSummary), _T("\u7206\u7834\u65b9\u5757 Lv.%d\r\n"), rogueStats.explosiveLevel); } + if (rogueStats.chainBlastLevel > 0) + { + _stprintf_s(upgradeSummary + lstrlen(upgradeSummary), 512 - lstrlen(upgradeSummary), _T("\u8fde\u9501\u7206\u7834 Lv.1\r\n")); + } + if (rogueStats.chainBombLevel > 0) + { + _stprintf_s(upgradeSummary + lstrlen(upgradeSummary), 512 - lstrlen(upgradeSummary), _T("\u8fde\u73af\u70b8\u5f39 Lv.1\r\n")); + } if (rogueStats.stableStructureLevel > 0) { _stprintf_s(upgradeSummary + lstrlen(upgradeSummary), 512 - lstrlen(upgradeSummary), _T("\u7a33\u5b9a\u7ed3\u6784 Lv.%d\r\n"), rogueStats.stableStructureLevel);