增加难度上升机制

This commit is contained in:
2026-04-26 09:55:21 +08:00
parent 72df9d474a
commit 30ccac8cbd
5 changed files with 198 additions and 35 deletions
+110 -19
View File
@@ -90,6 +90,10 @@ static const UpgradeEntry kUpgradePool[] =
};
static constexpr int kUpgradePoolSize = sizeof(kUpgradePool) / sizeof(kUpgradePool[0]);
static constexpr int kDifficultyStepMs = 30000;
static constexpr int kDifficultySpeedStepMs = 18;
static constexpr int kMaxRogueLockedRows = 4;
static constexpr int kDifficultyLevelsPerLockedRow = 3;
static int GetUpgradeCurrentLevel(int upgradeId);
static int GetUpgradeDynamicWeight(const UpgradeEntry& entry);
@@ -111,6 +115,7 @@ static int TriggerUpgradeShockwave(int rowsToClear);
static void FillUpgradeOptions();
static void ApplyUpgradeById(int upgradeId, int targetPieceType, int applyCount);
static void ApplyDestinyCurse();
static void ClearLockedRows();
static int GetNextPreviewLimit()
{
@@ -132,6 +137,91 @@ static int GetNextPreviewLimit()
return rogueStats.previewCount;
}
int GetRogueLockedRows()
{
if (currentMode != MODE_ROGUE)
{
return 0;
}
if (rogueStats.lockedRows < 0)
{
return 0;
}
return rogueStats.lockedRows > kMaxRogueLockedRows ? kMaxRogueLockedRows : rogueStats.lockedRows;
}
int GetRoguePlayableHeight()
{
return nGameHeight - GetRogueLockedRows();
}
static void ClearLockedRows()
{
int lockedRows = GetRogueLockedRows();
for (int y = nGameHeight - lockedRows; y < nGameHeight; y++)
{
if (y < 0 || y >= nGameHeight)
{
continue;
}
for (int x = 0; x < nGameWidth; x++)
{
workRegion[y][x] = 0;
}
}
}
void AdvanceRogueDifficulty(int elapsedMs)
{
if (currentMode != MODE_ROGUE || currentScreen != SCREEN_PLAYING || suspendFlag || gameOverFlag || elapsedMs <= 0)
{
return;
}
rogueStats.difficultyElapsedMs += elapsedMs;
bool difficultyChanged = false;
while (rogueStats.difficultyElapsedMs >= kDifficultyStepMs)
{
rogueStats.difficultyElapsedMs -= kDifficultyStepMs;
rogueStats.difficultyLevel++;
difficultyChanged = true;
}
if (!difficultyChanged)
{
return;
}
int nextLockedRows = rogueStats.difficultyLevel / kDifficultyLevelsPerLockedRow;
if (nextLockedRows > kMaxRogueLockedRows)
{
nextLockedRows = kMaxRogueLockedRows;
}
bool lockedRowsChanged = nextLockedRows > rogueStats.lockedRows;
if (lockedRowsChanged)
{
rogueStats.lockedRows = nextLockedRows;
ClearLockedRows();
ComputeTarget();
}
currentFallInterval = GetRogueFallInterval();
TCHAR difficultyDetail[128];
_stprintf_s(
difficultyDetail,
_T("\u96be\u5ea6 Lv.%d\uff0c\u4e0b\u843d\u52a0\u5feb\uff0c\u5df2\u9501\u5b9a\u5e95\u90e8 %d/%d \u884c\u3002"),
rogueStats.difficultyLevel,
GetRogueLockedRows(),
kMaxRogueLockedRows);
SetFeedbackMessage(lockedRowsChanged ? _T("\u68cb\u76d8\u538b\u7f29") : _T("\u96be\u5ea6\u4e0a\u5347"), difficultyDetail, 12);
}
static int GetUpgradeCurrentLevel(int upgradeId)
{
switch (upgradeId)
@@ -228,7 +318,7 @@ static int GetUpgradeDynamicWeight(const UpgradeEntry& entry)
int topRow = GetTopOccupiedRow();
if (topRow >= 0)
{
int occupiedHeight = nGameHeight - topRow;
int occupiedHeight = GetRoguePlayableHeight() - topRow;
if (occupiedHeight >= 14)
{
weight += 50;
@@ -362,7 +452,7 @@ static bool IsUpgradeSelectable(const UpgradeEntry& entry)
static int GetTopOccupiedRow()
{
for (int i = 0; i < nGameHeight; i++)
for (int i = 0; i < GetRoguePlayableHeight(); i++)
{
for (int j = 0; j < nGameWidth; j++)
{
@@ -478,7 +568,7 @@ int TriggerMiniBlackHole(int maxCellsToClear)
{
int blockCounts[8] = { 0 };
for (int y = 0; y < nGameHeight; y++)
for (int y = 0; y < GetRoguePlayableHeight(); y++)
{
for (int x = 0; x < nGameWidth; x++)
{
@@ -507,7 +597,7 @@ int TriggerMiniBlackHole(int maxCellsToClear)
}
int clearedCellCount = 0;
for (int y = nGameHeight - 1; y >= 0 && clearedCellCount < maxCellsToClear; y--)
for (int y = GetRoguePlayableHeight() - 1; y >= 0 && clearedCellCount < maxCellsToClear; y--)
{
for (int x = 0; x < nGameWidth && clearedCellCount < maxCellsToClear; x++)
{
@@ -558,7 +648,7 @@ int ClearExplosiveAreaAt(int centerY, int centerX)
{
for (int x = centerX - radius; x <= centerX + radius; x++)
{
if (y >= 0 && y < nGameHeight && x >= 0 && x < nGameWidth)
if (y >= 0 && y < GetRoguePlayableHeight() && x >= 0 && x < nGameWidth)
{
if (workRegion[y][x] != 0)
{
@@ -581,7 +671,7 @@ int ClearColumnAt(int column)
return 0;
}
for (int y = 0; y < nGameHeight; y++)
for (int y = 0; y < GetRoguePlayableHeight(); y++)
{
if (workRegion[y][column] != 0)
{
@@ -597,7 +687,7 @@ int ClearRowAt(int row)
{
int clearedCellCount = 0;
if (row < 0 || row >= nGameHeight)
if (row < 0 || row >= GetRoguePlayableHeight())
{
return 0;
}
@@ -622,9 +712,9 @@ int TriggerRainbowRowCompletion(int minRow, int maxRow)
{
minRow = 0;
}
if (maxRow >= nGameHeight)
if (maxRow >= GetRoguePlayableHeight())
{
maxRow = nGameHeight - 1;
maxRow = GetRoguePlayableHeight() - 1;
}
for (int row = minRow; row <= maxRow; row++)
@@ -659,7 +749,7 @@ int TriggerRainbowRowCompletion(int minRow, int maxRow)
static int TriggerBlackHole()
{
int blockCounts[8] = { 0 };
for (int y = 0; y < nGameHeight; y++)
for (int y = 0; y < GetRoguePlayableHeight(); y++)
{
for (int x = 0; x < nGameWidth; x++)
{
@@ -688,7 +778,7 @@ static int TriggerBlackHole()
}
int clearedCellCount = 0;
for (int y = 0; y < nGameHeight; y++)
for (int y = 0; y < GetRoguePlayableHeight(); y++)
{
for (int x = 0; x < nGameWidth; x++)
{
@@ -709,7 +799,7 @@ int TriggerScreenBomb()
for (int i = 0; i < 5; i++)
{
int row = nGameHeight - 1 - i;
int row = GetRoguePlayableHeight() - 1 - i;
if (row < 0)
{
break;
@@ -748,9 +838,9 @@ static int TriggerChainBlast(int lineAnchor)
{
randomY = 0;
}
if (randomY >= nGameHeight)
if (randomY >= GetRoguePlayableHeight())
{
randomY = nGameHeight - 1;
randomY = GetRoguePlayableHeight() - 1;
}
if (workRegion[randomY][randomX] != 0)
@@ -822,7 +912,7 @@ int TryStabilizeBoard()
return 0;
}
for (int y = nGameHeight - 2; y >= 1; y--)
for (int y = GetRoguePlayableHeight() - 2; y >= 1; y--)
{
for (int x = 1; x < nGameWidth - 1; x++)
{
@@ -913,7 +1003,7 @@ static int TriggerUpgradeShockwave(int rowsToClear)
for (int i = 0; i < rowsToClear; i++)
{
DeleteOneLine(nGameHeight - 1);
DeleteOneLine(GetRoguePlayableHeight() - 1);
clearedRows++;
}
@@ -1027,6 +1117,7 @@ static void FillUpgradeOptions()
int GetRogueFallInterval()
{
int baseInterval = 500 + rogueStats.slowFallStacks * 80;
baseInterval -= rogueStats.difficultyLevel * kDifficultySpeedStepMs;
if (rogueStats.highPressureLevel > 0)
{
@@ -1388,7 +1479,7 @@ void ApplyLineClearResult(int linesCleared)
int chainBlastCells = 0;
for (int i = 0; i < linesCleared; i++)
{
chainBlastCells += TriggerChainBlast(nGameHeight - 1 - i);
chainBlastCells += TriggerChainBlast(GetRoguePlayableHeight() - 1 - i);
}
if (chainBlastCells > 0)
@@ -1416,7 +1507,7 @@ void ApplyLineClearResult(int linesCleared)
int thunderRowsCleared = 0;
for (int i = 0; i < 2; i++)
{
int randomRow = rand() % nGameHeight;
int randomRow = rand() % GetRoguePlayableHeight();
for (int x = 0; x < nGameWidth; x++)
{
if (workRegion[randomRow][x] != 0)
@@ -1485,7 +1576,7 @@ void ApplyLineClearResult(int linesCleared)
while (rogueStats.sweeperCharge >= sweeperThreshold)
{
rogueStats.sweeperCharge -= sweeperThreshold;
DeleteOneLine(nGameHeight - 1);
DeleteOneLine(GetRoguePlayableHeight() - 1);
clearedBySweeper++;
}