mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
fix: 同步 gameSpeed 倍率展示并修复移动端资源栏遮挡
- 顶部资源栏/概览页:产量、能耗、明细按 gameSpeed 统一缩放,避免显示与实际产出不一致 - 支持 gameSpeed=0:避免 “|| 1” 抹掉 0,并在循环间隔计算中规避除 0 - 修复移动端资源横向滚动时被菜单按钮遮挡(min-w-0/overflow-hidden + 对齐规则)
This commit is contained in:
@@ -249,7 +249,8 @@ export interface ConsumptionDetail {
|
||||
export const calculateProductionBreakdown = (
|
||||
planet: Planet,
|
||||
officers: Record<OfficerType, Officer>,
|
||||
currentTime: number
|
||||
currentTime: number,
|
||||
resourceSpeed: number = 1
|
||||
): ProductionBreakdown => {
|
||||
const metalMineLevel = planet.buildings[BuildingType.MetalMine] || 0
|
||||
const crystalMineLevel = planet.buildings[BuildingType.CrystalMine] || 0
|
||||
@@ -435,42 +436,56 @@ export const calculateProductionBreakdown = (
|
||||
|
||||
const energyFinal = energyBase * (1 + totalEnergyBonus / 100)
|
||||
|
||||
const speed = resourceSpeed
|
||||
|
||||
const scaleBonuses = (bonuses: ProductionBonus[]) =>
|
||||
bonuses.map(bonus => ({
|
||||
...bonus,
|
||||
value: bonus.value * speed
|
||||
}))
|
||||
|
||||
const scaleSources = (sources?: ProductionSource[]) =>
|
||||
sources?.map(source => ({
|
||||
...source,
|
||||
production: source.production * speed
|
||||
}))
|
||||
|
||||
return {
|
||||
metal: {
|
||||
baseProduction: metalBase,
|
||||
baseProduction: metalBase * speed,
|
||||
buildingLevel: metalMineLevel,
|
||||
buildingName: 'buildings.metalMine',
|
||||
bonuses: metalBonuses,
|
||||
finalProduction: metalFinal
|
||||
bonuses: scaleBonuses(metalBonuses),
|
||||
finalProduction: metalFinal * speed
|
||||
},
|
||||
crystal: {
|
||||
baseProduction: crystalBase,
|
||||
baseProduction: crystalBase * speed,
|
||||
buildingLevel: crystalMineLevel,
|
||||
buildingName: 'buildings.crystalMine',
|
||||
bonuses: crystalBonuses,
|
||||
finalProduction: crystalFinal
|
||||
bonuses: scaleBonuses(crystalBonuses),
|
||||
finalProduction: crystalFinal * speed
|
||||
},
|
||||
deuterium: {
|
||||
baseProduction: deuteriumBase,
|
||||
baseProduction: deuteriumBase * speed,
|
||||
buildingLevel: deuteriumSynthesizerLevel,
|
||||
buildingName: 'buildings.deuteriumSynthesizer',
|
||||
bonuses: deuteriumBonuses,
|
||||
finalProduction: deuteriumFinal
|
||||
bonuses: scaleBonuses(deuteriumBonuses),
|
||||
finalProduction: deuteriumFinal * speed
|
||||
},
|
||||
darkMatter: {
|
||||
baseProduction: darkMatterBase,
|
||||
baseProduction: darkMatterBase * speed,
|
||||
buildingLevel: darkMatterCollectorLevel,
|
||||
buildingName: 'buildings.darkMatterCollector',
|
||||
bonuses: darkMatterBonuses,
|
||||
finalProduction: darkMatterFinal
|
||||
bonuses: scaleBonuses(darkMatterBonuses),
|
||||
finalProduction: darkMatterFinal * speed
|
||||
},
|
||||
energy: {
|
||||
baseProduction: energyBase,
|
||||
baseProduction: energyBase * speed,
|
||||
buildingLevel: solarPlantLevel,
|
||||
buildingName: 'buildings.solarPlant',
|
||||
bonuses: energyBonuses,
|
||||
finalProduction: energyFinal,
|
||||
sources: energySources
|
||||
bonuses: scaleBonuses(energyBonuses),
|
||||
finalProduction: energyFinal * speed,
|
||||
sources: scaleSources(energySources)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -478,7 +493,7 @@ export const calculateProductionBreakdown = (
|
||||
/**
|
||||
* 计算能量消耗详细breakdown
|
||||
*/
|
||||
export const calculateConsumptionBreakdown = (planet: Planet): ConsumptionBreakdown => {
|
||||
export const calculateConsumptionBreakdown = (planet: Planet, resourceSpeed: number = 1): ConsumptionBreakdown => {
|
||||
const metalMineLevel = planet.buildings[BuildingType.MetalMine] || 0
|
||||
const crystalMineLevel = planet.buildings[BuildingType.CrystalMine] || 0
|
||||
const deuteriumSynthesizerLevel = planet.buildings[BuildingType.DeuteriumSynthesizer] || 0
|
||||
@@ -487,22 +502,24 @@ export const calculateConsumptionBreakdown = (planet: Planet): ConsumptionBreakd
|
||||
const crystalConsumption = crystalMineLevel * 10 * Math.pow(1.1, crystalMineLevel)
|
||||
const deuteriumConsumption = deuteriumSynthesizerLevel * 15 * Math.pow(1.1, deuteriumSynthesizerLevel)
|
||||
|
||||
const speed = resourceSpeed
|
||||
|
||||
return {
|
||||
metalMine: {
|
||||
buildingLevel: metalMineLevel,
|
||||
buildingName: 'buildings.metalMine',
|
||||
consumption: metalConsumption
|
||||
consumption: metalConsumption * speed
|
||||
},
|
||||
crystalMine: {
|
||||
buildingLevel: crystalMineLevel,
|
||||
buildingName: 'buildings.crystalMine',
|
||||
consumption: crystalConsumption
|
||||
consumption: crystalConsumption * speed
|
||||
},
|
||||
deuteriumSynthesizer: {
|
||||
buildingLevel: deuteriumSynthesizerLevel,
|
||||
buildingName: 'buildings.deuteriumSynthesizer',
|
||||
consumption: deuteriumConsumption
|
||||
consumption: deuteriumConsumption * speed
|
||||
},
|
||||
total: metalConsumption + crystalConsumption + deuteriumConsumption
|
||||
total: (metalConsumption + crystalConsumption + deuteriumConsumption) * speed
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user