diff --git a/src/include/Tetris.h b/src/include/Tetris.h index 3f32e80..11b31b0 100644 --- a/src/include/Tetris.h +++ b/src/include/Tetris.h @@ -56,6 +56,9 @@ struct PlayerStats int explosiveLevel; int chainBlastLevel; int chainBombLevel; + int laserLevel; + int thunderTetrisLevel; + int thunderLaserLevel; int stableStructureLevel; int doubleGrowthLevel; int gamblerLevel; @@ -134,6 +137,7 @@ extern int nextTypes[3]; extern int holdType; extern bool holdUsedThisTurn; extern bool currentPieceIsExplosive; +extern bool currentPieceIsLaser; extern int bricks[7][4][4][4]; extern COLORREF BrickColor[7]; diff --git a/src/source/TetrisLogic.cpp b/src/source/TetrisLogic.cpp index e0f1bc2..dfdb6f8 100644 --- a/src/source/TetrisLogic.cpp +++ b/src/source/TetrisLogic.cpp @@ -23,6 +23,7 @@ int nextTypes[3] = { 0, 0, 0 }; int holdType = -1; bool holdUsedThisTurn = false; bool currentPieceIsExplosive = false; +bool currentPieceIsLaser = false; Point pendingChainBombCenter = { 0, 0 }; bool pendingChainBombFollowup = false; @@ -43,7 +44,10 @@ enum UpgradeId UPGRADE_PIECE_TUNING = 12, UPGRADE_GAMBLER = 13, UPGRADE_CHAIN_BLAST = 14, - UPGRADE_CHAIN_BOMB = 15 + UPGRADE_CHAIN_BOMB = 15, + UPGRADE_LASER_PIECE = 16, + UPGRADE_THUNDER_TETRIS = 17, + UPGRADE_THUNDER_LASER = 18 }; static const UpgradeEntry kUpgradePool[] = @@ -60,6 +64,9 @@ static const UpgradeEntry kUpgradePool[] = { 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_LASER_PIECE, -1, true, _T("\u6fc0\u5149\u65b9\u5757"), _T("\u7279\u6b8a"), _T("\u63d0\u9ad8\u6fc0\u5149\u65b9\u5757\u51fa\u73b0\u6982\u7387\uff0c\u843d\u5730\u540e\u6e05\u9664\u6240\u5728\u6574\u5217\u3002") }, + { UPGRADE_THUNDER_TETRIS, 1, false, _T("\u96f7\u9706\u56db\u6d88"), _T("\u8fdb\u9636"), _T("\u6bcf\u6b21\u5b8c\u6210\u56db\u6d88\u65f6\uff0c\u989d\u5916\u6e05\u9664\u968f\u673a 2 \u884c\u3002") }, + { UPGRADE_THUNDER_LASER, 1, false, _T("\u96f7\u9706\u6fc0\u5149"), _T("\u8fdb\u5316"), _T("\u56db\u6d88\u65f6\u989d\u5916\u53d1\u5c04 2 \u9053\u6fc0\u5149\uff0c\u968f\u673a\u6e05\u9664 2 \u5217\u5e76\u83b7\u5f97 EXP\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") }, @@ -221,6 +228,9 @@ static void ResetPlayerStats(PlayerStats& stats, bool useRogueRules) stats.explosiveLevel = 0; stats.chainBlastLevel = 0; stats.chainBombLevel = 0; + stats.laserLevel = 0; + stats.thunderTetrisLevel = 0; + stats.thunderLaserLevel = 0; stats.stableStructureLevel = 0; stats.doubleGrowthLevel = 0; stats.gamblerLevel = 0; @@ -278,6 +288,12 @@ static int GetUpgradeCurrentLevel(int upgradeId) return rogueStats.chainBlastLevel; case UPGRADE_CHAIN_BOMB: return rogueStats.chainBombLevel; + case UPGRADE_LASER_PIECE: + return rogueStats.laserLevel; + case UPGRADE_THUNDER_TETRIS: + return rogueStats.thunderTetrisLevel; + case UPGRADE_THUNDER_LASER: + return rogueStats.thunderLaserLevel; case UPGRADE_STABLE_STRUCTURE: return rogueStats.stableStructureLevel; case UPGRADE_DOUBLE_GROWTH: @@ -322,6 +338,16 @@ static bool IsUpgradeSelectable(const UpgradeEntry& entry) return rogueStats.explosiveLevel > 0 && rogueStats.chainBlastLevel > 0 && rogueStats.chainBombLevel == 0; } + if (entry.id == UPGRADE_THUNDER_TETRIS) + { + return rogueStats.laserLevel > 0 && rogueStats.thunderTetrisLevel == 0; + } + + if (entry.id == UPGRADE_THUNDER_LASER) + { + return rogueStats.laserLevel > 0 && rogueStats.thunderTetrisLevel > 0 && rogueStats.thunderLaserLevel == 0; + } + if (entry.repeatable) { return true; @@ -410,6 +436,22 @@ static bool RollExplosivePiece() return (rand() % 100) < chancePercent; } +static bool RollLaserPiece() +{ + if (currentMode != MODE_ROGUE || rogueStats.laserLevel <= 0) + { + return false; + } + + int chancePercent = 10 + (rogueStats.laserLevel - 1) * 8; + if (chancePercent > 35) + { + chancePercent = 35; + } + + return (rand() % 100) < chancePercent; +} + static int ClearExplosiveAreaAt(int centerY, int centerX) { int radius = (currentMode == MODE_ROGUE && rogueStats.chainBombLevel > 0) ? 2 : 1; @@ -433,6 +475,27 @@ static int ClearExplosiveAreaAt(int centerY, int centerX) return clearedCellCount; } +static int ClearColumnAt(int column) +{ + int clearedCellCount = 0; + + if (column < 0 || column >= nGameWidth) + { + return 0; + } + + for (int y = 0; y < nGameHeight; y++) + { + if (workRegion[y][column] != 0) + { + workRegion[y][column] = 0; + clearedCellCount++; + } + } + + return clearedCellCount; +} + static int TriggerChainBlast(int lineAnchor) { if (currentMode != MODE_ROGUE || rogueStats.chainBlastLevel <= 0) @@ -745,6 +808,15 @@ static void ApplyUpgradeById(int upgradeId, int targetPieceType, int applyCount) case UPGRADE_CHAIN_BOMB: rogueStats.chainBombLevel = 1; break; + case UPGRADE_LASER_PIECE: + rogueStats.laserLevel += applyCount; + break; + case UPGRADE_THUNDER_TETRIS: + rogueStats.thunderTetrisLevel = 1; + break; + case UPGRADE_THUNDER_LASER: + rogueStats.thunderLaserLevel = 1; + break; case UPGRADE_STABLE_STRUCTURE: rogueStats.stableStructureLevel += applyCount; break; @@ -849,6 +921,71 @@ static void ApplyLineClearResult(int linesCleared) } } + if (linesCleared == 4 && rogueStats.thunderTetrisLevel > 0) + { + int thunderRowsCleared = 0; + for (int i = 0; i < 2; i++) + { + int randomRow = rand() % nGameHeight; + for (int x = 0; x < nGameWidth; x++) + { + if (workRegion[randomRow][x] != 0) + { + workRegion[randomRow][x] = 0; + thunderRowsCleared++; + } + } + } + + if (thunderRowsCleared > 0) + { + int thunderScore = thunderRowsCleared * rogueStats.scoreMultiplierPercent / 100; + if (thunderScore < thunderRowsCleared) + { + thunderScore = thunderRowsCleared; + } + rogueStats.score += thunderScore; + tScore = rogueStats.score; + SetFeedbackMessage(_T("\u96f7\u9706\u56db\u6d88\u89e6\u53d1"), _T("\u56db\u6d88\u540e\u989d\u5916\u6e05\u7406\u4e86 2 \u884c\u8303\u56f4\u5185\u7684\u683c\u5b50\u3002"), 12); + } + } + + if (linesCleared == 4 && rogueStats.thunderLaserLevel > 0) + { + int laserCellsCleared = 0; + for (int i = 0; i < 2; i++) + { + laserCellsCleared += ClearColumnAt(rand() % nGameWidth); + } + + if (laserCellsCleared > 0) + { + int laserScore = laserCellsCleared * rogueStats.scoreMultiplierPercent / 100; + int laserExp = laserCellsCleared * rogueStats.expMultiplierPercent / 100; + if (laserScore < laserCellsCleared) + { + laserScore = laserCellsCleared; + } + if (laserExp < laserCellsCleared) + { + laserExp = laserCellsCleared; + } + + rogueStats.score += laserScore; + rogueStats.exp += laserExp; + tScore = rogueStats.score; + + TCHAR thunderLaserDetail[128]; + _stprintf_s( + thunderLaserDetail, + _T("\u968f\u673a\u6fc0\u5149\u6e05\u9664 %d \u683c +%d Score +%d EXP"), + laserCellsCleared, + laserScore, + laserExp); + SetFeedbackMessage(_T("\u96f7\u9706\u6fc0\u5149\u89e6\u53d1"), thunderLaserDetail, 12); + } + } + if (rogueStats.sweeperLevel > 0) { rogueStats.sweeperCharge += linesCleared; @@ -1225,6 +1362,35 @@ void Fixing() } } + if (currentPieceIsLaser) + { + int laserColumn = point.x + 1; + if (laserColumn < 0) + { + laserColumn = 0; + } + if (laserColumn >= nGameWidth) + { + laserColumn = nGameWidth - 1; + } + + int laserCellsCleared = ClearColumnAt(laserColumn); + if (currentMode == MODE_ROGUE && laserCellsCleared > 0) + { + int laserScore = laserCellsCleared * rogueStats.scoreMultiplierPercent / 100; + if (laserScore < laserCellsCleared) + { + laserScore = laserCellsCleared; + } + rogueStats.score += laserScore; + tScore = rogueStats.score; + + TCHAR laserDetail[128]; + _stprintf_s(laserDetail, _T("\u6e05\u9664 %d \u683c +%d Score"), laserCellsCleared, laserScore); + SetFeedbackMessage(_T("\u6fc0\u5149\u65b9\u5757\u89e6\u53d1"), laserDetail, 12); + } + } + if (TryStabilizeBoard() > 0) { SetFeedbackMessage(_T("\u7a33\u5b9a\u7ed3\u6784\u751f\u6548"), _T("\u81ea\u52a8\u586b\u8865\u4e86\u4e00\u4e2a\u90bb\u8fd1\u7a7a\u6d1e\u3002"), 10); @@ -1236,6 +1402,7 @@ void Fixing() state = 0; holdUsedThisTurn = false; currentPieceIsExplosive = RollExplosivePiece(); + currentPieceIsLaser = !currentPieceIsExplosive && RollLaserPiece(); point = GetSpawnPoint(type); target = point; ComputeTarget(); @@ -1408,6 +1575,7 @@ void Restart() holdType = -1; holdUsedThisTurn = false; currentPieceIsExplosive = false; + currentPieceIsLaser = false; tScore = 0; ResetNextQueue(); @@ -1416,6 +1584,7 @@ void Restart() state = 0; holdUsedThisTurn = false; currentPieceIsExplosive = RollExplosivePiece(); + currentPieceIsLaser = !currentPieceIsExplosive && RollLaserPiece(); point = GetSpawnPoint(type); target = point; @@ -1545,11 +1714,13 @@ void HoldCurrentPiece() type = ConsumeNextType(); nType = nextTypes[0]; currentPieceIsExplosive = RollExplosivePiece(); + currentPieceIsLaser = !currentPieceIsExplosive && RollLaserPiece(); } else { type = previousHoldType; currentPieceIsExplosive = false; + currentPieceIsLaser = false; } point = GetSpawnPoint(type); diff --git a/src/source/TetrisRender.cpp b/src/source/TetrisRender.cpp index dcdd6ee..1240b0c 100644 --- a/src/source/TetrisRender.cpp +++ b/src/source/TetrisRender.cpp @@ -529,7 +529,19 @@ void TDrawScreen(HDC hdc, HWND hWnd) }; HBRUSH brickBrush = CreateSolidBrush(BrickColor[type]); - HPEN brickPen = CreatePen(PS_SOLID, currentPieceIsExplosive ? SS(3) : 1, currentPieceIsExplosive ? RGB(255, 214, 82) : RGB(255, 250, 252)); + COLORREF activeOutlineColor = RGB(255, 250, 252); + int activeOutlineWidth = 1; + if (currentPieceIsExplosive) + { + activeOutlineColor = RGB(255, 214, 82); + activeOutlineWidth = SS(3); + } + else if (currentPieceIsLaser) + { + activeOutlineColor = RGB(120, 232, 255); + activeOutlineWidth = SS(3); + } + HPEN brickPen = CreatePen(PS_SOLID, activeOutlineWidth, activeOutlineColor); oldPen = (HPEN)SelectObject(hdc, brickPen); oldBrush = (HBRUSH)SelectObject(hdc, brickBrush); RoundRect(hdc, brickRect.left, brickRect.top, brickRect.right, brickRect.bottom, SS(12), SS(12)); @@ -692,6 +704,28 @@ void TDrawScreen(HDC hdc, HWND hWnd) TextOut(hdc, combatRect.left + SS(18), combatRect.top + SS(146), explosiveText, lstrlen(explosiveText)); } + if (rogueStats.laserLevel > 0) + { + TCHAR laserText[96]; + int laserChance = 10 + (rogueStats.laserLevel - 1) * 8; + if (laserChance > 35) + { + laserChance = 35; + } + _stprintf_s(laserText, _T("\u6fc0\u5149\u6982\u7387 %d%% %s"), laserChance, currentPieceIsLaser ? _T("\u672c\u5757\u5df2\u6fc0\u5149") : _T("\u672c\u5757\u666e\u901a")); + TextOut(hdc, combatRect.left + SS(18), combatRect.top + SS(338), laserText, lstrlen(laserText)); + } + + if (rogueStats.thunderTetrisLevel > 0) + { + TextOut(hdc, combatRect.left + SS(18), combatRect.top + SS(370), _T("\u96f7\u9706\u56db\u6d88 \u56db\u6d88\u52a0\u6e05 2 \u884c"), lstrlen(_T("\u96f7\u9706\u56db\u6d88 \u56db\u6d88\u52a0\u6e05 2 \u884c"))); + } + + if (rogueStats.thunderLaserLevel > 0) + { + TextOut(hdc, combatRect.left + SS(18), combatRect.top + SS(402), _T("\u96f7\u9706\u6fc0\u5149 \u56db\u6d88\u52a0\u6fc0\u5149 2 \u5217"), lstrlen(_T("\u96f7\u9706\u6fc0\u5149 \u56db\u6d88\u52a0\u6fc0\u5149 2 \u5217"))); + } + 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"))); @@ -806,6 +840,18 @@ void TDrawScreen(HDC hdc, HWND hWnd) { _stprintf_s(upgradeSummary + lstrlen(upgradeSummary), 512 - lstrlen(upgradeSummary), _T("\u8fde\u73af\u70b8\u5f39 Lv.1\r\n")); } + if (rogueStats.laserLevel > 0) + { + _stprintf_s(upgradeSummary + lstrlen(upgradeSummary), 512 - lstrlen(upgradeSummary), _T("\u6fc0\u5149\u65b9\u5757 Lv.%d\r\n"), rogueStats.laserLevel); + } + if (rogueStats.thunderTetrisLevel > 0) + { + _stprintf_s(upgradeSummary + lstrlen(upgradeSummary), 512 - lstrlen(upgradeSummary), _T("\u96f7\u9706\u56db\u6d88 Lv.1\r\n")); + } + if (rogueStats.thunderLaserLevel > 0) + { + _stprintf_s(upgradeSummary + lstrlen(upgradeSummary), 512 - lstrlen(upgradeSummary), _T("\u96f7\u9706\u6fc0\u5149 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);