Files
text-adventure-game/store/game.js
Claude cef974d94f feat: 优化游戏体验和系统平衡性
- 修复商店物品名称显示问题,添加堆叠物品出售数量选择
- 自动战斗状态持久化,战斗结束显示"寻找中"状态
- 战斗日志显示经验获取详情(战斗经验、武器经验)
- 技能进度条显示当前/最大经验值
- 阅读自动解锁技能并持续获得阅读经验,背包可直接阅读
- 优化训练平衡:时长60秒,经验5点/秒,耐力消耗降低
- 实现自然回复系统:基于体质回复HP/耐力,休息提供3倍加成
- 战斗和训练时不进行自然回复

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 19:40:55 +08:00

108 lines
2.1 KiB
JavaScript

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,
crafting: 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 isSearching = 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
isSearching.value = false
activeTasks.value = []
negativeStatus.value = []
marketPrices.value = {
lastRefreshDay: 1,
prices: {}
}
currentEvent.value = null
}
return {
currentTab,
drawerState,
logs,
gameTime,
inCombat,
combatState,
autoCombat,
isSearching,
activeTasks,
negativeStatus,
marketPrices,
currentEvent,
addLog,
resetGame
}
})