mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
重构并精简了部分UI组件,移除冗余弹窗与详情组件,新增NPC相关逻辑(npcBehaviorLogic、npcGrowthLogic、npcStore等)及外交逻辑(diplomaticLogic、DiplomacyView)。完善分页、标签、复选框等通用UI组件。优化战报弹窗,调整README下载链接为相对路径,修复部分国际化内容。
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import type { Planet, Player, BuildQueueItem, FleetMission, BattleResult, SpyReport, Officer, SpiedNotification, NPCActivityNotification, IncomingFleetAlert } from '@/types/game'
|
|
import { TechnologyType, OfficerType } from '@/types/game'
|
|
import type { Locale } from '@/locales'
|
|
import pkg from '../../package.json'
|
|
import { encryptData, decryptData } from '@/utils/crypto'
|
|
|
|
export const useGameStore = defineStore('game', {
|
|
state: () => ({
|
|
gameTime: Date.now(),
|
|
isPaused: false,
|
|
player: {
|
|
id: 'player1',
|
|
name: '',
|
|
planets: [] as Planet[],
|
|
technologies: {} as Record<TechnologyType, number>,
|
|
officers: {} as Record<OfficerType, Officer>,
|
|
researchQueue: [] as BuildQueueItem[],
|
|
fleetMissions: [] as FleetMission[],
|
|
battleReports: [] as BattleResult[],
|
|
spyReports: [] as SpyReport[],
|
|
spiedNotifications: [] as SpiedNotification[],
|
|
npcActivityNotifications: [] as NPCActivityNotification[],
|
|
missionReports: [],
|
|
incomingFleetAlerts: [] as IncomingFleetAlert[],
|
|
giftNotifications: [],
|
|
giftRejectedNotifications: [],
|
|
points: 0
|
|
} as Player,
|
|
currentPlanetId: '',
|
|
isDark: '',
|
|
locale: 'zh-CN' as Locale
|
|
}),
|
|
getters: {
|
|
currentPlanet(): Planet | undefined {
|
|
return this.player.planets.find(p => p.id === this.currentPlanetId)
|
|
},
|
|
getMoonForPlanet(): (planetId: string) => Planet | undefined {
|
|
return (planetId: string) => {
|
|
return this.player.planets.find(p => p.parentPlanetId === planetId && p.isMoon)
|
|
}
|
|
}
|
|
},
|
|
persist: {
|
|
key: pkg.name,
|
|
storage: localStorage,
|
|
serializer: {
|
|
serialize: state => encryptData(state),
|
|
deserialize: value => decryptData(value)
|
|
}
|
|
}
|
|
})
|