feat: 初始化项目结构与核心功能

引入项目基础目录结构,包含多语言支持、主要页面与组件、核心游戏逻辑、UI 组件库、加密与本地持久化、自动化 Docker 构建流程、GitHub issue 模板(中英文)、README(中英文)、LICENSE 及开发配置文件。实现 OGame 单机版主要功能模块,为后续开发和扩展奠定基础。
This commit is contained in:
谦君
2025-12-11 14:49:25 +08:00
commit 705ee8c3db
178 changed files with 17258 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import { defineStore } from 'pinia'
import type { BuildingType, TechnologyType, ShipType, DefenseType } from '@/types/game'
export type DetailDialogType = 'building' | 'technology' | 'ship' | 'defense'
export interface DetailDialogState {
isOpen: boolean
type: DetailDialogType | null
itemType: BuildingType | TechnologyType | ShipType | DefenseType | null
currentLevel?: number // 用于建筑和科技
}
export const useDetailDialogStore = defineStore('detailDialog', {
state: (): DetailDialogState => ({
isOpen: false,
type: null,
itemType: null,
currentLevel: undefined
}),
actions: {
openBuilding(buildingType: BuildingType, currentLevel: number) {
this.isOpen = true
this.type = 'building'
this.itemType = buildingType
this.currentLevel = currentLevel
},
openTechnology(technologyType: TechnologyType, currentLevel: number) {
this.isOpen = true
this.type = 'technology'
this.itemType = technologyType
this.currentLevel = currentLevel
},
openShip(shipType: ShipType) {
this.isOpen = true
this.type = 'ship'
this.itemType = shipType
this.currentLevel = undefined
},
openDefense(defenseType: DefenseType) {
this.isOpen = true
this.type = 'defense'
this.itemType = defenseType
this.currentLevel = undefined
},
close() {
this.isOpen = false
this.type = null
this.itemType = null
this.currentLevel = undefined
}
}
})

47
src/stores/gameStore.ts Normal file
View File

@@ -0,0 +1,47 @@
import { defineStore } from 'pinia'
import type { Planet, Player, BuildQueueItem, FleetMission, BattleResult, SpyReport, Officer } 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[]
} as Player,
currentPlanetId: '',
isDark: '',
locale: 'zh-CN' as Locale,
sidebarCollapsed: window.innerWidth < 1024 ? false : true,
universePlanets: {} as Record<string, Planet>
}),
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)
}
}
})