mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
Merge branch 'setube:main' into main
This commit is contained in:
22
src/App.vue
22
src/App.vue
@@ -201,11 +201,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 资源显示 - PC端居中,移动端可折叠 -->
|
<!-- 资源显示 - PC端居中,移动端可折叠 -->
|
||||||
|
<!-- 关键:min-w-0 + overflow-hidden,避免横向滚动内容溢出覆盖左侧菜单按钮 -->
|
||||||
|
<div class="min-w-0 overflow-hidden">
|
||||||
<div
|
<div
|
||||||
class="resource-bar flex items-center gap-3 sm:gap-6 justify-center"
|
class="resource-bar flex items-center gap-3 sm:gap-6 justify-start sm:justify-center"
|
||||||
:class="resourceBarExpanded ? 'hidden' : 'overflow-x-auto'"
|
:class="resourceBarExpanded ? 'hidden' : 'overflow-x-auto'"
|
||||||
>
|
>
|
||||||
<div v-for="resourceType in resourceTypes" :key="resourceType.key" class="flex items-center gap-1.5 sm:gap-2 flex-shrink-0">
|
<div
|
||||||
|
v-for="resourceType in resourceTypes"
|
||||||
|
:key="resourceType.key"
|
||||||
|
class="flex items-center gap-1.5 sm:gap-2 flex-shrink-0"
|
||||||
|
>
|
||||||
<ResourceIcon :type="resourceType.key" size="md" />
|
<ResourceIcon :type="resourceType.key" size="md" />
|
||||||
<div class="min-w-0">
|
<div class="min-w-0">
|
||||||
<!-- 电力显示净产量和效率 -->
|
<!-- 电力显示净产量和效率 -->
|
||||||
@@ -226,7 +232,8 @@
|
|||||||
class="text-xs sm:text-sm font-medium truncate"
|
class="text-xs sm:text-sm font-medium truncate"
|
||||||
:class="getResourceColor(planet.resources[resourceType.key], capacity?.[resourceType.key] || Infinity)"
|
:class="getResourceColor(planet.resources[resourceType.key], capacity?.[resourceType.key] || Infinity)"
|
||||||
>
|
>
|
||||||
{{ formatNumber(planet.resources[resourceType.key]) }} / {{ formatNumber(capacity?.[resourceType.key] || 0) }}
|
{{ formatNumber(planet.resources[resourceType.key]) }} /
|
||||||
|
{{ formatNumber(capacity?.[resourceType.key] || 0) }}
|
||||||
</p>
|
</p>
|
||||||
<p class="text-[10px] sm:text-xs text-muted-foreground truncate">
|
<p class="text-[10px] sm:text-xs text-muted-foreground truncate">
|
||||||
+{{ formatNumber(Math.round((production?.[resourceType.key] || 0) / 60)) }}/{{ t('resources.perMinute') }}
|
+{{ formatNumber(Math.round((production?.[resourceType.key] || 0) / 60)) }}/{{ t('resources.perMinute') }}
|
||||||
@@ -235,6 +242,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 右侧:展开按钮(仅移动端) + 状态 -->
|
<!-- 右侧:展开按钮(仅移动端) + 状态 -->
|
||||||
<div class="flex items-center gap-2 sm:gap-3 flex-shrink-0 justify-end">
|
<div class="flex items-center gap-2 sm:gap-3 flex-shrink-0 justify-end">
|
||||||
@@ -428,6 +436,7 @@
|
|||||||
import { DIPLOMATIC_CONFIG } from '@/config/gameConfig'
|
import { DIPLOMATIC_CONFIG } from '@/config/gameConfig'
|
||||||
import type { VersionInfo } from '@/utils/versionCheck'
|
import type { VersionInfo } from '@/utils/versionCheck'
|
||||||
import { formatNumber, getResourceColor } from '@/utils/format'
|
import { formatNumber, getResourceColor } from '@/utils/format'
|
||||||
|
import { getGameLoopIntervalMs, scaleNumber, scaleResources } from '@/utils/speed'
|
||||||
import {
|
import {
|
||||||
Moon,
|
Moon,
|
||||||
Sun,
|
Sun,
|
||||||
@@ -1232,7 +1241,7 @@
|
|||||||
clearInterval(gameLoop)
|
clearInterval(gameLoop)
|
||||||
}
|
}
|
||||||
// 根据游戏速度计算间隔时间
|
// 根据游戏速度计算间隔时间
|
||||||
const interval = 1000 / (gameStore.gameSpeed || 1)
|
const interval = getGameLoopIntervalMs(gameStore.gameSpeed)
|
||||||
// 启动新的游戏循环
|
// 启动新的游戏循环
|
||||||
gameLoop = setInterval(() => {
|
gameLoop = setInterval(() => {
|
||||||
updateGame()
|
updateGame()
|
||||||
@@ -1433,11 +1442,12 @@
|
|||||||
if (!planet.value) return null
|
if (!planet.value) return null
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
const bonuses = officerLogic.calculateActiveBonuses(gameStore.player.officers, now)
|
const bonuses = officerLogic.calculateActiveBonuses(gameStore.player.officers, now)
|
||||||
return resourceLogic.calculateResourceProduction(planet.value, {
|
const base = resourceLogic.calculateResourceProduction(planet.value, {
|
||||||
resourceProductionBonus: bonuses.resourceProductionBonus,
|
resourceProductionBonus: bonuses.resourceProductionBonus,
|
||||||
darkMatterProductionBonus: bonuses.darkMatterProductionBonus,
|
darkMatterProductionBonus: bonuses.darkMatterProductionBonus,
|
||||||
energyProductionBonus: bonuses.energyProductionBonus
|
energyProductionBonus: bonuses.energyProductionBonus
|
||||||
})
|
})
|
||||||
|
return scaleResources(base, gameStore.gameSpeed)
|
||||||
})
|
})
|
||||||
|
|
||||||
const capacity = computed(() => {
|
const capacity = computed(() => {
|
||||||
@@ -1450,7 +1460,7 @@
|
|||||||
// 电力消耗
|
// 电力消耗
|
||||||
const energyConsumption = computed(() => {
|
const energyConsumption = computed(() => {
|
||||||
if (!planet.value) return 0
|
if (!planet.value) return 0
|
||||||
return resourceLogic.calculateEnergyConsumption(planet.value)
|
return scaleNumber(resourceLogic.calculateEnergyConsumption(planet.value), gameStore.gameSpeed)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 净电力(产量 - 消耗)
|
// 净电力(产量 - 消耗)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
import { DIPLOMATIC_CONFIG } from '@/config/gameConfig'
|
import { DIPLOMATIC_CONFIG } from '@/config/gameConfig'
|
||||||
import { locales, type Locale } from '@/locales'
|
import { locales, type Locale } from '@/locales'
|
||||||
|
import * as resourceLogic from './resourceLogic'
|
||||||
|
import * as officerLogic from './officerLogic'
|
||||||
import type {
|
import type {
|
||||||
DiplomaticRelation,
|
DiplomaticRelation,
|
||||||
RelationStatus,
|
RelationStatus,
|
||||||
@@ -783,14 +785,14 @@ export const handleNPCGiftToPlayer = (npc: NPC, player: Player, giftResources: R
|
|||||||
* @param locale 语言代码
|
* @param locale 语言代码
|
||||||
*/
|
*/
|
||||||
export const acceptNPCGift = (player: Player, npc: NPC, giftNotification: GiftNotification, locale: Locale): void => {
|
export const acceptNPCGift = (player: Player, npc: NPC, giftNotification: GiftNotification, locale: Locale): void => {
|
||||||
// 将资源添加到玩家主星球
|
// 将资源添加到玩家主星球(使用安全添加函数防止溢出)
|
||||||
if (player.planets && player.planets.length > 0) {
|
if (player.planets && player.planets.length > 0) {
|
||||||
const mainPlanet = player.planets[0]
|
const mainPlanet = player.planets[0]
|
||||||
if (mainPlanet) {
|
if (mainPlanet) {
|
||||||
mainPlanet.resources.metal += giftNotification.resources.metal
|
// 计算军官加成
|
||||||
mainPlanet.resources.crystal += giftNotification.resources.crystal
|
const bonuses = officerLogic.calculateActiveBonuses(player.officers, Date.now())
|
||||||
mainPlanet.resources.deuterium += giftNotification.resources.deuterium
|
// 使用安全添加函数,超出容量的资源会丢失
|
||||||
mainPlanet.resources.darkMatter += giftNotification.resources.darkMatter
|
resourceLogic.addResourcesSafely(mainPlanet, giftNotification.resources, bonuses.storageCapacityBonus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import * as battleLogic from './battleLogic'
|
|||||||
import * as moonLogic from './moonLogic'
|
import * as moonLogic from './moonLogic'
|
||||||
import * as moonValidation from './moonValidation'
|
import * as moonValidation from './moonValidation'
|
||||||
import * as diplomaticLogic from './diplomaticLogic'
|
import * as diplomaticLogic from './diplomaticLogic'
|
||||||
|
import * as resourceLogic from './resourceLogic'
|
||||||
|
import * as fleetStorageLogic from './fleetStorageLogic'
|
||||||
|
import * as officerLogic from './officerLogic'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算两个星球之间的距离
|
* 计算两个星球之间的距离
|
||||||
@@ -78,8 +81,9 @@ export const processTransportArrival = (
|
|||||||
targetPlanet: Planet | undefined,
|
targetPlanet: Planet | undefined,
|
||||||
player?: Player,
|
player?: Player,
|
||||||
allNpcs?: NPC[],
|
allNpcs?: NPC[],
|
||||||
locale: Locale = 'zh-CN'
|
locale: Locale = 'zh-CN',
|
||||||
): { success: boolean; reputationGain?: number } => {
|
storageCapacityBonus: number = 0
|
||||||
|
): { success: boolean; reputationGain?: number; overflow?: Resources } => {
|
||||||
// 检查是否是赠送任务
|
// 检查是否是赠送任务
|
||||||
if (mission.isGift && mission.giftTargetNpcId && player && allNpcs) {
|
if (mission.isGift && mission.giftTargetNpcId && player && allNpcs) {
|
||||||
const targetNpc = allNpcs.find(n => n.id === mission.giftTargetNpcId)
|
const targetNpc = allNpcs.find(n => n.id === mission.giftTargetNpcId)
|
||||||
@@ -101,13 +105,15 @@ export const processTransportArrival = (
|
|||||||
|
|
||||||
// 正常运输任务
|
// 正常运输任务
|
||||||
if (targetPlanet) {
|
if (targetPlanet) {
|
||||||
targetPlanet.resources.metal += mission.cargo.metal
|
// 使用安全添加函数,防止资源溢出
|
||||||
targetPlanet.resources.crystal += mission.cargo.crystal
|
const result = resourceLogic.addResourcesSafely(targetPlanet, mission.cargo, storageCapacityBonus)
|
||||||
targetPlanet.resources.deuterium += mission.cargo.deuterium
|
|
||||||
targetPlanet.resources.darkMatter += mission.cargo.darkMatter
|
|
||||||
mission.status = 'returning'
|
mission.status = 'returning'
|
||||||
mission.cargo = { metal: 0, crystal: 0, deuterium: 0, darkMatter: 0, energy: 0 }
|
|
||||||
return { success: true }
|
// 如果有溢出的资源,保留在cargo中返回给发送者
|
||||||
|
if (result.overflow.metal > 0 || result.overflow.crystal > 0 || result.overflow.deuterium > 0 || result.overflow.darkMatter > 0) {
|
||||||
|
mission.cargo = result.overflow
|
||||||
|
return { success: true, overflow: result.overflow }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mission.status = 'returning'
|
mission.status = 'returning'
|
||||||
mission.cargo = { metal: 0, crystal: 0, deuterium: 0, darkMatter: 0, energy: 0 }
|
mission.cargo = { metal: 0, crystal: 0, deuterium: 0, darkMatter: 0, energy: 0 }
|
||||||
@@ -178,10 +184,10 @@ export const processAttackArrival = async (
|
|||||||
})
|
})
|
||||||
targetPlanet.defense = battleLogic.repairDefense(defenseBeforeBattle, targetPlanet.defense) as Record<DefenseType, number>
|
targetPlanet.defense = battleLogic.repairDefense(defenseBeforeBattle, targetPlanet.defense) as Record<DefenseType, number>
|
||||||
|
|
||||||
// 扣除掠夺的资源
|
// 扣除掠夺的资源(防止下溢到负数)
|
||||||
targetPlanet.resources.metal -= battleResult.plunder.metal
|
targetPlanet.resources.metal = Math.max(0, targetPlanet.resources.metal - battleResult.plunder.metal)
|
||||||
targetPlanet.resources.crystal -= battleResult.plunder.crystal
|
targetPlanet.resources.crystal = Math.max(0, targetPlanet.resources.crystal - battleResult.plunder.crystal)
|
||||||
targetPlanet.resources.deuterium -= battleResult.plunder.deuterium
|
targetPlanet.resources.deuterium = Math.max(0, targetPlanet.resources.deuterium - battleResult.plunder.deuterium)
|
||||||
|
|
||||||
mission.status = 'returning'
|
mission.status = 'returning'
|
||||||
|
|
||||||
@@ -519,18 +525,28 @@ export const processSpyArrival = (
|
|||||||
/**
|
/**
|
||||||
* 处理部署任务到达
|
* 处理部署任务到达
|
||||||
*/
|
*/
|
||||||
export const processDeployArrival = (mission: FleetMission, targetPlanet: Planet | undefined, playerId: string): boolean => {
|
export const processDeployArrival = (
|
||||||
|
mission: FleetMission,
|
||||||
|
targetPlanet: Planet | undefined,
|
||||||
|
playerId: string,
|
||||||
|
technologies: Record<TechnologyType, number>
|
||||||
|
): { success: boolean; overflow?: Partial<Record<ShipType, number>> } => {
|
||||||
if (!targetPlanet || targetPlanet.ownerId !== playerId) {
|
if (!targetPlanet || targetPlanet.ownerId !== playerId) {
|
||||||
mission.status = 'returning'
|
mission.status = 'returning'
|
||||||
return false
|
return { success: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [shipType, count] of Object.entries(mission.fleet)) {
|
// 使用安全添加函数,防止舰队仓储溢出
|
||||||
targetPlanet.fleet[shipType as ShipType] += count
|
const result = fleetStorageLogic.addFleetSafely(targetPlanet, mission.fleet, technologies)
|
||||||
|
// 如果有溢出的舰船,保留在mission.fleet中返回给发送者
|
||||||
|
const hasOverflow = Object.keys(result.overflow).length > 0
|
||||||
|
if (hasOverflow) {
|
||||||
|
mission.fleet = result.overflow as Fleet
|
||||||
|
mission.status = 'returning'
|
||||||
|
return { success: true, overflow: result.overflow }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 部署任务直接完成,不返回
|
// 部署任务直接完成,不返回
|
||||||
return true
|
return { success: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -693,19 +709,19 @@ export const processDestroyArrival = (
|
|||||||
/**
|
/**
|
||||||
* 处理舰队任务返回
|
* 处理舰队任务返回
|
||||||
*/
|
*/
|
||||||
export const processFleetReturn = (mission: FleetMission, originPlanet: Planet): void => {
|
export const processFleetReturn = (
|
||||||
// 舰船返回
|
mission: FleetMission,
|
||||||
Object.entries(mission.fleet).forEach(([shipType, count]) => {
|
originPlanet: Planet,
|
||||||
if (count > 0) {
|
technologies: Record<TechnologyType, number>,
|
||||||
originPlanet.fleet[shipType as ShipType] += count
|
storageCapacityBonus: number
|
||||||
}
|
): void => {
|
||||||
})
|
// 舰船返回 - 使用安全添加函数
|
||||||
|
fleetStorageLogic.addFleetSafely(originPlanet, mission.fleet, technologies)
|
||||||
|
// 注意:如果舰队仓储溢出,超出部分会丢失(这是合理的惩罚)
|
||||||
|
|
||||||
// 资源返回(掠夺物或运输货物)
|
// 资源返回(掠夺物或运输货物)- 使用安全添加函数
|
||||||
originPlanet.resources.metal += mission.cargo.metal
|
resourceLogic.addResourcesSafely(originPlanet, mission.cargo, storageCapacityBonus)
|
||||||
originPlanet.resources.crystal += mission.cargo.crystal
|
// 注意:如果资源仓储溢出,超出部分会丢失(这是合理的惩罚)
|
||||||
originPlanet.resources.deuterium += mission.cargo.deuterium
|
|
||||||
originPlanet.resources.darkMatter += mission.cargo.darkMatter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -743,6 +759,9 @@ export const updateFleetMissions = async (
|
|||||||
|
|
||||||
// 获取所有星球列表(用于月球生成检查)
|
// 获取所有星球列表(用于月球生成检查)
|
||||||
const allPlanets = Array.from(planets.values())
|
const allPlanets = Array.from(planets.values())
|
||||||
|
// 计算军官加成(用于资源容量计算)
|
||||||
|
const bonuses = officerLogic.calculateActiveBonuses(attacker.officers, now)
|
||||||
|
const storageCapacityBonus = bonuses.storageCapacityBonus
|
||||||
|
|
||||||
// 使用 for...of 以支持 await
|
// 使用 for...of 以支持 await
|
||||||
for (const mission of missions) {
|
for (const mission of missions) {
|
||||||
@@ -755,7 +774,7 @@ export const updateFleetMissions = async (
|
|||||||
|
|
||||||
switch (mission.missionType) {
|
switch (mission.missionType) {
|
||||||
case MissionType.Transport:
|
case MissionType.Transport:
|
||||||
processTransportArrival(mission, targetPlanet, attacker, allNpcs)
|
processTransportArrival(mission, targetPlanet, attacker, allNpcs, locale, storageCapacityBonus)
|
||||||
break
|
break
|
||||||
|
|
||||||
case MissionType.Attack: {
|
case MissionType.Attack: {
|
||||||
@@ -808,8 +827,8 @@ export const updateFleetMissions = async (
|
|||||||
break
|
break
|
||||||
|
|
||||||
case MissionType.Deploy:
|
case MissionType.Deploy:
|
||||||
const deployed = processDeployArrival(mission, targetPlanet, attacker.id)
|
const deployed = processDeployArrival(mission, targetPlanet, attacker.id, attacker.technologies)
|
||||||
if (deployed) {
|
if (deployed.success && !deployed.overflow) {
|
||||||
completedMissions.push(mission.id)
|
completedMissions.push(mission.id)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -858,7 +877,7 @@ export const updateFleetMissions = async (
|
|||||||
if (mission.status === 'returning' && mission.returnTime && now >= mission.returnTime) {
|
if (mission.status === 'returning' && mission.returnTime && now >= mission.returnTime) {
|
||||||
// 舰队返回
|
// 舰队返回
|
||||||
if (originPlanet) {
|
if (originPlanet) {
|
||||||
processFleetReturn(mission, originPlanet)
|
processFleetReturn(mission, originPlanet, attacker.technologies, storageCapacityBonus)
|
||||||
}
|
}
|
||||||
completedMissions.push(mission.id)
|
completedMissions.push(mission.id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,26 @@ export const calculateMaxFleetStorage = (planet: Planet, technologies: Record<Te
|
|||||||
return maxStorage
|
return maxStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算建造队列中的舰船仓储使用量
|
||||||
|
* @param buildQueue 建造队列
|
||||||
|
* @returns 队列中舰船的仓储使用量
|
||||||
|
*/
|
||||||
|
export const calculateQueueFleetStorageUsage = (buildQueue: Array<{ type: string; itemType: string; quantity?: number }>): number => {
|
||||||
|
let queueUsage = 0
|
||||||
|
|
||||||
|
for (const item of buildQueue) {
|
||||||
|
if (item.type === 'ship') {
|
||||||
|
const shipType = item.itemType as ShipType
|
||||||
|
const quantity = item.quantity || 0
|
||||||
|
const shipConfig = SHIPS[shipType]
|
||||||
|
queueUsage += quantity * shipConfig.storageUsage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return queueUsage
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否有足够的舰队仓储空间建造新舰船
|
* 检查是否有足够的舰队仓储空间建造新舰船
|
||||||
* @param planet 星球对象
|
* @param planet 星球对象
|
||||||
@@ -67,10 +87,11 @@ export const hasEnoughFleetStorage = (
|
|||||||
technologies: Record<TechnologyType, number>
|
technologies: Record<TechnologyType, number>
|
||||||
): boolean => {
|
): boolean => {
|
||||||
const currentUsage = calculateFleetStorageUsage(planet.fleet)
|
const currentUsage = calculateFleetStorageUsage(planet.fleet)
|
||||||
|
const queueUsage = calculateQueueFleetStorageUsage(planet.buildQueue)
|
||||||
const maxStorage = calculateMaxFleetStorage(planet, technologies)
|
const maxStorage = calculateMaxFleetStorage(planet, technologies)
|
||||||
const newShipUsage = SHIPS[shipType].storageUsage * quantity
|
const newShipUsage = SHIPS[shipType].storageUsage * quantity
|
||||||
|
|
||||||
return currentUsage + newShipUsage <= maxStorage
|
return currentUsage + queueUsage + newShipUsage <= maxStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,3 +114,46 @@ export const getMaxBuildableShips = (planet: Planet, shipType: ShipType, technol
|
|||||||
|
|
||||||
return Math.floor(availableStorage / shipStorageUsage)
|
return Math.floor(availableStorage / shipStorageUsage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全地添加舰船到星球(会检查舰队仓储容量上限)
|
||||||
|
* @param planet 星球对象
|
||||||
|
* @param fleet 要添加的舰船
|
||||||
|
* @param technologies 玩家的科技等级
|
||||||
|
* @returns 实际添加的舰船数量和溢出的舰船数量
|
||||||
|
*/
|
||||||
|
export const addFleetSafely = (
|
||||||
|
planet: Planet,
|
||||||
|
fleet: Partial<Record<ShipType, number>>,
|
||||||
|
technologies: Record<TechnologyType, number>
|
||||||
|
): { added: Partial<Record<ShipType, number>>; overflow: Partial<Record<ShipType, number>> } => {
|
||||||
|
const maxStorage = calculateMaxFleetStorage(planet, technologies)
|
||||||
|
let currentUsage = calculateFleetStorageUsage(planet.fleet)
|
||||||
|
|
||||||
|
const added: Partial<Record<ShipType, number>> = {}
|
||||||
|
const overflow: Partial<Record<ShipType, number>> = {}
|
||||||
|
|
||||||
|
for (const [shipType, count] of Object.entries(fleet)) {
|
||||||
|
if (count <= 0) continue
|
||||||
|
|
||||||
|
const ship = shipType as ShipType
|
||||||
|
const shipStorageUsage = SHIPS[ship].storageUsage
|
||||||
|
|
||||||
|
// 计算可以添加多少艘(不超过容量上限)
|
||||||
|
const spaceAvailable = Math.max(0, maxStorage - currentUsage)
|
||||||
|
const maxCanAdd = shipStorageUsage > 0 ? Math.floor(spaceAvailable / shipStorageUsage) : count
|
||||||
|
const actuallyAdded = Math.min(count, maxCanAdd)
|
||||||
|
const overflowed = count - actuallyAdded
|
||||||
|
if (actuallyAdded > 0) {
|
||||||
|
planet.fleet[ship] = (planet.fleet[ship] || 0) + actuallyAdded
|
||||||
|
added[ship] = actuallyAdded
|
||||||
|
currentUsage += actuallyAdded * shipStorageUsage
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overflowed > 0) {
|
||||||
|
overflow[ship] = overflowed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { added, overflow }
|
||||||
|
}
|
||||||
|
|||||||
@@ -384,15 +384,16 @@ export const autoBuildNPCFleet = (npc: NPC): void => {
|
|||||||
|
|
||||||
if (!canBuild) continue
|
if (!canBuild) continue
|
||||||
|
|
||||||
// 根据难度和当前资源决定建造数量
|
// 根据难度和当前资源决定建造数量(防止除零)
|
||||||
const maxAffordable = Math.floor(
|
const metalAffordable = shipConfig.cost.metal > 0 ? planet.resources.metal / shipConfig.cost.metal : Infinity
|
||||||
Math.min(
|
const crystalAffordable = shipConfig.cost.crystal > 0 ? planet.resources.crystal / shipConfig.cost.crystal : Infinity
|
||||||
planet.resources.metal / shipConfig.cost.metal,
|
const deuteriumAffordable = shipConfig.cost.deuterium > 0 ? planet.resources.deuterium / shipConfig.cost.deuterium : Infinity
|
||||||
planet.resources.crystal / shipConfig.cost.crystal,
|
const darkMatterAffordable = shipConfig.cost.darkMatter > 0 ? planet.resources.darkMatter / shipConfig.cost.darkMatter : Infinity
|
||||||
planet.resources.deuterium / shipConfig.cost.deuterium,
|
|
||||||
shipConfig.cost.darkMatter > 0 ? planet.resources.darkMatter / shipConfig.cost.darkMatter : Infinity
|
const maxAffordable = Math.floor(Math.min(metalAffordable, crystalAffordable, deuteriumAffordable, darkMatterAffordable))
|
||||||
)
|
|
||||||
)
|
// 防止NaN或Infinity(如果所有成本都为0的极端情况)
|
||||||
|
if (!Number.isFinite(maxAffordable) || maxAffordable <= 0) continue
|
||||||
|
|
||||||
// 建造数量:简单1-5艘,中等5-10艘,困难10-20艘
|
// 建造数量:简单1-5艘,中等5-10艘,困难10-20艘
|
||||||
const buildCount = Math.min(maxAffordable, npc.difficulty === 'easy' ? 5 : npc.difficulty === 'medium' ? 10 : 20)
|
const buildCount = Math.min(maxAffordable, npc.difficulty === 'easy' ? 5 : npc.difficulty === 'medium' ? 10 : 20)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type { Planet, Resources, Officer, BuildingConfig, TechnologyConfig } fro
|
|||||||
import { OfficerType } from '@/types/game'
|
import { OfficerType } from '@/types/game'
|
||||||
import * as officerLogic from '@/logic/officerLogic'
|
import * as officerLogic from '@/logic/officerLogic'
|
||||||
import * as resourceLogic from '@/logic/resourceLogic'
|
import * as resourceLogic from '@/logic/resourceLogic'
|
||||||
|
import { scaleResources } from '@/utils/speed'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取特定等级的升级条件
|
* 获取特定等级的升级条件
|
||||||
@@ -93,11 +94,12 @@ export const checkRequirements = (
|
|||||||
* @param officers 玩家的军官对象
|
* @param officers 玩家的军官对象
|
||||||
* @returns 每小时各类资源的产量
|
* @returns 每小时各类资源的产量
|
||||||
*/
|
*/
|
||||||
export const getResourceProduction = (planet: Planet, officers: Record<OfficerType, Officer>): Resources => {
|
export const getResourceProduction = (planet: Planet, officers: Record<OfficerType, Officer>, resourceSpeed: number = 1): Resources => {
|
||||||
// 计算当前激活的军官加成
|
// 计算当前激活的军官加成
|
||||||
const bonuses = officerLogic.calculateActiveBonuses(officers, Date.now())
|
const bonuses = officerLogic.calculateActiveBonuses(officers, Date.now())
|
||||||
// 根据建筑等级和军官加成计算资源产量
|
// 根据建筑等级和军官加成计算资源产量
|
||||||
return resourceLogic.calculateResourceProduction(planet, bonuses)
|
const base = resourceLogic.calculateResourceProduction(planet, bonuses)
|
||||||
|
return scaleResources(base, resourceSpeed)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -194,6 +194,44 @@ export const addResources = (currentResources: Resources, amount: Resources): vo
|
|||||||
currentResources.darkMatter += amount.darkMatter
|
currentResources.darkMatter += amount.darkMatter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全地添加资源(会检查仓储容量上限)
|
||||||
|
* @param planet 星球对象
|
||||||
|
* @param amount 要添加的资源
|
||||||
|
* @param storageCapacityBonus 仓储容量加成
|
||||||
|
* @returns 实际添加的资源数量和溢出的资源数量
|
||||||
|
*/
|
||||||
|
export const addResourcesSafely = (
|
||||||
|
planet: Planet,
|
||||||
|
amount: Resources,
|
||||||
|
storageCapacityBonus: number
|
||||||
|
): { added: Resources; overflow: Resources } => {
|
||||||
|
const capacity = calculateResourceCapacity(planet, storageCapacityBonus)
|
||||||
|
|
||||||
|
const added: Resources = { metal: 0, crystal: 0, deuterium: 0, darkMatter: 0, energy: 0 }
|
||||||
|
const overflow: Resources = { metal: 0, crystal: 0, deuterium: 0, darkMatter: 0, energy: 0 }
|
||||||
|
|
||||||
|
// 处理每种资源
|
||||||
|
const resources: Array<keyof Resources> = ['metal', 'crystal', 'deuterium', 'darkMatter']
|
||||||
|
|
||||||
|
for (const resourceType of resources) {
|
||||||
|
const currentAmount = planet.resources[resourceType]
|
||||||
|
const amountToAdd = amount[resourceType]
|
||||||
|
const maxCapacity = capacity[resourceType]
|
||||||
|
|
||||||
|
// 计算可以添加的量(不超过容量上限)
|
||||||
|
const spaceAvailable = Math.max(0, maxCapacity - currentAmount)
|
||||||
|
const actuallyAdded = Math.min(amountToAdd, spaceAvailable)
|
||||||
|
const overflowed = amountToAdd - actuallyAdded
|
||||||
|
|
||||||
|
planet.resources[resourceType] += actuallyAdded
|
||||||
|
added[resourceType] = actuallyAdded
|
||||||
|
overflow[resourceType] = overflowed
|
||||||
|
}
|
||||||
|
|
||||||
|
return { added, overflow }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源产量详细信息(用于UI展示)
|
* 资源产量详细信息(用于UI展示)
|
||||||
*/
|
*/
|
||||||
@@ -249,7 +287,8 @@ export interface ConsumptionDetail {
|
|||||||
export const calculateProductionBreakdown = (
|
export const calculateProductionBreakdown = (
|
||||||
planet: Planet,
|
planet: Planet,
|
||||||
officers: Record<OfficerType, Officer>,
|
officers: Record<OfficerType, Officer>,
|
||||||
currentTime: number
|
currentTime: number,
|
||||||
|
resourceSpeed: number = 1
|
||||||
): ProductionBreakdown => {
|
): ProductionBreakdown => {
|
||||||
const metalMineLevel = planet.buildings[BuildingType.MetalMine] || 0
|
const metalMineLevel = planet.buildings[BuildingType.MetalMine] || 0
|
||||||
const crystalMineLevel = planet.buildings[BuildingType.CrystalMine] || 0
|
const crystalMineLevel = planet.buildings[BuildingType.CrystalMine] || 0
|
||||||
@@ -435,42 +474,56 @@ export const calculateProductionBreakdown = (
|
|||||||
|
|
||||||
const energyFinal = energyBase * (1 + totalEnergyBonus / 100)
|
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 {
|
return {
|
||||||
metal: {
|
metal: {
|
||||||
baseProduction: metalBase,
|
baseProduction: metalBase * speed,
|
||||||
buildingLevel: metalMineLevel,
|
buildingLevel: metalMineLevel,
|
||||||
buildingName: 'buildings.metalMine',
|
buildingName: 'buildings.metalMine',
|
||||||
bonuses: metalBonuses,
|
bonuses: scaleBonuses(metalBonuses),
|
||||||
finalProduction: metalFinal
|
finalProduction: metalFinal * speed
|
||||||
},
|
},
|
||||||
crystal: {
|
crystal: {
|
||||||
baseProduction: crystalBase,
|
baseProduction: crystalBase * speed,
|
||||||
buildingLevel: crystalMineLevel,
|
buildingLevel: crystalMineLevel,
|
||||||
buildingName: 'buildings.crystalMine',
|
buildingName: 'buildings.crystalMine',
|
||||||
bonuses: crystalBonuses,
|
bonuses: scaleBonuses(crystalBonuses),
|
||||||
finalProduction: crystalFinal
|
finalProduction: crystalFinal * speed
|
||||||
},
|
},
|
||||||
deuterium: {
|
deuterium: {
|
||||||
baseProduction: deuteriumBase,
|
baseProduction: deuteriumBase * speed,
|
||||||
buildingLevel: deuteriumSynthesizerLevel,
|
buildingLevel: deuteriumSynthesizerLevel,
|
||||||
buildingName: 'buildings.deuteriumSynthesizer',
|
buildingName: 'buildings.deuteriumSynthesizer',
|
||||||
bonuses: deuteriumBonuses,
|
bonuses: scaleBonuses(deuteriumBonuses),
|
||||||
finalProduction: deuteriumFinal
|
finalProduction: deuteriumFinal * speed
|
||||||
},
|
},
|
||||||
darkMatter: {
|
darkMatter: {
|
||||||
baseProduction: darkMatterBase,
|
baseProduction: darkMatterBase * speed,
|
||||||
buildingLevel: darkMatterCollectorLevel,
|
buildingLevel: darkMatterCollectorLevel,
|
||||||
buildingName: 'buildings.darkMatterCollector',
|
buildingName: 'buildings.darkMatterCollector',
|
||||||
bonuses: darkMatterBonuses,
|
bonuses: scaleBonuses(darkMatterBonuses),
|
||||||
finalProduction: darkMatterFinal
|
finalProduction: darkMatterFinal * speed
|
||||||
},
|
},
|
||||||
energy: {
|
energy: {
|
||||||
baseProduction: energyBase,
|
baseProduction: energyBase * speed,
|
||||||
buildingLevel: solarPlantLevel,
|
buildingLevel: solarPlantLevel,
|
||||||
buildingName: 'buildings.solarPlant',
|
buildingName: 'buildings.solarPlant',
|
||||||
bonuses: energyBonuses,
|
bonuses: scaleBonuses(energyBonuses),
|
||||||
finalProduction: energyFinal,
|
finalProduction: energyFinal * speed,
|
||||||
sources: energySources
|
sources: scaleSources(energySources)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,7 +531,7 @@ export const calculateProductionBreakdown = (
|
|||||||
/**
|
/**
|
||||||
* 计算能量消耗详细breakdown
|
* 计算能量消耗详细breakdown
|
||||||
*/
|
*/
|
||||||
export const calculateConsumptionBreakdown = (planet: Planet): ConsumptionBreakdown => {
|
export const calculateConsumptionBreakdown = (planet: Planet, resourceSpeed: number = 1): ConsumptionBreakdown => {
|
||||||
const metalMineLevel = planet.buildings[BuildingType.MetalMine] || 0
|
const metalMineLevel = planet.buildings[BuildingType.MetalMine] || 0
|
||||||
const crystalMineLevel = planet.buildings[BuildingType.CrystalMine] || 0
|
const crystalMineLevel = planet.buildings[BuildingType.CrystalMine] || 0
|
||||||
const deuteriumSynthesizerLevel = planet.buildings[BuildingType.DeuteriumSynthesizer] || 0
|
const deuteriumSynthesizerLevel = planet.buildings[BuildingType.DeuteriumSynthesizer] || 0
|
||||||
@@ -487,22 +540,24 @@ export const calculateConsumptionBreakdown = (planet: Planet): ConsumptionBreakd
|
|||||||
const crystalConsumption = crystalMineLevel * 10 * Math.pow(1.1, crystalMineLevel)
|
const crystalConsumption = crystalMineLevel * 10 * Math.pow(1.1, crystalMineLevel)
|
||||||
const deuteriumConsumption = deuteriumSynthesizerLevel * 15 * Math.pow(1.1, deuteriumSynthesizerLevel)
|
const deuteriumConsumption = deuteriumSynthesizerLevel * 15 * Math.pow(1.1, deuteriumSynthesizerLevel)
|
||||||
|
|
||||||
|
const speed = resourceSpeed
|
||||||
|
|
||||||
return {
|
return {
|
||||||
metalMine: {
|
metalMine: {
|
||||||
buildingLevel: metalMineLevel,
|
buildingLevel: metalMineLevel,
|
||||||
buildingName: 'buildings.metalMine',
|
buildingName: 'buildings.metalMine',
|
||||||
consumption: metalConsumption
|
consumption: metalConsumption * speed
|
||||||
},
|
},
|
||||||
crystalMine: {
|
crystalMine: {
|
||||||
buildingLevel: crystalMineLevel,
|
buildingLevel: crystalMineLevel,
|
||||||
buildingName: 'buildings.crystalMine',
|
buildingName: 'buildings.crystalMine',
|
||||||
consumption: crystalConsumption
|
consumption: crystalConsumption * speed
|
||||||
},
|
},
|
||||||
deuteriumSynthesizer: {
|
deuteriumSynthesizer: {
|
||||||
buildingLevel: deuteriumSynthesizerLevel,
|
buildingLevel: deuteriumSynthesizerLevel,
|
||||||
buildingName: 'buildings.deuteriumSynthesizer',
|
buildingName: 'buildings.deuteriumSynthesizer',
|
||||||
consumption: deuteriumConsumption
|
consumption: deuteriumConsumption * speed
|
||||||
},
|
},
|
||||||
total: metalConsumption + crystalConsumption + deuteriumConsumption
|
total: (metalConsumption + crystalConsumption + deuteriumConsumption) * speed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,6 +173,24 @@ export const calculateCurrentMissileCount = (defense: Partial<Record<DefenseType
|
|||||||
return interplanetaryMissiles + antiBallisticMissiles
|
return interplanetaryMissiles + antiBallisticMissiles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算建造队列中的导弹总数
|
||||||
|
*/
|
||||||
|
export const calculateQueueMissileCount = (buildQueue: Array<{ type: string; itemType: string; quantity?: number }>): number => {
|
||||||
|
let queueMissileCount = 0
|
||||||
|
|
||||||
|
for (const item of buildQueue) {
|
||||||
|
if (item.type === 'defense') {
|
||||||
|
const defenseType = item.itemType as DefenseType
|
||||||
|
if (defenseType === DefenseType.InterplanetaryMissile || defenseType === DefenseType.AntiBallisticMissile) {
|
||||||
|
queueMissileCount += item.quantity || 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return queueMissileCount
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查导弹容量限制
|
* 检查导弹容量限制
|
||||||
*/
|
*/
|
||||||
@@ -180,7 +198,8 @@ export const checkMissileSiloLimit = (
|
|||||||
defenseType: DefenseType,
|
defenseType: DefenseType,
|
||||||
currentDefense: Partial<Record<DefenseType, number>>,
|
currentDefense: Partial<Record<DefenseType, number>>,
|
||||||
buildings: Partial<Record<BuildingType, number>>,
|
buildings: Partial<Record<BuildingType, number>>,
|
||||||
quantity: number
|
quantity: number,
|
||||||
|
buildQueue?: Array<{ type: string; itemType: string; quantity?: number }>
|
||||||
): boolean => {
|
): boolean => {
|
||||||
// 只对导弹类型进行检查
|
// 只对导弹类型进行检查
|
||||||
if (defenseType !== DefenseType.InterplanetaryMissile && defenseType !== DefenseType.AntiBallisticMissile) {
|
if (defenseType !== DefenseType.InterplanetaryMissile && defenseType !== DefenseType.AntiBallisticMissile) {
|
||||||
@@ -189,7 +208,8 @@ export const checkMissileSiloLimit = (
|
|||||||
|
|
||||||
const maxCapacity = calculateMissileSiloCapacity(buildings)
|
const maxCapacity = calculateMissileSiloCapacity(buildings)
|
||||||
const currentCount = calculateCurrentMissileCount(currentDefense)
|
const currentCount = calculateCurrentMissileCount(currentDefense)
|
||||||
const newCount = currentCount + quantity
|
const queueCount = buildQueue ? calculateQueueMissileCount(buildQueue) : 0
|
||||||
|
const newCount = currentCount + queueCount + quantity
|
||||||
|
|
||||||
return newCount <= maxCapacity
|
return newCount <= maxCapacity
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export const validateDefenseBuild = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 导弹发射井容量限制
|
// 导弹发射井容量限制
|
||||||
if (!shipLogic.checkMissileSiloLimit(defenseType, planet.defense, planet.buildings, quantity)) {
|
if (!shipLogic.checkMissileSiloLimit(defenseType, planet.defense, planet.buildings, quantity, planet.buildQueue)) {
|
||||||
return { valid: false, reason: 'errors.missileSiloLimit' }
|
return { valid: false, reason: 'errors.missileSiloLimit' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
src/utils/speed.ts
Normal file
28
src/utils/speed.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import type { Resources } from '@/types/game'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按倍率缩放一个数值
|
||||||
|
* - 支持合法的 0(例如用于“暂停”)
|
||||||
|
*/
|
||||||
|
export const scaleNumber = (value: number, multiplier: number): number => value * multiplier
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按倍率缩放 Resources(常用于“每小时产量/消耗”等展示)
|
||||||
|
* - 支持合法的 0(例如用于“暂停”)
|
||||||
|
*/
|
||||||
|
export const scaleResources = (resources: Resources, multiplier: number): Resources => ({
|
||||||
|
metal: resources.metal * multiplier,
|
||||||
|
crystal: resources.crystal * multiplier,
|
||||||
|
deuterium: resources.deuterium * multiplier,
|
||||||
|
darkMatter: resources.darkMatter * multiplier,
|
||||||
|
energy: resources.energy * multiplier
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算游戏循环的间隔(毫秒)
|
||||||
|
* - multiplier <= 0 或非有限值时,回退到 baseMs,避免除 0
|
||||||
|
*/
|
||||||
|
export const getGameLoopIntervalMs = (multiplier: number, baseMs: number = 1000): number => {
|
||||||
|
if (!Number.isFinite(multiplier) || multiplier <= 0) return baseMs
|
||||||
|
return baseMs / multiplier
|
||||||
|
}
|
||||||
@@ -201,6 +201,7 @@
|
|||||||
import { Badge } from '@/components/ui/badge'
|
import { Badge } from '@/components/ui/badge'
|
||||||
import ResourceIcon from '@/components/ResourceIcon.vue'
|
import ResourceIcon from '@/components/ResourceIcon.vue'
|
||||||
import { formatNumber, getResourceColor } from '@/utils/format'
|
import { formatNumber, getResourceColor } from '@/utils/format'
|
||||||
|
import { scaleNumber } from '@/utils/speed'
|
||||||
import type { Planet } from '@/types/game'
|
import type { Planet } from '@/types/game'
|
||||||
import * as publicLogic from '@/logic/publicLogic'
|
import * as publicLogic from '@/logic/publicLogic'
|
||||||
import * as resourceLogic from '@/logic/resourceLogic'
|
import * as resourceLogic from '@/logic/resourceLogic'
|
||||||
@@ -209,25 +210,27 @@
|
|||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const { SHIPS } = useGameConfig()
|
const { SHIPS } = useGameConfig()
|
||||||
const planet = computed(() => gameStore.currentPlanet)
|
const planet = computed(() => gameStore.currentPlanet)
|
||||||
const production = computed(() => (planet.value ? publicLogic.getResourceProduction(planet.value, gameStore.player.officers) : null))
|
const production = computed(() =>
|
||||||
|
planet.value ? publicLogic.getResourceProduction(planet.value, gameStore.player.officers, gameStore.gameSpeed) : null
|
||||||
|
)
|
||||||
const capacity = computed(() => (planet.value ? publicLogic.getResourceCapacity(planet.value, gameStore.player.officers) : null))
|
const capacity = computed(() => (planet.value ? publicLogic.getResourceCapacity(planet.value, gameStore.player.officers) : null))
|
||||||
|
|
||||||
// 能量消耗
|
// 能量消耗
|
||||||
const energyConsumption = computed(() => {
|
const energyConsumption = computed(() => {
|
||||||
if (!planet.value) return 0
|
if (!planet.value) return 0
|
||||||
return resourceLogic.calculateEnergyConsumption(planet.value)
|
return scaleNumber(resourceLogic.calculateEnergyConsumption(planet.value), gameStore.gameSpeed)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 资源产量详细breakdown
|
// 资源产量详细breakdown
|
||||||
const productionBreakdown = computed(() => {
|
const productionBreakdown = computed(() => {
|
||||||
if (!planet.value) return null
|
if (!planet.value) return null
|
||||||
return resourceLogic.calculateProductionBreakdown(planet.value, gameStore.player.officers, Date.now())
|
return resourceLogic.calculateProductionBreakdown(planet.value, gameStore.player.officers, Date.now(), gameStore.gameSpeed)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 资源消耗详细breakdown
|
// 资源消耗详细breakdown
|
||||||
const consumptionBreakdown = computed(() => {
|
const consumptionBreakdown = computed(() => {
|
||||||
if (!planet.value) return null
|
if (!planet.value) return null
|
||||||
return resourceLogic.calculateConsumptionBreakdown(planet.value)
|
return resourceLogic.calculateConsumptionBreakdown(planet.value, gameStore.gameSpeed)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 资源类型配置
|
// 资源类型配置
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<div class="flex items-center gap-2 sm:gap-4 w-full sm:w-auto">
|
<div class="flex items-center gap-2 sm:gap-4 w-full sm:w-auto">
|
||||||
<div class="flex items-center gap-2 flex-1 sm:flex-initial">
|
<div class="flex items-center gap-2 flex-1 sm:flex-initial">
|
||||||
<Button @click="decreaseSpeed" variant="outline" size="sm" :disabled="gameStore.gameSpeed <= 0.5">-</Button>
|
<Button @click="decreaseSpeed" variant="outline" size="sm" :disabled="gameStore.gameSpeed <= 0.5">-</Button>
|
||||||
<span class="min-w-[60px] text-center font-medium">{{ gameStore.gameSpeed || 1 }}x</span>
|
<span class="min-w-[60px] text-center font-medium">{{ gameStore.gameSpeed }}x</span>
|
||||||
<Button @click="increaseSpeed" variant="outline" size="sm" :disabled="gameStore.gameSpeed >= 10">+</Button>
|
<Button @click="increaseSpeed" variant="outline" size="sm" :disabled="gameStore.gameSpeed >= 10">+</Button>
|
||||||
</div>
|
</div>
|
||||||
<Button @click="resetSpeed" variant="ghost" size="sm">{{ t('settings.reset') }}</Button>
|
<Button @click="resetSpeed" variant="ghost" size="sm">{{ t('settings.reset') }}</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user