// 测试墙体配置集成 // 验证MainUIController是否正确使用wall.json配置 console.log('=== 墙体配置集成测试 ==='); // 模拟wall.json配置数据 const mockWallConfig = { wallConfig: { maxLevel: 5, healthByLevel: { "1": 100, "2": 500, "3": 1200, "4": 1500, "5": 2000 }, upgradeCosts: { "1": 100, "2": 300, "3": 1000, "4": 2000 } } }; // 模拟SaveDataManager的方法 class MockSaveDataManager { constructor() { this.wallConfig = mockWallConfig; this.playerData = { wallLevel: 1, money: 1000 }; } getWallLevel() { return this.playerData.wallLevel; } getWallUpgradeCost() { const costs = this.wallConfig.wallConfig.upgradeCosts; return costs[this.playerData.wallLevel.toString()] || 0; } getWallHealthByLevel(level) { const healthMap = this.wallConfig.wallConfig.healthByLevel; return healthMap[level.toString()] || 0; } getWallMaxLevel() { return this.wallConfig.wallConfig.maxLevel || 5; } } // 测试升级信息显示逻辑 function testUpgradeInfoDisplay() { console.log('\n--- 测试升级信息显示 ---'); const sdm = new MockSaveDataManager(); // 测试不同等级的显示 for (let level = 1; level <= 5; level++) { sdm.playerData.wallLevel = level; const currentLevel = sdm.getWallLevel(); const cost = sdm.getWallUpgradeCost(); const currentHp = sdm.getWallHealthByLevel(currentLevel); const nextHp = sdm.getWallHealthByLevel(currentLevel + 1); const maxLevel = sdm.getWallMaxLevel(); console.log(`等级 ${level}:`); console.log(` 升级费用: ${cost}`); console.log(` 当前血量: ${currentHp}`); console.log(` 下级血量: ${nextHp}`); console.log(` 血量显示: ${currentHp}>>${nextHp}`); console.log(` 是否达到最大等级: ${currentLevel >= maxLevel}`); console.log(''); } } // 测试升级逻辑 function testUpgradeLogic() { console.log('--- 测试升级逻辑 ---'); const sdm = new MockSaveDataManager(); // 测试各种升级场景 const testCases = [ { level: 1, money: 50, desc: '金币不足' }, { level: 1, money: 150, desc: '正常升级' }, { level: 5, money: 5000, desc: '已达最大等级' }, { level: 4, money: 1500, desc: '升级到最大等级前' } ]; testCases.forEach((testCase, index) => { console.log(`\n测试案例 ${index + 1}: ${testCase.desc}`); sdm.playerData.wallLevel = testCase.level; sdm.playerData.money = testCase.money; const currentLevel = sdm.getWallLevel(); const cost = sdm.getWallUpgradeCost(); const maxLevel = sdm.getWallMaxLevel(); console.log(` 当前等级: ${currentLevel}`); console.log(` 当前金币: ${testCase.money}`); console.log(` 升级费用: ${cost}`); console.log(` 最大等级: ${maxLevel}`); // 检查升级条件 if (currentLevel >= maxLevel) { console.log(' 结果: 墙体已达到最大等级'); } else if (testCase.money < cost) { console.log(` 结果: 钞票不足,需要${cost}钞票`); } else { console.log(' 结果: 可以升级'); } }); } // 运行测试 testUpgradeInfoDisplay(); testUpgradeLogic(); console.log('\n=== 测试完成 ==='); console.log('MainUIController现在应该正确使用wall.json配置数据了!');