Docs: Consolidate prompts 61-76 into summary and update context

This commit is contained in:
2025-12-07 22:06:51 +09:00
parent 59ebb7cd98
commit 135bf26332
20 changed files with 155 additions and 490 deletions
+64 -45
View File
@@ -16,14 +16,14 @@ class LootGenerator {
int finalHp = template.hpBonus;
int finalArmor = template.armorBonus;
int finalLuck = template.luck;
// 0. Normal Rarity: Prefix logic for base stat variations
if (template.rarity == ItemRarity.normal) {
// Weighted Random Selection
final prefixes = ItemPrefixTable.normalPrefixes;
int totalWeight = prefixes.fold(0, (sum, p) => sum + p.weight);
int roll = _random.nextInt(totalWeight);
ItemModifier? selectedModifier;
int currentSum = 0;
for (var mod in prefixes) {
@@ -36,9 +36,9 @@ class LootGenerator {
if (selectedModifier != null) {
if (selectedModifier.prefix.isNotEmpty) {
finalName = "${selectedModifier.prefix} $template.name";
finalName = "${selectedModifier.prefix} ${template.name}";
}
double mult = selectedModifier.multiplier;
if (mult != 1.0) {
finalAtk = (finalAtk * mult).floor();
@@ -49,58 +49,77 @@ class LootGenerator {
}
// 1. Magic Rarity: 50% chance to get a Magic Prefix (1 stat change)
else if (template.rarity == ItemRarity.magic) {
if (_random.nextDouble() < ItemConfig.magicPrefixChance) { // Use constant
if (_random.nextDouble() < ItemConfig.magicPrefixChance) {
// Use constant
// Filter valid prefixes for this slot
final validPrefixes = ItemPrefixTable.magicPrefixes.where((p) {
return p.allowedSlots == null || p.allowedSlots!.contains(template.slot);
return p.allowedSlots == null ||
p.allowedSlots!.contains(template.slot);
}).toList();
if (validPrefixes.isNotEmpty) {
final modifier = validPrefixes[_random.nextInt(validPrefixes.length)];
finalName = "${modifier.prefix} ${template.name}";
modifier.statChanges.forEach((stat, value) {
switch(stat) {
case StatType.atk: finalAtk += value; break;
case StatType.maxHp: finalHp += value; break;
case StatType.defense: finalArmor += value; break;
case StatType.luck: finalLuck += value; break;
}
});
final modifier = validPrefixes[_random.nextInt(validPrefixes.length)];
finalName = "${modifier.prefix} ${template.name}";
modifier.statChanges.forEach((stat, value) {
switch (stat) {
case StatType.atk:
finalAtk += value;
break;
case StatType.maxHp:
finalHp += value;
break;
case StatType.defense:
finalArmor += value;
break;
case StatType.luck:
finalLuck += value;
break;
}
});
}
}
}
}
// 2. Rare Rarity: Always get a Rare Prefix (2 stat changes or stronger)
else if (template.rarity == ItemRarity.rare) {
bool nameChanged = false;
// Always generate a completely new cool name for Rare items
finalName = NameGenerator.generateName(template.slot);
nameChanged = true;
bool nameChanged = false;
// Filter valid prefixes for this slot
final validPrefixes = ItemPrefixTable.rarePrefixes.where((p) {
return p.allowedSlots == null || p.allowedSlots!.contains(template.slot);
}).toList();
// Always generate a completely new cool name for Rare items
finalName = NameGenerator.generateName(template.slot);
nameChanged = true;
if (validPrefixes.isNotEmpty) {
final modifier = validPrefixes[_random.nextInt(validPrefixes.length)];
// If name wasn't already changed by NameGenerator, apply prefix to name
if (!nameChanged) {
finalName = "${modifier.prefix} ${template.name}";
}
// Even if name changed, we STILL apply the stats from the prefix modifier!
modifier.statChanges.forEach((stat, value) {
switch(stat) {
case StatType.atk: finalAtk += value; break;
case StatType.maxHp: finalHp += value; break;
case StatType.defense: finalArmor += value; break;
case StatType.luck: finalLuck += value; break;
}
});
}
// Filter valid prefixes for this slot
final validPrefixes = ItemPrefixTable.rarePrefixes.where((p) {
return p.allowedSlots == null ||
p.allowedSlots!.contains(template.slot);
}).toList();
if (validPrefixes.isNotEmpty) {
final modifier = validPrefixes[_random.nextInt(validPrefixes.length)];
// If name wasn't already changed by NameGenerator, apply prefix to name
if (!nameChanged) {
finalName = "${modifier.prefix} ${template.name}";
}
// Even if name changed, we STILL apply the stats from the prefix modifier!
modifier.statChanges.forEach((stat, value) {
switch (stat) {
case StatType.atk:
finalAtk += value;
break;
case StatType.maxHp:
finalHp += value;
break;
case StatType.defense:
finalArmor += value;
break;
case StatType.luck:
finalLuck += value;
break;
}
});
}
}
// Legendary/Unique items usually keep their original names/stats.
+1 -3
View File
@@ -48,9 +48,7 @@ class Character {
'baseDefense': baseDefense,
'gold': gold,
'image': image,
'equipment': equipment.map(
(key, value) => MapEntry(key.name, value.id),
),
'equipment': equipment.map((key, value) => MapEntry(key.name, value.id)),
'inventory': inventory.map((e) => e.id).toList(),
'statusEffects': statusEffects.map((e) => e.toJson()).toList(),
'permanentModifiers': permanentModifiers.map((e) => e.toJson()).toList(),
+7 -8
View File
@@ -369,15 +369,13 @@ class BattleProvider with ChangeNotifier {
handleImpact(event); // Process impact via handleImpact for safety
}
// Now check for enemy death (if applicable from bleed, or previous impacts)
if (enemy.isDead) {
// Check enemy death after player's action
_onVictory();
return;
}
// Now check for enemy death (if applicable from bleed, or previous impacts)
_endPlayerTurn();
}
// Removed redundant `if (enemy.isDead)` check as it's handled in `_processAttackImpact`
_endPlayerTurn();
}
void _endPlayerTurn() {
// Update durations at end of turn
@@ -630,6 +628,7 @@ class BattleProvider with ChangeNotifier {
stage++;
showRewardPopup = false;
rewardOptions.clear(); // Clear options to prevent flash on next victory
_prepareNextStage();