mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
fix: 优化NPC冷却与成长平衡及多语言提示
为NPC初始化和数据迁移时增加侦查/攻击冷却的随机延迟,避免所有NPC同时行动。调整NPC成长难度参数,降低前期NPC威胁,提升平滑度。修正多语言包中侦查被发现提示内容。优化舰队警报弹窗滚动体验。
This commit is contained in:
12
src/App.vue
12
src/App.vue
@@ -1136,6 +1136,11 @@
|
||||
|
||||
// 这是NPC的星球
|
||||
if (!npcMap.has(planet.ownerId)) {
|
||||
// 为每个NPC设置随机的初始冷却时间,避免所有NPC同时行动
|
||||
const now = Date.now()
|
||||
const randomSpyOffset = Math.random() * 240 * 1000 // 0-4分钟的随机延迟
|
||||
const randomAttackOffset = Math.random() * 480 * 1000 // 0-8分钟的随机延迟
|
||||
|
||||
npcMap.set(planet.ownerId, {
|
||||
id: planet.ownerId,
|
||||
name: `NPC-${planet.ownerId.substring(0, 8)}`,
|
||||
@@ -1145,8 +1150,8 @@
|
||||
relations: {}, // 外交关系
|
||||
allies: [], // 盟友列表
|
||||
enemies: [], // 敌人列表
|
||||
lastSpyTime: 0, // 上次侦查时间
|
||||
lastAttackTime: 0, // 上次攻击时间
|
||||
lastSpyTime: now - randomSpyOffset, // 设置随机的上次侦查时间
|
||||
lastAttackTime: now - randomAttackOffset, // 设置随机的上次攻击时间
|
||||
fleetMissions: [], // 舰队任务
|
||||
playerSpyReports: {} // 对玩家的侦查报告
|
||||
})
|
||||
@@ -1224,7 +1229,8 @@
|
||||
}
|
||||
|
||||
const now = Date.now()
|
||||
const allPlanets = Object.values(universeStore.planets)
|
||||
// 合并玩家星球和NPC星球到allPlanets(NPC需要能够侦查和攻击玩家星球)
|
||||
const allPlanets = [...gameStore.player.planets, ...Object.values(universeStore.planets)]
|
||||
|
||||
// 更新每个NPC的行为
|
||||
npcStore.npcs.forEach(npc => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div v-if="alerts.length > 0" class="bg-destructive/10 border-b border-destructive/20">
|
||||
<div class="px-4 sm:px-6 py-2 space-y-2">
|
||||
<div class="px-4 sm:px-6 py-2 space-y-2 max-h-[230px] overflow-y-auto">
|
||||
<div
|
||||
v-for="alert in alerts"
|
||||
:key="alert.id"
|
||||
|
||||
@@ -866,7 +866,7 @@ export default {
|
||||
ships: 'Schiffe',
|
||||
spiedBy: 'Ausspioniert von',
|
||||
attackedBy: 'Angegriffen von',
|
||||
detectionSuccess: 'Spionage entdeckt',
|
||||
detectionSuccess: 'Du hast feindliche Spionage entdeckt!',
|
||||
detectionFailed: 'Spionage nicht entdeckt',
|
||||
npcSpiedYourPlanet: 'NPC hat deinen Planeten ausspioniert',
|
||||
npcAttackedYourPlanet: 'NPC hat deinen Planeten angegriffen'
|
||||
|
||||
@@ -655,7 +655,7 @@ export default {
|
||||
spiedNotificationDetails: 'Spied Notification Details',
|
||||
spyDetected: 'Spy Detected',
|
||||
detectionResult: 'Detection Result',
|
||||
detectionSuccess: 'Your spy probe was detected!',
|
||||
detectionSuccess: 'You detected the enemy spy!',
|
||||
spiedNotificationMessage: '{npc} attempted to spy on your planet {planet}',
|
||||
spiedNotificationTip: 'Consider increasing your defense or counter-attacking if this NPC is hostile',
|
||||
viewInGalaxy: 'View in Galaxy',
|
||||
|
||||
@@ -856,7 +856,7 @@ export default {
|
||||
ships: '隻',
|
||||
spiedBy: '偵察された',
|
||||
attackedBy: '攻撃された',
|
||||
detectionSuccess: '偵察が発見された',
|
||||
detectionSuccess: '敵の偵察を発見した!',
|
||||
detectionFailed: '偵察が発見されなかった',
|
||||
npcSpiedYourPlanet: 'NPCがあなたの惑星を偵察しました',
|
||||
npcAttackedYourPlanet: 'NPCがあなたの惑星を攻撃しました'
|
||||
|
||||
@@ -857,7 +857,7 @@ export default {
|
||||
ships: '척',
|
||||
spiedBy: '정찰당함',
|
||||
attackedBy: '공격당함',
|
||||
detectionSuccess: '정찰 발견됨',
|
||||
detectionSuccess: '적의 정찰을 발견했습니다!',
|
||||
detectionFailed: '정찰 미발견',
|
||||
npcSpiedYourPlanet: 'NPC가 당신의 행성을 정찰했습니다',
|
||||
npcAttackedYourPlanet: 'NPC가 당신의 행성을 공격했습니다'
|
||||
|
||||
@@ -864,7 +864,7 @@ export default {
|
||||
ships: 'кораблей',
|
||||
spiedBy: 'Разведан',
|
||||
attackedBy: 'Атакован',
|
||||
detectionSuccess: 'Разведка обнаружена',
|
||||
detectionSuccess: 'Вы обнаружили вражескую разведку!',
|
||||
detectionFailed: 'Разведка не обнаружена',
|
||||
npcSpiedYourPlanet: 'NPC разведал вашу планету',
|
||||
npcAttackedYourPlanet: 'NPC атаковал вашу планету'
|
||||
|
||||
@@ -650,7 +650,7 @@ export default {
|
||||
spiedNotificationDetails: '被侦查通知详情',
|
||||
spyDetected: '侦查被发现',
|
||||
detectionResult: '检测结果',
|
||||
detectionSuccess: '你的侦查探测被发现了!',
|
||||
detectionSuccess: '你发现了敌方侦查!',
|
||||
spiedNotificationMessage: '{npc}试图侦查你的星球{planet}',
|
||||
spiedNotificationTip: '考虑增强防御或反击,如果这个NPC对你有敌意',
|
||||
viewInGalaxy: '在星系中查看',
|
||||
|
||||
@@ -857,7 +857,7 @@ export default {
|
||||
ships: '艘艦船',
|
||||
spiedBy: '被偵查',
|
||||
attackedBy: '被攻擊',
|
||||
detectionSuccess: '偵查被發現',
|
||||
detectionSuccess: '你發現了敵方偵查!',
|
||||
detectionFailed: '偵查未被發現',
|
||||
npcSpiedYourPlanet: 'NPC偵查了你的星球',
|
||||
npcAttackedYourPlanet: 'NPC攻擊了你的星球'
|
||||
|
||||
@@ -23,25 +23,25 @@ export interface NPCGrowthGameState {
|
||||
// NPC成长配置(旧版,保留用于兼容)
|
||||
export const NPC_GROWTH_CONFIG = {
|
||||
easy: {
|
||||
powerRatio: 1.0, // 实力比例(相对玩家) - 提升到1.0,与玩家势均力敌
|
||||
powerRatio: 0.6, // 实力比例(相对玩家)
|
||||
checkInterval: 300, // 检查间隔(秒) - 5分钟
|
||||
resourceGrowthRate: 1.3, // 资源增长速率系数 - 大幅提升
|
||||
buildingGrowthSpeed: 1.0, // 建筑升级速度系数
|
||||
techGrowthSpeed: 1.0 // 科技研究速度系数
|
||||
resourceGrowthRate: 0.5, // 资源增长速率系数
|
||||
buildingGrowthSpeed: 0.5, // 建筑升级速度系数
|
||||
techGrowthSpeed: 0.5 // 科技研究速度系数
|
||||
},
|
||||
medium: {
|
||||
powerRatio: 1.5, // 提升到1.5,超越玩家
|
||||
powerRatio: 0.8,
|
||||
checkInterval: 180, // 3分钟
|
||||
resourceGrowthRate: 1.8, // 大幅提升资源增长
|
||||
buildingGrowthSpeed: 1.5,
|
||||
techGrowthSpeed: 1.5
|
||||
resourceGrowthRate: 0.8,
|
||||
buildingGrowthSpeed: 0.8,
|
||||
techGrowthSpeed: 0.8
|
||||
},
|
||||
hard: {
|
||||
powerRatio: 2.0, // 提升到2.0,远超玩家
|
||||
powerRatio: 1.1,
|
||||
checkInterval: 120, // 2分钟
|
||||
resourceGrowthRate: 2.5, // 极高资源增长
|
||||
buildingGrowthSpeed: 2.0,
|
||||
techGrowthSpeed: 2.0
|
||||
resourceGrowthRate: 1.2,
|
||||
buildingGrowthSpeed: 1.0,
|
||||
techGrowthSpeed: 1.0
|
||||
}
|
||||
} as const
|
||||
|
||||
@@ -61,58 +61,58 @@ export const calculateDynamicDifficulty = (playerPoints: number): DynamicDifficu
|
||||
// 积分区间和对应的难度参数
|
||||
if (playerPoints < 1000) {
|
||||
// 新手期:0-1,000分
|
||||
// NPC保持50-70%实力,给予发展空间但保持挑战
|
||||
const ratio = 0.5 + (playerPoints / 1000) * 0.2
|
||||
// NPC保持30-50%实力,给予充分发展空间,但资源增长速度加快
|
||||
const ratio = 0.3 + (playerPoints / 1000) * 0.2
|
||||
return {
|
||||
powerRatio: ratio,
|
||||
checkInterval: 300, // 5分钟
|
||||
resourceGrowthRate: 1.2, // 提升资源增长,确保NPC快速发育
|
||||
buildingGrowthSpeed: 0.8,
|
||||
techGrowthSpeed: 0.8
|
||||
resourceGrowthRate: 0.8, // 从0.4提升到0.8,确保NPC有足够资源发育
|
||||
buildingGrowthSpeed: 0.6, // 从0.4提升到0.6
|
||||
techGrowthSpeed: 0.6 // 从0.4提升到0.6
|
||||
}
|
||||
} else if (playerPoints < 5000) {
|
||||
// 初级期:1,000-5,000分
|
||||
// NPC保持70-110%实力,快速追赶玩家
|
||||
const ratio = 0.7 + ((playerPoints - 1000) / 4000) * 0.4
|
||||
// NPC保持50-70%实力,逐渐增加挑战
|
||||
const ratio = 0.5 + ((playerPoints - 1000) / 4000) * 0.2
|
||||
return {
|
||||
powerRatio: ratio,
|
||||
checkInterval: 240, // 4分钟
|
||||
resourceGrowthRate: 1.5, // 大幅提升资源增长速度
|
||||
buildingGrowthSpeed: 1.2,
|
||||
techGrowthSpeed: 1.2
|
||||
resourceGrowthRate: 1.0, // 从0.6提升到1.0,与玩家资源产出相当
|
||||
buildingGrowthSpeed: 0.8, // 从0.6提升到0.8
|
||||
techGrowthSpeed: 0.8 // 从0.6提升到0.8
|
||||
}
|
||||
} else if (playerPoints < 20000) {
|
||||
// 中级期:5,000-20,000分
|
||||
// NPC保持110-150%实力,形成强大威胁
|
||||
const ratio = 1.1 + ((playerPoints - 5000) / 15000) * 0.4
|
||||
// NPC保持70-90%实力,持续挑战
|
||||
const ratio = 0.7 + ((playerPoints - 5000) / 15000) * 0.2
|
||||
return {
|
||||
powerRatio: ratio,
|
||||
checkInterval: 180, // 3分钟
|
||||
resourceGrowthRate: 1.8, // 极大幅提升资源增长
|
||||
buildingGrowthSpeed: 1.5,
|
||||
techGrowthSpeed: 1.5
|
||||
resourceGrowthRate: 0.8,
|
||||
buildingGrowthSpeed: 0.8,
|
||||
techGrowthSpeed: 0.8
|
||||
}
|
||||
} else if (playerPoints < 50000) {
|
||||
// 高级期:20,000-50,000分
|
||||
// NPC保持150-200%实力,远超玩家
|
||||
const ratio = 1.5 + ((playerPoints - 20000) / 30000) * 0.5
|
||||
// NPC保持90-110%实力,与玩家势均力敌
|
||||
const ratio = 0.9 + ((playerPoints - 20000) / 30000) * 0.2
|
||||
return {
|
||||
powerRatio: ratio,
|
||||
checkInterval: 150, // 2.5分钟
|
||||
resourceGrowthRate: 2.2, // 极高资源增长
|
||||
buildingGrowthSpeed: 1.8,
|
||||
techGrowthSpeed: 1.8
|
||||
resourceGrowthRate: 1.0,
|
||||
buildingGrowthSpeed: 1.0,
|
||||
techGrowthSpeed: 1.0
|
||||
}
|
||||
} else {
|
||||
// 专家期:50,000+分
|
||||
// NPC保持200-250%实力,成为超强对手
|
||||
const ratio = Math.min(2.5, 2.0 + ((playerPoints - 50000) / 50000) * 0.5)
|
||||
// NPC保持110-130%实力,超越玩家
|
||||
const ratio = Math.min(1.3, 1.1 + ((playerPoints - 50000) / 50000) * 0.2)
|
||||
return {
|
||||
powerRatio: ratio,
|
||||
checkInterval: 120, // 2分钟
|
||||
resourceGrowthRate: 2.5, // 极高的资源增长速度
|
||||
buildingGrowthSpeed: 2.0,
|
||||
techGrowthSpeed: 2.0
|
||||
resourceGrowthRate: 1.2,
|
||||
buildingGrowthSpeed: 1.2,
|
||||
techGrowthSpeed: 1.2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,13 +68,18 @@ export const migrateGameData = (): void => {
|
||||
|
||||
// 修复NPC数据(确保所有必需字段都存在)
|
||||
if (oldData.npcs && Array.isArray(oldData.npcs)) {
|
||||
const now = Date.now()
|
||||
oldData.npcs.forEach((npc: NPC) => {
|
||||
// 确保NPC有必需的时间字段
|
||||
if (npc.lastSpyTime === undefined) {
|
||||
npc.lastSpyTime = 0
|
||||
// 确保NPC有必需的时间字段,并设置随机冷却避免同时行动
|
||||
if (npc.lastSpyTime === undefined || npc.lastSpyTime === 0) {
|
||||
// 0-4分钟的随机延迟
|
||||
const randomSpyOffset = Math.random() * 240 * 1000
|
||||
npc.lastSpyTime = now - randomSpyOffset
|
||||
}
|
||||
if (npc.lastAttackTime === undefined) {
|
||||
npc.lastAttackTime = 0
|
||||
if (npc.lastAttackTime === undefined || npc.lastAttackTime === 0) {
|
||||
// 0-8分钟的随机延迟
|
||||
const randomAttackOffset = Math.random() * 480 * 1000
|
||||
npc.lastAttackTime = now - randomAttackOffset
|
||||
}
|
||||
// 确保NPC有必需的数组字段
|
||||
if (!npc.fleetMissions) {
|
||||
|
||||
Reference in New Issue
Block a user