Initial commit: Text Adventure Game

Features:
- Combat system with AP/EP hit calculation and three-layer defense
- Auto-combat/farming mode
- Item system with stacking support
- Skill system with levels, milestones, and parent skill sync
- Shop system with dynamic pricing
- Inventory management with bulk selling
- Event system
- Game loop with offline earnings
- Save/Load system

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-01-21 17:13:51 +08:00
commit cb412544e9
90 changed files with 17149 additions and 0 deletions

103
store/game.js Normal file
View File

@@ -0,0 +1,103 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useGameStore = defineStore('game', () => {
// 当前标签页
const currentTab = ref('status')
// 抽屉状态
const drawerState = ref({
inventory: false,
event: false,
shop: false
})
// 日志
const logs = ref([])
// 游戏时间
const gameTime = ref({
day: 1,
hour: 8,
minute: 0,
totalMinutes: 480
})
// 战斗状态
const inCombat = ref(false)
const combatState = ref(null)
const autoCombat = ref(false) // 自动战斗模式
// 活动任务
const activeTasks = ref([])
// 负面状态
const negativeStatus = ref([])
// 市场价格
const marketPrices = ref({
lastRefreshDay: 1,
prices: {}
})
// 当前事件
const currentEvent = ref(null)
// 添加日志
function addLog(message, type = 'info') {
const time = `${String(gameTime.value.hour).padStart(2, '0')}:${String(gameTime.value.minute).padStart(2, '0')}`
logs.value.push({
id: Date.now(),
time,
message,
type
})
// 限制日志数量
if (logs.value.length > 200) {
logs.value.shift()
}
}
// 重置游戏状态
function resetGame() {
currentTab.value = 'status'
drawerState.value = {
inventory: false,
event: false,
shop: false
}
logs.value = []
gameTime.value = {
day: 1,
hour: 8,
minute: 0,
totalMinutes: 480
}
inCombat.value = false
combatState.value = null
autoCombat.value = false
activeTasks.value = []
negativeStatus.value = []
marketPrices.value = {
lastRefreshDay: 1,
prices: {}
}
currentEvent.value = null
}
return {
currentTab,
drawerState,
logs,
gameTime,
inCombat,
combatState,
autoCombat,
activeTasks,
negativeStatus,
marketPrices,
currentEvent,
addLog,
resetGame
}
})

113
store/player.js Normal file
View File

@@ -0,0 +1,113 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
export const usePlayerStore = defineStore('player', () => {
// 基础属性
const baseStats = ref({
strength: 10, // 力量
agility: 8, // 敏捷
dexterity: 8, // 灵巧
intuition: 10, // 智力
vitality: 10 // 体质(影响HP)
})
// 当前资源
const currentStats = ref({
health: 100,
maxHealth: 100,
stamina: 100,
maxStamina: 100,
sanity: 100,
maxSanity: 100
})
// 主等级
const level = ref({
current: 1,
exp: 0,
maxExp: 100
})
// 技能
const skills = ref({})
// 装备
const equipment = ref({
weapon: null,
armor: null,
shield: null,
accessory: null
})
// 背包
const inventory = ref([])
// 货币(以铜币为单位)
const currency = ref({
copper: 0
})
// 当前位置
const currentLocation = ref('camp')
// 标记
const flags = ref({})
// 计算属性:总货币
const totalCurrency = computed(() => {
return {
gold: Math.floor(currency.value.copper / 10000),
silver: Math.floor((currency.value.copper % 10000) / 100),
copper: currency.value.copper % 100
}
})
// 重置玩家数据
function resetPlayer() {
baseStats.value = {
strength: 10,
agility: 8,
dexterity: 8,
intuition: 10,
vitality: 10
}
currentStats.value = {
health: 100,
maxHealth: 100,
stamina: 100,
maxStamina: 100,
sanity: 100,
maxSanity: 100
}
level.value = {
current: 1,
exp: 0,
maxExp: 100
}
skills.value = {}
equipment.value = {
weapon: null,
armor: null,
shield: null,
accessory: null
}
inventory.value = []
currency.value = { copper: 0 }
currentLocation.value = 'camp'
flags.value = {}
}
return {
baseStats,
currentStats,
level,
skills,
equipment,
inventory,
currency,
totalCurrency,
currentLocation,
flags,
resetPlayer
}
})