feat: 实现游戏核心系统和UI组件

核心系统:
- combatSystem: 战斗逻辑、伤害计算、战斗状态管理
- skillSystem: 技能系统、技能解锁、经验值、里程碑
- taskSystem: 任务系统、任务类型、任务执行和完成
- eventSystem: 事件系统、随机事件处理
- environmentSystem: 环境系统、时间流逝、区域效果
- levelingSystem: 升级系统、属性成长
- soundSystem: 音效系统

配置文件:
- enemies: 敌人配置、掉落表
- events: 事件配置、事件效果
- items: 物品配置、装备属性
- locations: 地点配置、探索事件
- skills: 技能配置、技能树

UI组件:
- CraftingDrawer: 制造界面
- InventoryDrawer: 背包界面
- 其他UI优化和动画

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-01-23 16:20:10 +08:00
parent 021f6a54f5
commit 16223c89a5
25 changed files with 2731 additions and 318 deletions

View File

@@ -13,6 +13,7 @@ import { processEnvironmentExp, processEnvironmentEffects } from './environmentS
import { checkScheduledEvents } from './eventSystem.js'
import { addSkillExp } from './skillSystem.js'
import { addItemToInventory } from './itemSystem.js'
import { addExp, calculateCombatExp } from './levelingSystem.js'
// 游戏循环定时器
let gameLoopInterval = null
@@ -196,24 +197,14 @@ export function handleCombatVictory(gameStore, playerStore, combatResult) {
// 添加日志
gameStore.addLog(`战胜了 ${enemy.name}!`, 'reward')
// 给予经验值
// 给予经验值 (使用新的等级系统)
if (enemy.expReward) {
playerStore.level.exp += enemy.expReward
// 检查升级
const maxExp = playerStore.level.maxExp
if (playerStore.level.exp >= maxExp) {
playerStore.level.current++
playerStore.level.exp -= maxExp
playerStore.level.maxExp = Math.floor(playerStore.level.maxExp * 1.5)
gameStore.addLog(`升级了! 等级: ${playerStore.level.current}`, 'reward')
// 升级恢复状态
playerStore.currentStats.health = playerStore.currentStats.maxHealth
playerStore.currentStats.stamina = playerStore.currentStats.maxStamina
playerStore.currentStats.sanity = playerStore.currentStats.maxSanity
}
const adjustedExp = calculateCombatExp(
enemy.level || 1,
playerStore.level.current,
enemy.expReward
)
addExp(playerStore, gameStore, adjustedExp)
}
// 给予武器技能经验奖励
@@ -374,6 +365,24 @@ function processDrops(gameStore, playerStore, drops) {
* @param {Object} rewards - 奖励
*/
function handleTaskCompletion(gameStore, playerStore, task, rewards) {
// 处理制造任务
if (task.type === 'crafting') {
if (rewards.success !== false && rewards.craftedItem) {
// 制造成功,添加物品到背包
const { completeCrafting } = require('./craftingSystem.js')
const result = completeCrafting(gameStore, playerStore, task, rewards)
if (result.success) {
gameStore.addLog(result.message, 'reward')
} else if (result.failed) {
gameStore.addLog(result.message, 'warning')
}
} else if (rewards.success === false) {
// 制造失败
gameStore.addLog('制造失败,材料已消耗', 'warning')
}
return
}
// 应用货币奖励
if (rewards.currency) {
playerStore.currency.copper += rewards.currency
@@ -381,7 +390,7 @@ function handleTaskCompletion(gameStore, playerStore, task, rewards) {
// 应用技能经验
for (const [skillId, exp] of Object.entries(rewards)) {
if (skillId !== 'currency' && skillId !== 'completionBonus' && typeof exp === 'number') {
if (skillId !== 'currency' && skillId !== 'completionBonus' && skillId !== 'craftedItem' && skillId !== 'craftedCount' && typeof exp === 'number') {
addSkillExp(playerStore, skillId, exp)
}
}
@@ -392,7 +401,8 @@ function handleTaskCompletion(gameStore, playerStore, task, rewards) {
resting: '休息',
training: '训练',
working: '工作',
praying: '祈祷'
praying: '祈祷',
crafting: '制造'
}
gameStore.addLog(`${taskNames[task.type]}任务完成`, 'reward')
}