Refactor: Centralize Constants and Configuration
This commit is contained in:
@@ -18,6 +18,7 @@ import '../game/model/effect_event.dart'; // EffectEvent import
|
||||
|
||||
import '../game/save_manager.dart';
|
||||
import '../game/config/game_config.dart';
|
||||
import '../game/config/battle_config.dart'; // Import BattleConfig
|
||||
import 'shop_provider.dart'; // Import ShopProvider
|
||||
|
||||
import '../game/logic/battle_log_manager.dart';
|
||||
@@ -625,7 +626,7 @@ class BattleProvider with ChangeNotifier {
|
||||
// Calculate Gold Reward
|
||||
// Base 10 + (Stage * 5) + Random variance
|
||||
final random = Random();
|
||||
int goldReward = 10 + (stage * 5) + random.nextInt(10);
|
||||
int goldReward = GameConfig.baseGoldReward + (stage * GameConfig.goldRewardPerStage) + random.nextInt(GameConfig.goldRewardVariance);
|
||||
|
||||
player.gold += goldReward;
|
||||
_lastGoldReward = goldReward; // Store for UI display
|
||||
@@ -798,7 +799,7 @@ class BattleProvider with ChangeNotifier {
|
||||
|
||||
if (canDefend) {
|
||||
// 70% Attack, 30% Defend
|
||||
isAttack = random.nextDouble() < 0.7;
|
||||
isAttack = random.nextDouble() < BattleConfig.enemyAttackChance;
|
||||
} else {
|
||||
isAttack = true;
|
||||
}
|
||||
@@ -808,13 +809,13 @@ class BattleProvider with ChangeNotifier {
|
||||
double efficiency = 1.0;
|
||||
switch (risk) {
|
||||
case RiskLevel.safe:
|
||||
efficiency = 0.5;
|
||||
efficiency = BattleConfig.safeEfficiency;
|
||||
break;
|
||||
case RiskLevel.normal:
|
||||
efficiency = 1.0;
|
||||
efficiency = BattleConfig.normalEfficiency;
|
||||
break;
|
||||
case RiskLevel.risky:
|
||||
efficiency = 2.0;
|
||||
efficiency = BattleConfig.riskyEfficiency;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -828,13 +829,13 @@ class BattleProvider with ChangeNotifier {
|
||||
bool success = false;
|
||||
switch (risk) {
|
||||
case RiskLevel.safe:
|
||||
success = random.nextDouble() < 1.0;
|
||||
success = random.nextDouble() < BattleConfig.safeBaseChance;
|
||||
break;
|
||||
case RiskLevel.normal:
|
||||
success = random.nextDouble() < 0.8;
|
||||
success = random.nextDouble() < BattleConfig.normalBaseChance;
|
||||
break;
|
||||
case RiskLevel.risky:
|
||||
success = random.nextDouble() < 0.4;
|
||||
success = random.nextDouble() < BattleConfig.riskyBaseChance;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -856,13 +857,13 @@ class BattleProvider with ChangeNotifier {
|
||||
bool success = false;
|
||||
switch (risk) {
|
||||
case RiskLevel.safe:
|
||||
success = random.nextDouble() < 1.0;
|
||||
success = random.nextDouble() < BattleConfig.safeBaseChance;
|
||||
break;
|
||||
case RiskLevel.normal:
|
||||
success = random.nextDouble() < 0.8;
|
||||
success = random.nextDouble() < BattleConfig.normalBaseChance;
|
||||
break;
|
||||
case RiskLevel.risky:
|
||||
success = random.nextDouble() < 0.4;
|
||||
success = random.nextDouble() < BattleConfig.riskyBaseChance;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user