完成第一批6个Rogue强化与随机强化池接入

This commit is contained in:
2026-04-24 19:07:15 +08:00
parent 9664a2e623
commit bbaa89e21d
4 changed files with 293 additions and 71 deletions
+169 -20
View File
@@ -18,14 +18,30 @@ UpgradeUiState upgradeUiState = { 0, 0, 0, 0, {} };
int currentScreen = SCREEN_MENU;
int currentMode = MODE_CLASSIC;
int currentFallInterval = 500;
int nextTypes[3] = { 0, 0, 0 };
enum UpgradeId
{
UPGRADE_SCORE_MULTIPLIER = 0,
UPGRADE_EXP_MULTIPLIER = 1,
UPGRADE_SLOW_FALL = 2
UPGRADE_SLOW_FALL = 2,
UPGRADE_COMBO_BONUS = 3,
UPGRADE_PREVIEW_PLUS_ONE = 4,
UPGRADE_LAST_CHANCE = 5
};
static const UpgradeEntry kUpgradePool[] =
{
{ UPGRADE_SCORE_MULTIPLIER, -1, true, _T("\u5206\u6570\u500d\u7387"), _T("\u5f97\u5206"), _T("\u6240\u6709\u5f97\u5206\u63d0\u9ad8 20%\u3002") },
{ UPGRADE_COMBO_BONUS, -1, true, _T("\u8fde\u51fb\u52a0\u6210"), _T("\u8282\u594f"), _T("\u8fde\u7eed\u6d88\u884c\u65f6\u8ffd\u52a0\u8fde\u51fb\u5956\u52b1\u3002") },
{ UPGRADE_SLOW_FALL, -1, true, _T("\u6162\u901f\u4e0b\u843d"), _T("\u64cd\u4f5c"), _T("\u81ea\u7136\u4e0b\u843d\u53d8\u6162\uff0c\u6bcf\u6b21\u63d0\u9ad8 80ms\u3002") },
{ UPGRADE_PREVIEW_PLUS_ONE, 3, false, _T("\u989d\u5916\u9884\u89c8"), _T("\u89c6\u91ce"), _T("\u4e0b\u4e00\u4e2a\u65b9\u5757\u9884\u89c8 +1\uff0c\u6700\u591a 3 \u4e2a\u3002") },
{ UPGRADE_EXP_MULTIPLIER, -1, true, _T("\u7ecf\u9a8c\u5f3a\u5316"), _T("\u6210\u957f"), _T("\u540e\u7eed\u6d88\u884c\u83b7\u5f97 EXP \u63d0\u9ad8 25%\u3002") },
{ UPGRADE_LAST_CHANCE, 1, false, _T("\u6700\u540e\u4e00\u640f"), _T("\u4fdd\u547d"), _T("\u9996\u6b21\u9876\u6b7b\u65f6\u81ea\u52a8\u6e05\u9664\u5e95\u90e8 3 \u884c\u5e76\u7ee7\u7eed\u6e38\u620f\u3002") }
};
static constexpr int kUpgradePoolSize = sizeof(kUpgradePool) / sizeof(kUpgradePool[0]);
int bricks[7][4][4][4] =
{
{
@@ -164,6 +180,87 @@ static void ResetPlayerStats(PlayerStats& stats, bool useRogueRules)
stats.scoreMultiplierPercent = 100;
stats.expMultiplierPercent = 100;
stats.slowFallStacks = 0;
stats.comboBonusStacks = 0;
stats.comboChain = 0;
stats.previewCount = 1;
stats.lastChanceCount = 0;
stats.scoreUpgradeLevel = 0;
stats.expUpgradeLevel = 0;
stats.previewUpgradeLevel = 0;
stats.lastChanceUpgradeLevel = 0;
}
static int GetNextPreviewLimit()
{
if (currentMode != MODE_ROGUE)
{
return 1;
}
if (rogueStats.previewCount < 1)
{
return 1;
}
if (rogueStats.previewCount > 3)
{
return 3;
}
return rogueStats.previewCount;
}
static int GetUpgradeCurrentLevel(int upgradeId)
{
switch (upgradeId)
{
case UPGRADE_SCORE_MULTIPLIER:
return rogueStats.scoreUpgradeLevel;
case UPGRADE_EXP_MULTIPLIER:
return rogueStats.expUpgradeLevel;
case UPGRADE_SLOW_FALL:
return rogueStats.slowFallStacks;
case UPGRADE_COMBO_BONUS:
return rogueStats.comboBonusStacks;
case UPGRADE_PREVIEW_PLUS_ONE:
return rogueStats.previewUpgradeLevel;
case UPGRADE_LAST_CHANCE:
return rogueStats.lastChanceUpgradeLevel;
default:
return 0;
}
}
static bool IsUpgradeSelectable(const UpgradeEntry& entry)
{
if (entry.repeatable)
{
return true;
}
if (entry.maxLevel <= 0)
{
return GetUpgradeCurrentLevel(entry.id) == 0;
}
return GetUpgradeCurrentLevel(entry.id) < entry.maxLevel;
}
static void ResetNextQueue()
{
for (int i = 0; i < 3; i++)
{
nextTypes[i] = rand() % 7;
}
}
static int ConsumeNextType()
{
int nextType = nextTypes[0];
nextTypes[0] = nextTypes[1];
nextTypes[1] = nextTypes[2];
nextTypes[2] = rand() % 7;
return nextType;
}
static int GetRogueScoreByLines(int linesCleared)
@@ -207,23 +304,36 @@ static int ApplyLevelProgress(PlayerStats& stats)
static void FillUpgradeOptions()
{
upgradeUiState.optionCount = 3;
int selectableIndexes[kUpgradePoolSize] = { 0 };
int selectableCount = 0;
for (int i = 0; i < kUpgradePoolSize; i++)
{
if (IsUpgradeSelectable(kUpgradePool[i]))
{
selectableIndexes[selectableCount++] = i;
}
}
int optionCount = selectableCount < 3 ? selectableCount : 3;
upgradeUiState.optionCount = optionCount;
upgradeUiState.selectedIndex = 0;
upgradeUiState.options[0].id = UPGRADE_SCORE_MULTIPLIER;
upgradeUiState.options[0].name = _T("\u5206\u6570\u500d\u7387");
upgradeUiState.options[0].category = _T("\u5f97\u5206");
upgradeUiState.options[0].description = _T("\u6240\u6709\u5f97\u5206\u63d0\u9ad8 20%\u3002");
for (int i = 0; i < optionCount; i++)
{
int pickSlot = rand() % selectableCount;
int pickedIndex = selectableIndexes[pickSlot];
const UpgradeEntry& pickedEntry = kUpgradePool[pickedIndex];
upgradeUiState.options[1].id = UPGRADE_EXP_MULTIPLIER;
upgradeUiState.options[1].name = _T("\u7ecf\u9a8c\u5f3a\u5316");
upgradeUiState.options[1].category = _T("\u6210\u957f");
upgradeUiState.options[1].description = _T("\u540e\u7eed\u6d88\u884c\u83b7\u5f97 EXP \u63d0\u9ad8 25%\u3002");
upgradeUiState.options[i].id = pickedEntry.id;
upgradeUiState.options[i].currentLevel = GetUpgradeCurrentLevel(pickedEntry.id);
upgradeUiState.options[i].name = pickedEntry.name;
upgradeUiState.options[i].category = pickedEntry.category;
upgradeUiState.options[i].description = pickedEntry.description;
upgradeUiState.options[2].id = UPGRADE_SLOW_FALL;
upgradeUiState.options[2].name = _T("\u6162\u901f\u4e0b\u843d");
upgradeUiState.options[2].category = _T("\u64cd\u4f5c");
upgradeUiState.options[2].description = _T("\u81ea\u7136\u4e0b\u843d\u53d8\u6162\uff0c\u6bcf\u6b21\u63d0\u9ad8 80ms\u3002");
selectableIndexes[pickSlot] = selectableIndexes[selectableCount - 1];
selectableCount--;
}
}
static int GetRogueFallInterval()
@@ -237,14 +347,30 @@ static void ApplyUpgradeById(int upgradeId)
{
case UPGRADE_SCORE_MULTIPLIER:
rogueStats.scoreMultiplierPercent += 20;
rogueStats.scoreUpgradeLevel++;
break;
case UPGRADE_COMBO_BONUS:
rogueStats.comboBonusStacks++;
break;
case UPGRADE_EXP_MULTIPLIER:
rogueStats.expMultiplierPercent += 25;
rogueStats.expUpgradeLevel++;
break;
case UPGRADE_SLOW_FALL:
rogueStats.slowFallStacks++;
currentFallInterval = GetRogueFallInterval();
break;
case UPGRADE_PREVIEW_PLUS_ONE:
if (rogueStats.previewCount < 3)
{
rogueStats.previewCount++;
}
rogueStats.previewUpgradeLevel = rogueStats.previewCount - 1;
break;
case UPGRADE_LAST_CHANCE:
rogueStats.lastChanceCount = 1;
rogueStats.lastChanceUpgradeLevel = 1;
break;
default:
break;
}
@@ -254,6 +380,10 @@ static void ApplyLineClearResult(int linesCleared)
{
if (linesCleared <= 0)
{
if (currentMode == MODE_ROGUE)
{
rogueStats.comboChain = 0;
}
return;
}
@@ -271,6 +401,12 @@ static void ApplyLineClearResult(int linesCleared)
int expGain = GetRogueExpByLines(linesCleared);
expGain = expGain * rogueStats.expMultiplierPercent / 100;
rogueStats.comboChain++;
if (rogueStats.comboBonusStacks > 0 && rogueStats.comboChain > 1)
{
scoreGain += (rogueStats.comboChain - 1) * rogueStats.comboBonusStacks * 50;
}
rogueStats.totalLinesCleared += linesCleared;
rogueStats.score += scoreGain;
rogueStats.exp += expGain;
@@ -533,13 +669,25 @@ void Fixing()
if (overflowTop)
{
gameOverFlag = true;
return;
if (currentMode == MODE_ROGUE && rogueStats.lastChanceCount > 0)
{
rogueStats.lastChanceCount--;
for (int i = 0; i < 3; i++)
{
DeleteOneLine(nGameHeight - 1);
}
}
else
{
gameOverFlag = true;
return;
}
}
// 生成下一个活动方块
type = nType;
nType = rand() % 7;
type = ConsumeNextType();
nType = nextTypes[0];
state = 0;
point = GetSpawnPoint(type);
target = point;
@@ -664,8 +812,9 @@ void Restart()
upgradeUiState.totalChosenCount = 0;
tScore = 0;
type = rand() % 7;
nType = rand() % 7;
ResetNextQueue();
type = ConsumeNextType();
nType = nextTypes[0];
state = 0;
point = GetSpawnPoint(type);
target = point;