fix: 修复武器经验获取并完善义体系统
- 修复战斗胜利后未获得武器技能经验的问题 (initCombat未传递skillExpReward) - 每级武器技能提供5%武器伤害加成(已实现,无需修改) - 实现义体安装/卸载功能,支持NPC对话交互 - StatusPanel添加义体装备槽显示 - MapPanel修复NPC对话import问题 - 新增成就系统框架 - 添加项目文档CLAUDE.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
142
utils/prostheticSystem.js
Normal file
142
utils/prostheticSystem.js
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* 义体系统 - 安装、卸下、义体适应性
|
||||
*/
|
||||
|
||||
/**
|
||||
* 安装义体
|
||||
* @param {Object} playerStore - 玩家Store
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
* @param {Object} prostheticItem - 义体物品
|
||||
* @returns {Object} { success: boolean, message: string }
|
||||
*/
|
||||
export function installProsthetic(playerStore, gameStore, prostheticItem) {
|
||||
// 检查是否已有义体
|
||||
if (playerStore.equipment.prosthetic) {
|
||||
return {
|
||||
success: false,
|
||||
message: '你已经装备了义体,需要先卸下当前的义体。'
|
||||
}
|
||||
}
|
||||
|
||||
// 检查义体类型
|
||||
if (prostheticItem.type !== 'prosthetic') {
|
||||
return {
|
||||
success: false,
|
||||
message: '这不是义体装备。'
|
||||
}
|
||||
}
|
||||
|
||||
// 装备义体
|
||||
playerStore.equipment.prosthetic = { ...prostheticItem }
|
||||
|
||||
// 解锁义体适应性技能
|
||||
if (!playerStore.skills['prosthetic_adaptation']) {
|
||||
playerStore.skills['prosthetic_adaptation'] = { level: 0, exp: 0 }
|
||||
}
|
||||
|
||||
gameStore.addLog(`安装了 ${prostheticItem.name}`, 'reward')
|
||||
gameStore.addLog(`获得了被动技能: 义体适应性`, 'info')
|
||||
|
||||
// 检查成就
|
||||
gameStore.checkAchievements('equip_prosthetic', { prostheticCount: 1 })
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `成功安装 ${prostheticItem.name}`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸下义体
|
||||
* @param {Object} playerStore - 玩家Store
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
* @returns {Object} { success: boolean, message: string, removedItem: Object }
|
||||
*/
|
||||
export function removeProsthetic(playerStore, gameStore) {
|
||||
const currentProsthetic = playerStore.equipment.prosthetic
|
||||
|
||||
if (!currentProsthetic) {
|
||||
return {
|
||||
success: false,
|
||||
message: '你没有装备任何义体。'
|
||||
}
|
||||
}
|
||||
|
||||
// 将义体放回背包
|
||||
playerStore.inventory.push({ ...currentProsthetic })
|
||||
|
||||
// 卸下义体
|
||||
playerStore.equipment.prosthetic = null
|
||||
|
||||
gameStore.addLog(`卸下了 ${currentProsthetic.name}`, 'info')
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `成功卸下 ${currentProsthetic.name}`,
|
||||
removedItem: currentProsthetic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取义体提供的属性加成
|
||||
* @param {Object} prosthetic - 义体装备
|
||||
* @returns {Object} 属性加成
|
||||
*/
|
||||
export function getProstheticBonus(prosthetic) {
|
||||
if (!prosthetic) return null
|
||||
|
||||
return {
|
||||
stats: prosthetic.stats || {},
|
||||
skill: prosthetic.skill || null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查义体技能是否可用
|
||||
* @param {Object} playerStore - 玩家Store
|
||||
* @param {String} skillId - 技能ID
|
||||
* @returns {Boolean} 是否可用
|
||||
*/
|
||||
export function isProstheticSkillAvailable(playerStore, skillId) {
|
||||
const prosthetic = playerStore.equipment.prosthetic
|
||||
if (!prosthetic) return false
|
||||
|
||||
// 检查义体是否提供该技能
|
||||
return prosthetic.skill === skillId || prosthetic.grantedSkills?.includes(skillId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加义体适应性经验
|
||||
* @param {Object} playerStore - 玩家Store
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
* @param {Number} exp - 经验值
|
||||
*/
|
||||
export function addProstheticExp(playerStore, gameStore, exp) {
|
||||
const skill = playerStore.skills['prosthetic_adaptation']
|
||||
if (!skill) return
|
||||
|
||||
const { SKILL_CONFIG } = require('@/config/skills.js')
|
||||
const skillConfig = SKILL_CONFIG['prosthetic_adaptation']
|
||||
const maxLevel = skillConfig.maxLevel
|
||||
|
||||
if (skill.level >= maxLevel) return
|
||||
|
||||
skill.exp += exp
|
||||
const expNeeded = skillConfig.expPerLevel(skill.level)
|
||||
|
||||
while (skill.exp >= expNeeded && skill.level < maxLevel) {
|
||||
skill.exp -= expNeeded
|
||||
skill.level++
|
||||
gameStore.addLog(`义体适应性提升到 Lv.${skill.level}!`, 'reward')
|
||||
|
||||
// 检查里程碑奖励
|
||||
if (skillConfig.milestones[skill.level]) {
|
||||
const milestone = skillConfig.milestones[skill.level]
|
||||
gameStore.addLog(`解锁效果: ${milestone.desc}`, 'info')
|
||||
}
|
||||
|
||||
if (skill.level < maxLevel) {
|
||||
expNeeded = skillConfig.expPerLevel(skill.level)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user