Compare commits
5 Commits
16223c89a5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b851656de | |||
| ccfd6a5e75 | |||
| 27e1c8d440 | |||
| 5d4371ba1f | |||
| cef974d94f |
@@ -13,7 +13,10 @@
|
||||
"Bash(git remote add:*)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit:*)",
|
||||
"Bash(git push:*)"
|
||||
"Bash(git push:*)",
|
||||
"Read(//d/uniapp/app_test/wwa3/**)",
|
||||
"Bash(npx eslint:*)",
|
||||
"mcp__playwright__browser_close"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is a text-based idle adventure game (文字冒险游戏) built with uni-app, Vue 3, and Pinia. The game features skill-driven progression, idle mechanics, combat, crafting, and a dark post-apocalyptic theme.
|
||||
|
||||
**Tech Stack:**
|
||||
- Framework: uni-app (Vue 3 with Composition API)
|
||||
- State Management: Pinia
|
||||
- Testing: Jest + Vitest + Playwright
|
||||
- Style: SCSS with global variables
|
||||
|
||||
## Build and Run Commands
|
||||
|
||||
### Development
|
||||
- Use HBuilderX IDE to run the project (uni-app standard)
|
||||
- Run to different platforms: mp-weixin (WeChat Mini Program), h5, app
|
||||
|
||||
### Testing
|
||||
```bash
|
||||
npm test # Run Jest tests in watch mode
|
||||
npm run test:watch # Run tests in watch mode
|
||||
npm run test:coverage # Generate coverage report
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
### Directory Structure
|
||||
```
|
||||
├── components/
|
||||
│ ├── common/ # Reusable UI components (ProgressBar, StatItem, etc.)
|
||||
│ ├── layout/ # Layout components (TabBar, Drawer)
|
||||
│ ├── panels/ # Main game panels (StatusPanel, MapPanel, LogPanel)
|
||||
│ └── drawers/ # Slide-out drawers (Inventory, Event, Shop, Crafting)
|
||||
├── config/ # Game configuration (skills, items, enemies, locations, etc.)
|
||||
├── store/ # Pinia stores (player.js, game.js)
|
||||
├── utils/ # Game systems (combat, skill, item, task, event, etc.)
|
||||
├── pages/ # Uni-app pages
|
||||
└── tests/ # Unit tests with fixtures and helpers
|
||||
```
|
||||
|
||||
### Core Systems (utils/)
|
||||
- **skillSystem.js**: Skill unlocking, XP, leveling, milestone rewards, parent skills
|
||||
- **combatSystem.js**: AP/EP hit calculation, three-layer defense (evade/shield/armor), damage
|
||||
- **itemSystem.js**: Item usage, equipment, quality calculation, inventory management
|
||||
- **taskSystem.js**: Idle task management, mutual exclusion checks
|
||||
- **eventSystem.js**: Event triggering, NPC dialogue handling
|
||||
- **environmentSystem.js**: Environment penalties, passive skill XP
|
||||
- **gameLoop.js**: Main game tick (1-second interval), time progression, auto-save
|
||||
- **storage.js**: Save/load using uni.setStorageSync, offline earnings
|
||||
- **craftingSystem.js**: Recipe-based crafting with quality calculation
|
||||
- **levelingSystem.js**: Player level progression and stat scaling
|
||||
- **mapLayout.js**: Visual map representation
|
||||
|
||||
### State Management (Pinia Stores)
|
||||
- **player.js**: Base stats, current stats (HP/stamina/sanity), level, skills, equipment, inventory, currency, location, flags
|
||||
- **game.js**: Current tab, drawer states, logs, game time, combat state, active tasks, market prices, current event
|
||||
|
||||
### Configuration (config/)
|
||||
- **constants.js**: Game constants (quality levels, stat scaling, time scale, etc.)
|
||||
- **skills.js**: All skill definitions with milestones and unlock conditions
|
||||
- **items.js**: All item definitions (weapons, consumables, materials, books)
|
||||
- **enemies.js**: Enemy stats, drops, spawn conditions
|
||||
- **locations.js**: Area definitions, connections, activities, unlock conditions
|
||||
- **npcs.js**: NPC dialogue trees and interactions
|
||||
- **events.js**: Event definitions and triggers
|
||||
- **recipes.js**: Crafting recipes
|
||||
- **shop.js**: Shop inventory and pricing
|
||||
- **formulas.js**: Mathematical formulas for stat calculations
|
||||
|
||||
## Key Game Concepts
|
||||
|
||||
### Quality System (品质系统)
|
||||
Items have quality (0-250) that affects their power:
|
||||
- 0-49: 垃圾 (Trash)
|
||||
- 50-99: 普通 (Common)
|
||||
- 100-139: 优秀 (Good)
|
||||
- 140-169: 稀有 (Rare)
|
||||
- 170-199: 史诗 (Epic)
|
||||
- 200-250: 传说 (Legendary)
|
||||
|
||||
Each tier has a multiplier that increases item stats.
|
||||
|
||||
### AP/EP Combat System
|
||||
- AP (Attack Points) = 灵巧 + 智力×0.2 + skills + equipment + stance - enemyCountPenalty
|
||||
- EP (Evasion Points) = 敏捷 + 智力×0.2 + skills + equipment + stance - environmentPenalty
|
||||
- Hit rate is non-linear: AP=5×EP → ~98%, AP=EP → ~50%, AP=0.5×EP → ~24%
|
||||
|
||||
### Three-Layer Defense
|
||||
1. Evasion (complete dodge)
|
||||
2. Shield absorption
|
||||
3. Defense reduction (min 10% damage)
|
||||
|
||||
### Skill Milestones
|
||||
Skills provide permanent global bonuses at specific levels (e.g., all weapons +crit rate at level 5). Parent skills auto-level to match highest child skill level.
|
||||
|
||||
### Time System
|
||||
- 1 real second = 5 game minutes
|
||||
- Day/night cycle affects gameplay
|
||||
- Markets refresh daily
|
||||
- Offline earnings available (0.5h base, 2.5h with ad)
|
||||
|
||||
### Idle Tasks
|
||||
Active tasks (reading, training, working) and passive tasks (environment adaptation). Combat is mutually exclusive with most tasks.
|
||||
|
||||
## Important Patterns
|
||||
|
||||
### Adding New Skills
|
||||
1. Add config to `config/skills.js`
|
||||
2. Set unlockCondition (item, location, or skill level)
|
||||
3. Add milestones with permanent bonuses
|
||||
4. Link to parentSkill if applicable
|
||||
|
||||
### Adding New Items
|
||||
1. Add config to `config/items.js`
|
||||
2. Set baseValue, baseDamage/defense, type
|
||||
3. Add to shop or enemy drop tables
|
||||
4. For equipment, quality affects final stats
|
||||
|
||||
### Adding New Locations
|
||||
1. Add to `config/locations.js`
|
||||
2. Set connections, enemies, activities
|
||||
3. Add unlockCondition if needed
|
||||
4. Update `utils/mapLayout.js` for visual representation
|
||||
|
||||
### Store Usage
|
||||
```javascript
|
||||
import { usePlayerStore } from '@/store/player.js'
|
||||
import { useGameStore } from '@/store/game.js'
|
||||
|
||||
const player = usePlayerStore()
|
||||
const game = useGameStore()
|
||||
|
||||
// Access state
|
||||
player.baseStats.strength
|
||||
game.logs
|
||||
|
||||
// Call actions
|
||||
game.addLog('message', 'info')
|
||||
```
|
||||
|
||||
### Color Variables (uni.scss)
|
||||
- $bg-primary: #0a0a0f (main background)
|
||||
- $accent: #4ecdc4 (primary accent)
|
||||
- $danger: #ff6b6b (combat/HP low)
|
||||
- Quality colors: $quality-trash through $quality-legend
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Game Loop Timing
|
||||
- Main loop runs every 1 second via `gameLoop.js`
|
||||
- Time advances by TIME_SCALE (5) minutes per tick
|
||||
- Auto-save triggers every 30 game minutes
|
||||
|
||||
### Saving
|
||||
- `App.vue` handles onLaunch/onShow/onHide
|
||||
- Auto-saves on app hide
|
||||
- Manual save via `window.manualSave()`
|
||||
- Logs are NOT persisted (cleared on load)
|
||||
|
||||
### Testing
|
||||
- Tests in `tests/unit/` use Vitest
|
||||
- Fixtures in `tests/fixtures/` provide mock data
|
||||
- Helpers in `tests/helpers/` mock timers, stores, random
|
||||
- See `tests/README.md` for testing guidelines
|
||||
|
||||
## Known Gotchas
|
||||
|
||||
1. **uni API availability**: Some uni APIs only work in specific platforms (H5 vs mini-program)
|
||||
2. **Store timing**: Always use `setActivePinia(createPinia())` in tests
|
||||
3. **Logs array**: Limited to 200 entries, shifts old entries
|
||||
4. **Skill level cap**: Cannot exceed player level × 2
|
||||
5. **Equipment quality**: Calculated as base × quality% × tierMultiplier
|
||||
6. **Combat stance**: Switching stance resets attack progress
|
||||
7. **Market saturation**: Selling same item reduces price (encourages exploration)
|
||||
@@ -0,0 +1,547 @@
|
||||
# 文字冒险游戏 - 内容开发指南
|
||||
|
||||
本项目是一个基于 UniApp + Vue 3 的文字冒险游戏,采用配置驱动的架构。所有游戏内容(物品、NPC、技能、配方、事件等)都通过配置文件定义,无需修改核心代码即可扩展游戏内容。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
config/
|
||||
├── constants.js # 游戏常量(品质等级、时间等)
|
||||
├── items.js # 物品配置
|
||||
├── skills.js # 技能配置
|
||||
├── npcs.js # NPC配置
|
||||
├── recipes.js # 制造配方配置
|
||||
├── enemies.js # 敌人配置
|
||||
├── events.js # 事件/剧情配置
|
||||
├── locations.js # 地点配置
|
||||
└── shop.js # 商店配置
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. 创建物品
|
||||
|
||||
物品定义在 `config/items.js` 中的 `ITEM_CONFIG` 对象。
|
||||
|
||||
### 基本结构
|
||||
|
||||
```javascript
|
||||
your_item_id: {
|
||||
id: 'your_item_id', // 唯一ID(建议使用下划线命名)
|
||||
name: '物品名称', // 显示名称
|
||||
type: 'weapon', // 类型:weapon/armor/shield/accessory/consumable/book/material
|
||||
subtype: 'one_handed', // 子类型(可选)
|
||||
icon: '🗡️', // 图标(emoji)
|
||||
baseValue: 100, // 基础价值(铜币)
|
||||
description: '物品描述', // 描述文本
|
||||
stackable: true, // 是否可堆叠(消耗品/素材)
|
||||
maxStack: 99 // 最大堆叠数
|
||||
}
|
||||
```
|
||||
|
||||
### 武器
|
||||
|
||||
```javascript
|
||||
sword: {
|
||||
id: 'sword',
|
||||
name: '铁剑',
|
||||
type: 'weapon',
|
||||
subtype: 'sword', // one_handed/two_handed/sword/axe/blunt/ranged
|
||||
icon: '⚔️',
|
||||
baseValue: 500,
|
||||
baseDamage: 25, // 基础攻击力
|
||||
attackSpeed: 1.2, // 攻击速度倍率
|
||||
quality: 100, // 基础品质(影响属性计算)
|
||||
unlockSkill: 'sword_mastery', // 装备解锁的技能
|
||||
stats: { // 额外属性加成
|
||||
critRate: 5 // 暴击率+5%
|
||||
},
|
||||
description: '一把精工打造的铁剑。'
|
||||
}
|
||||
```
|
||||
|
||||
### 防具
|
||||
|
||||
```javascript
|
||||
armor: {
|
||||
id: 'leather_armor',
|
||||
name: '皮甲',
|
||||
type: 'armor',
|
||||
subtype: 'light', // light/heavy
|
||||
icon: '🦺',
|
||||
baseValue: 150,
|
||||
baseDefense: 8, // 基础防御力
|
||||
quality: 100,
|
||||
stats: {
|
||||
evasion: 5 // 闪避+5%
|
||||
},
|
||||
description: '用兽皮制成的轻甲。'
|
||||
}
|
||||
```
|
||||
|
||||
### 消耗品
|
||||
|
||||
```javascript
|
||||
potion: {
|
||||
id: 'health_potion',
|
||||
name: '治疗药水',
|
||||
type: 'consumable',
|
||||
subtype: 'medicine', // food/drink/medicine
|
||||
icon: '🧪',
|
||||
baseValue: 150,
|
||||
effect: { // 使用效果
|
||||
health: 100, // 恢复生命值
|
||||
stamina: 20, // 恢复耐力
|
||||
sanity: 10 // 恢复精神
|
||||
},
|
||||
description: '快速恢复生命值。',
|
||||
stackable: true,
|
||||
maxStack: 20
|
||||
}
|
||||
```
|
||||
|
||||
### 书籍
|
||||
|
||||
```javascript
|
||||
book: {
|
||||
id: 'skill_book',
|
||||
name: '战斗指南',
|
||||
type: 'book',
|
||||
icon: '📖',
|
||||
baseValue: 200,
|
||||
readingTime: 60, // 阅读时间(秒)
|
||||
expReward: { // 阅读获得的技能经验
|
||||
combat: 100, // 主经验
|
||||
sword_mastery: 50 // 特定技能经验
|
||||
},
|
||||
completionBonus: { // 完成奖励(可选)
|
||||
exp: 200 // 额外主经验
|
||||
},
|
||||
description: '记载着战斗技巧的书籍。'
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. 创建技能
|
||||
|
||||
技能定义在 `config/skills.js` 中的 `SKILL_CONFIG` 对象。
|
||||
|
||||
### 基本结构
|
||||
|
||||
```javascript
|
||||
your_skill: {
|
||||
id: 'your_skill',
|
||||
name: '技能名称',
|
||||
type: 'combat', // 类型:combat/life/passive
|
||||
category: 'weapon', // 分类:weapon/crafting/reading等
|
||||
icon: '⚔️',
|
||||
maxLevel: 20, // 最大等级
|
||||
expPerLevel: (level) => level * 100, // 每级所需经验公式
|
||||
milestones: { // 里程碑(等级解锁效果)
|
||||
5: {
|
||||
desc: '攻击力+10%',
|
||||
effect: { attackBonus: 10 }
|
||||
},
|
||||
10: {
|
||||
desc: '解锁新技能',
|
||||
effect: { unlockSkill: 'advanced_skill' }
|
||||
}
|
||||
},
|
||||
unlockCondition: { // 解锁条件(可选)
|
||||
type: 'item',
|
||||
itemId: 'starter_sword'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 战斗技能
|
||||
|
||||
```javascript
|
||||
sword_mastery: {
|
||||
id: 'sword_mastery',
|
||||
name: '剑术精通',
|
||||
type: 'combat',
|
||||
category: 'weapon',
|
||||
icon: '⚔️',
|
||||
maxLevel: 20,
|
||||
expPerLevel: (level) => level * 100,
|
||||
milestones: {
|
||||
5: { desc: '暴击率+5%', effect: { critRate: 5 } },
|
||||
10: { desc: '攻击力+15%', effect: { attackBonus: 15 } },
|
||||
15: { desc: '暴击伤害+0.5', effect: { critMult: 0.5 } },
|
||||
20: { desc: '剑术大师', effect: { mastery: true } }
|
||||
},
|
||||
unlockCondition: null // 初始解锁/通过装备武器解锁
|
||||
}
|
||||
```
|
||||
|
||||
### 生活技能
|
||||
|
||||
```javascript
|
||||
crafting: {
|
||||
id: 'crafting',
|
||||
name: '制造',
|
||||
type: 'life',
|
||||
category: 'crafting',
|
||||
icon: '🔨',
|
||||
maxLevel: 20,
|
||||
expPerLevel: (level) => level * 80,
|
||||
milestones: {
|
||||
1: { desc: '解锁基础制造', effect: {} },
|
||||
5: { desc: '制造成功率+5%', effect: { craftingSuccessRate: 5 } },
|
||||
10: { desc: '制造时间-25%', effect: { craftingSpeed: 0.25 } }
|
||||
},
|
||||
unlockCondition: null
|
||||
}
|
||||
```
|
||||
|
||||
### 被动技能
|
||||
|
||||
```javascript
|
||||
night_vision: {
|
||||
id: 'night_vision',
|
||||
name: '夜视',
|
||||
type: 'passive',
|
||||
category: 'environment',
|
||||
icon: '👁️',
|
||||
maxLevel: 10,
|
||||
expPerLevel: (level) => level * 30,
|
||||
milestones: {
|
||||
5: { desc: '黑暗惩罚-10%', effect: { darkPenaltyReduce: 10 } },
|
||||
10: { desc: '黑暗惩罚-25%', effect: { darkPenaltyReduce: 25 } }
|
||||
},
|
||||
unlockCondition: {
|
||||
location: 'basement' // 进入该地点自动解锁
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. 创建NPC
|
||||
|
||||
NPC定义在 `config/npcs.js` 中的 `NPC_CONFIG` 对象。
|
||||
|
||||
### 基本结构
|
||||
|
||||
```javascript
|
||||
your_npc: {
|
||||
id: 'your_npc',
|
||||
name: 'NPC名称',
|
||||
location: 'camp', // 所在位置(location ID)
|
||||
dialogue: {
|
||||
first: { // 首次对话
|
||||
text: '对话文本...',
|
||||
choices: [
|
||||
{ text: '选项1', next: 'node1' },
|
||||
{ text: '选项2', next: null, action: 'action_name' }
|
||||
]
|
||||
},
|
||||
node1: { // 后续对话节点
|
||||
text: '更多对话...',
|
||||
choices: [
|
||||
{ text: '再见', next: null }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 带动作的NPC
|
||||
|
||||
```javascript
|
||||
merchant: {
|
||||
id: 'merchant',
|
||||
name: '商人',
|
||||
location: 'market',
|
||||
dialogue: {
|
||||
first: {
|
||||
text: '欢迎光临!',
|
||||
choices: [
|
||||
{ text: '查看商品', next: null, action: 'open_shop' },
|
||||
{ text: '这是哪里?', next: 'explain' }
|
||||
]
|
||||
},
|
||||
explain: {
|
||||
text: '这里是市场...',
|
||||
choices: [
|
||||
{ text: '查看商品', next: null, action: 'open_shop' },
|
||||
{ text: '离开', next: null }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 可用动作
|
||||
|
||||
| 动作 | 说明 |
|
||||
|------|------|
|
||||
| `open_shop` | 打开商店 |
|
||||
| `give_item` | 给予物品(需指定 actionData) |
|
||||
| `heal` | 恢复生命值 |
|
||||
| `unlock_skill` | 解锁技能 |
|
||||
| `teleport` | 传送到指定位置 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 创建配方
|
||||
|
||||
配方定义在 `config/recipes.js` 中的 `RECIPE_CONFIG` 对象。
|
||||
|
||||
### 基本结构
|
||||
|
||||
```javascript
|
||||
your_recipe: {
|
||||
id: 'your_recipe',
|
||||
type: RECIPE_TYPES.WEAPON, // 类型:WEAPON/ARMOR/SHIELD/CONSUMABLE/SPECIAL
|
||||
resultItem: 'result_item_id', // 产物物品ID
|
||||
resultCount: 1, // 产物数量
|
||||
materials: [ // 材料需求
|
||||
{ itemId: 'material_1', count: 5 },
|
||||
{ itemId: 'material_2', count: 2 }
|
||||
],
|
||||
requiredSkill: 'crafting', // 所需技能
|
||||
requiredSkillLevel: 3, // 所需技能等级
|
||||
baseTime: 60, // 基础制造时间(秒)
|
||||
baseSuccessRate: 0.85, // 基础成功率(0-1)
|
||||
unlockCondition: { // 解锁条件(可选)
|
||||
type: 'skill', // skill/quest/item
|
||||
skillId: 'crafting',
|
||||
level: 5
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 配方示例
|
||||
|
||||
```javascript
|
||||
iron_sword: {
|
||||
id: 'iron_sword',
|
||||
type: RECIPE_TYPES.WEAPON,
|
||||
resultItem: 'iron_sword',
|
||||
resultCount: 1,
|
||||
materials: [
|
||||
{ itemId: 'iron_ore', count: 5 },
|
||||
{ itemId: 'leather', count: 2 }
|
||||
],
|
||||
requiredSkill: 'sword_mastery',
|
||||
requiredSkillLevel: 5,
|
||||
baseTime: 180,
|
||||
baseSuccessRate: 0.75,
|
||||
unlockCondition: {
|
||||
type: 'skill',
|
||||
skillId: 'crafting',
|
||||
level: 3
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 创建敌人
|
||||
|
||||
敌人定义在 `config/enemies.js` 中的 `ENEMY_CONFIG` 对象。
|
||||
|
||||
### 基本结构
|
||||
|
||||
```javascript
|
||||
your_enemy: {
|
||||
id: 'your_enemy',
|
||||
name: '敌人名称',
|
||||
icon: '👾',
|
||||
level: 5, // 等级
|
||||
hp: 100, // 生命值
|
||||
attack: 15, // 攻击力
|
||||
defense: 5, // 防御力
|
||||
speed: 10, // 速度(影响行动顺序)
|
||||
expReward: 50, // 经验奖励
|
||||
// 可选属性
|
||||
critRate: 5, // 暴击率
|
||||
fleeRate: 20, // 逃跑成功率
|
||||
skills: ['skill_id'], // 拥有的技能
|
||||
drops: [ // 掉落列表
|
||||
{ itemId: 'drop_item', chance: 0.3, count: { min: 1, max: 2 } }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. 创建事件/剧情
|
||||
|
||||
事件定义在 `config/events.js` 中的 `EVENT_CONFIG` 对象。
|
||||
|
||||
### 基本结构
|
||||
|
||||
```javascript
|
||||
your_event: {
|
||||
id: 'your_event',
|
||||
type: 'story', // 类型:story/tips/unlock/dialogue/reward/combat
|
||||
title: '事件标题',
|
||||
text: '事件内容...',
|
||||
textTemplate: '支持{variable}变量替换', // 或使用模板
|
||||
choices: [
|
||||
{ text: '选项', next: 'next_event_id' },
|
||||
{ text: '带动作的选项', next: null, action: 'action_name', actionData: {} }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 事件类型
|
||||
|
||||
| 类型 | 说明 |
|
||||
|------|------|
|
||||
| `story` | 剧情事件 |
|
||||
| `tips` | 提示信息 |
|
||||
| `unlock` | 解锁内容提示 |
|
||||
| `dialogue` | NPC对话 |
|
||||
| `reward` | 奖励提示 |
|
||||
| `combat` | 战斗事件 |
|
||||
|
||||
### 触发条件
|
||||
|
||||
在 `EVENT_TRIGGERS` 中配置触发条件:
|
||||
|
||||
```javascript
|
||||
export const EVENT_TRIGGERS = {
|
||||
once: {
|
||||
your_trigger: {
|
||||
condition: (playerStore) => {
|
||||
// 返回 true 时触发事件
|
||||
return playerStore.level >= 5 && !playerStore.flags.yourEventSeen
|
||||
},
|
||||
eventId: 'your_event',
|
||||
setFlag: 'yourEventSeen' // 触发后设置的标记
|
||||
}
|
||||
},
|
||||
environment: {
|
||||
your_env_trigger: {
|
||||
condition: (playerStore, locationId) => {
|
||||
return locationId === 'dark_cave' && !playerStore.flags.darkCaveFirstEnter
|
||||
},
|
||||
eventId: 'dark_warning'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. 解锁条件
|
||||
|
||||
解锁条件可用于技能、配方、地点等。
|
||||
|
||||
### 类型
|
||||
|
||||
```javascript
|
||||
// 基于等级
|
||||
unlockCondition: {
|
||||
type: 'level',
|
||||
level: 5
|
||||
}
|
||||
|
||||
// 基于技能
|
||||
unlockCondition: {
|
||||
type: 'skill',
|
||||
skillId: 'crafting',
|
||||
level: 3
|
||||
}
|
||||
|
||||
// 基于物品
|
||||
unlockCondition: {
|
||||
type: 'item',
|
||||
itemId: 'key_item'
|
||||
}
|
||||
|
||||
// 基于位置
|
||||
unlockCondition: {
|
||||
type: 'location',
|
||||
locationId: 'secret_area'
|
||||
}
|
||||
|
||||
// 基于任务标记
|
||||
unlockCondition: {
|
||||
type: 'quest',
|
||||
flag: 'completed_quest_x'
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. 品质系统
|
||||
|
||||
物品品质定义在 `config/constants.js` 中的 `QUALITY_LEVELS`。
|
||||
|
||||
```javascript
|
||||
QUALITY_LEVELS: {
|
||||
1: { level: 1, name: '垃圾', color: '#6b7280', range: [0, 49], multiplier: 0.5 },
|
||||
2: { level: 2, name: '普通', color: '#ffffff', range: [50, 89], multiplier: 1.0 },
|
||||
3: { level: 3, name: '优秀', color: '#22c55e', range: [90, 129], multiplier: 1.2 },
|
||||
4: { level: 4, name: '稀有', color: '#3b82f6', range: [130, 159], multiplier: 1.5 },
|
||||
5: { level: 5, name: '史诗', color: '#a855f7', range: [160, 199], multiplier: 2.0 },
|
||||
6: { level: 6, name: '传说', color: '#f59e0b', range: [200, 250], multiplier: 3.0 }
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 9. 快速开始示例
|
||||
|
||||
### 添加新武器
|
||||
|
||||
```javascript
|
||||
// 在 config/items.js 中添加
|
||||
flame_sword: {
|
||||
id: 'flame_sword',
|
||||
name: '烈焰之剑',
|
||||
type: 'weapon',
|
||||
subtype: 'sword',
|
||||
icon: '🔥⚔️',
|
||||
baseValue: 2000,
|
||||
baseDamage: 50,
|
||||
attackSpeed: 1.3,
|
||||
quality: 150,
|
||||
unlockSkill: 'sword_mastery',
|
||||
stats: {
|
||||
critRate: 10,
|
||||
fireDamage: 15
|
||||
},
|
||||
description: '燃烧着永恒烈焰的魔剑。'
|
||||
}
|
||||
```
|
||||
|
||||
### 添加新技能
|
||||
|
||||
```javascript
|
||||
// 在 config/skills.js 中添加
|
||||
fire_mastery: {
|
||||
id: 'fire_mastery',
|
||||
name: '火焰精通',
|
||||
type: 'combat',
|
||||
category: 'element',
|
||||
icon: '🔥',
|
||||
maxLevel: 15,
|
||||
expPerLevel: (level) => level * 150,
|
||||
milestones: {
|
||||
3: { desc: '火焰伤害+20%', effect: { fireDamageBonus: 20 } },
|
||||
7: { desc: '攻击附带燃烧', effect: { burnEffect: true } },
|
||||
15: { desc: '火焰免疫', effect: { fireImmunity: true } }
|
||||
},
|
||||
unlockCondition: {
|
||||
type: 'item',
|
||||
itemId: 'flame_essence'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 10. 注意事项
|
||||
|
||||
1. **ID命名**:统一使用下划线命名(snake_case),保持唯一性
|
||||
2. **引用**:添加新物品后,记得在配方、商店、敌人掉落等处引用
|
||||
3. **平衡性**:注意数值平衡,参考现有物品的属性比例
|
||||
4. **测试**:添加内容后建议在游戏中测试效果
|
||||
5. **保存**:游戏进度保存在 localStorage,修改配置后可能需要清除缓存测试
|
||||
@@ -0,0 +1,597 @@
|
||||
<template>
|
||||
<view class="mini-map">
|
||||
<!-- 地图容器 -->
|
||||
<view class="mini-map__container">
|
||||
<scroll-view
|
||||
class="mini-map__scroll"
|
||||
scroll-x
|
||||
scroll-y
|
||||
:scroll-left="scrollLeft"
|
||||
:scroll-top="scrollTop"
|
||||
@scroll="onScroll"
|
||||
>
|
||||
<view
|
||||
class="mini-map__content"
|
||||
:style="contentStyle"
|
||||
>
|
||||
<!-- 连接线层 -->
|
||||
<view class="mini-map__connections">
|
||||
<view
|
||||
v-for="edge in mapData.edges"
|
||||
:key="`${edge.from}-${edge.to}`"
|
||||
class="connection-line"
|
||||
:class="{ 'connection-line--path': isInPath(edge) }"
|
||||
:style="getLineStyle(edge)"
|
||||
></view>
|
||||
</view>
|
||||
|
||||
<!-- 节点层 -->
|
||||
<view
|
||||
v-for="node in mapData.nodes"
|
||||
:key="node.id"
|
||||
class="map-node"
|
||||
:class="getNodeClass(node)"
|
||||
:style="getNodeStyle(node)"
|
||||
@click="handleNodeClick(node)"
|
||||
@touchstart="onTouchStart"
|
||||
@touchmove="onTouchMove"
|
||||
@touchend="onTouchEnd"
|
||||
>
|
||||
<!-- 节点圆点 -->
|
||||
<view class="node__dot"></view>
|
||||
|
||||
<!-- 当前位置脉冲效果 -->
|
||||
<view v-if="node.id === currentLocation" class="node__pulse"></view>
|
||||
|
||||
<!-- 节点名称 -->
|
||||
<text class="node__name">{{ node.name }}</text>
|
||||
|
||||
<!-- 锁定图标 -->
|
||||
<text v-if="isLocked(node)" class="node__lock">🔒</text>
|
||||
|
||||
<!-- 距离标记 -->
|
||||
<text v-else-if="getDistance(node) > 0" class="node__distance">{{ getDistance(node) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 缩放控制 -->
|
||||
<view class="mini-map__zoom-controls">
|
||||
<view class="zoom-btn" @click="zoomIn">
|
||||
<text class="zoom-icon">+</text>
|
||||
</view>
|
||||
<view class="zoom-btn" @click="resetZoom">
|
||||
<text class="zoom-icon">⟲</text>
|
||||
</view>
|
||||
<view class="zoom-btn" @click="zoomOut">
|
||||
<text class="zoom-icon">−</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 图例 -->
|
||||
<view class="mini-map__legend">
|
||||
<view class="legend-item">
|
||||
<view class="legend-dot legend-dot--current"></view>
|
||||
<text class="legend-text">当前位置</text>
|
||||
</view>
|
||||
<view class="legend-item">
|
||||
<view class="legend-dot legend-dot--safe"></view>
|
||||
<text class="legend-text">安全</text>
|
||||
</view>
|
||||
<view class="legend-item">
|
||||
<view class="legend-dot legend-dot--danger"></view>
|
||||
<text class="legend-text">危险</text>
|
||||
</view>
|
||||
<view class="legend-item">
|
||||
<view class="legend-dot legend-dot--dungeon"></view>
|
||||
<text class="legend-text">副本</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 路径提示 -->
|
||||
<view v-if="selectedPath.length > 1" class="mini-map__path">
|
||||
<text class="path-text">前往路径: {{ selectedPath.map(id => getLocationName(id)).join(' → ') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, watch } from 'vue'
|
||||
import { useGameStore } from '@/store/game'
|
||||
import { usePlayerStore } from '@/store/player'
|
||||
import { LOCATION_CONFIG } from '@/config/locations'
|
||||
import { getMapData, getPath } from '@/utils/mapLayout.js'
|
||||
|
||||
const game = useGameStore()
|
||||
const player = usePlayerStore()
|
||||
|
||||
const mapData = ref({ nodes: [], edges: [], width: 300, height: 400 })
|
||||
const selectedPath = ref([])
|
||||
|
||||
// 缩放和平移状态
|
||||
const zoom = ref(1)
|
||||
const scrollLeft = ref(0)
|
||||
const scrollTop = ref(0)
|
||||
const currentLocationNode = ref(null)
|
||||
|
||||
// 容器尺寸
|
||||
const containerWidth = 280
|
||||
const containerHeight = 300
|
||||
|
||||
// 触摸拖动状态
|
||||
const touchStartX = ref(0)
|
||||
const touchStartY = ref(0)
|
||||
const isDragging = ref(false)
|
||||
|
||||
const currentLocation = computed(() => player.currentLocation)
|
||||
|
||||
// 内容样式
|
||||
const contentStyle = computed(() => {
|
||||
return {
|
||||
width: (containerWidth * zoom.value) + 'px',
|
||||
height: (containerHeight * zoom.value) + 'px',
|
||||
transformOrigin: 'center center'
|
||||
}
|
||||
})
|
||||
|
||||
// 初始化地图
|
||||
function initMap() {
|
||||
const data = getMapData(player.currentLocation)
|
||||
|
||||
// 不再缩放以适应容器,使用原始坐标
|
||||
// 但确保地图足够大
|
||||
const padding = 40
|
||||
|
||||
mapData.value = {
|
||||
nodes: data.nodes.map(n => ({
|
||||
...n,
|
||||
x: n.x,
|
||||
y: n.y
|
||||
})),
|
||||
edges: data.edges,
|
||||
width: data.width,
|
||||
height: data.height,
|
||||
reachable: data.reachable
|
||||
}
|
||||
|
||||
// 找到当前节点并居中
|
||||
centerOnLocation()
|
||||
selectedPath.value = []
|
||||
}
|
||||
|
||||
// 居中到当前位置
|
||||
function centerOnLocation() {
|
||||
const currentNode = mapData.value.nodes.find(n => n.id === currentLocation.value)
|
||||
if (!currentNode) return
|
||||
|
||||
currentLocationNode.value = currentNode
|
||||
|
||||
// 计算需要滚动的位置以居中当前节点
|
||||
// 考虑缩放比例
|
||||
const targetLeft = currentNode.x * zoom.value - containerWidth / 2
|
||||
const targetTop = currentNode.y * zoom.value - containerHeight / 2
|
||||
|
||||
scrollLeft.value = Math.max(0, targetLeft)
|
||||
scrollTop.value = Math.max(0, targetTop)
|
||||
}
|
||||
|
||||
// 缩放控制
|
||||
function zoomIn() {
|
||||
zoom.value = Math.min(2, zoom.value + 0.2)
|
||||
centerOnLocation()
|
||||
}
|
||||
|
||||
function zoomOut() {
|
||||
zoom.value = Math.max(0.5, zoom.value - 0.2)
|
||||
centerOnLocation()
|
||||
}
|
||||
|
||||
function resetZoom() {
|
||||
zoom.value = 1
|
||||
centerOnLocation()
|
||||
}
|
||||
|
||||
// 触摸事件处理(用于拖动)
|
||||
function onTouchStart(e) {
|
||||
touchStartX.value = e.touches[0].clientX
|
||||
touchStartY.value = e.touches[0].clientY
|
||||
isDragging.value = false
|
||||
}
|
||||
|
||||
function onTouchMove(e) {
|
||||
const deltaX = e.touches[0].clientX - touchStartX.value
|
||||
const deltaY = e.touches[0].clientY - touchStartY.value
|
||||
|
||||
if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) {
|
||||
isDragging.value = true
|
||||
}
|
||||
}
|
||||
|
||||
function onTouchEnd(e) {
|
||||
// 如果不是拖动,则视为点击
|
||||
// 这里的处理在 handleNodeClick 中完成
|
||||
}
|
||||
|
||||
// 滚动事件
|
||||
function onScroll(e) {
|
||||
// 可以在这里记录滚动位置
|
||||
}
|
||||
|
||||
// 获取节点样式
|
||||
function getNodeStyle(node) {
|
||||
return {
|
||||
left: (node.x * zoom.value) + 'px',
|
||||
top: (node.y * zoom.value) + 'px'
|
||||
}
|
||||
}
|
||||
|
||||
// 获取节点样式类
|
||||
function getNodeClass(node) {
|
||||
const classes = []
|
||||
|
||||
if (node.id === currentLocation.value) {
|
||||
classes.push('map-node--current')
|
||||
}
|
||||
|
||||
if (isLocked(node)) {
|
||||
classes.push('map-node--locked')
|
||||
} else {
|
||||
if (node.type === 'safe') classes.push('map-node--safe')
|
||||
else if (node.type === 'danger') classes.push('map-node--danger')
|
||||
else if (node.type === 'dungeon') classes.push('map-node--dungeon')
|
||||
|
||||
const dist = getDistance(node)
|
||||
if (dist === 1) classes.push('map-node--adjacent')
|
||||
}
|
||||
|
||||
return classes.join(' ')
|
||||
}
|
||||
|
||||
// 检查区域是否锁定
|
||||
function isLocked(node) {
|
||||
const loc = LOCATION_CONFIG[node.id]
|
||||
if (!loc?.unlockCondition) return false
|
||||
|
||||
if (loc.unlockCondition.type === 'kill') {
|
||||
const killCount = (player.killCount && player.killCount[loc.unlockCondition.target]) || 0
|
||||
return killCount < loc.unlockCondition.count
|
||||
} else if (loc.unlockCondition.type === 'item') {
|
||||
return !player.inventory.some(i => i.id === loc.unlockCondition.item)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 获取距离(步数)
|
||||
function getDistance(node) {
|
||||
return mapData.value.reachable?.[node.id] ?? 99
|
||||
}
|
||||
|
||||
// 获取位置名称
|
||||
function getLocationName(id) {
|
||||
return LOCATION_CONFIG[id]?.name || id
|
||||
}
|
||||
|
||||
// 获取连接线样式
|
||||
function getLineStyle(edge) {
|
||||
const fromNode = mapData.value.nodes.find(n => n.id === edge.from)
|
||||
const toNode = mapData.value.nodes.find(n => n.id === edge.to)
|
||||
|
||||
if (!fromNode || !toNode) return {}
|
||||
|
||||
const dx = (toNode.x - fromNode.x) * zoom.value
|
||||
const dy = (toNode.y - fromNode.y) * zoom.value
|
||||
const length = Math.sqrt(dx * dx + dy * dy)
|
||||
const angle = Math.atan2(dy, dx) * 180 / Math.PI
|
||||
|
||||
return {
|
||||
left: (fromNode.x * zoom.value) + 'px',
|
||||
top: (fromNode.y * zoom.value) + 'px',
|
||||
width: length + 'px',
|
||||
transform: `rotate(${angle}deg)`
|
||||
}
|
||||
}
|
||||
|
||||
// 检查边是否在选中路径上
|
||||
function isInPath(edge) {
|
||||
if (selectedPath.value.length < 2) return false
|
||||
|
||||
for (let i = 0; i < selectedPath.value.length - 1; i++) {
|
||||
const from = selectedPath.value[i]
|
||||
const to = selectedPath.value[i + 1]
|
||||
if ((edge.from === from && edge.to === to) ||
|
||||
(edge.from === to && edge.to === from)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 处理节点点击
|
||||
function handleNodeClick(node) {
|
||||
if (node.id === currentLocation.value) {
|
||||
selectedPath.value = []
|
||||
return
|
||||
}
|
||||
|
||||
const path = getPath(currentLocation.value, node.id)
|
||||
if (path) {
|
||||
selectedPath.value = path
|
||||
|
||||
// 如果相邻且未锁定,提示可前往
|
||||
if (path.length === 2 && !isLocked(node)) {
|
||||
game.addLog(`可以前往 ${node.name}`, 'info')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 监听当前位置变化
|
||||
watch(() => player.currentLocation, () => {
|
||||
initMap()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
initMap()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.mini-map {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
|
||||
&__container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 360rpx;
|
||||
background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
border: 2rpx solid #4a5568;
|
||||
}
|
||||
|
||||
&__scroll {
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
&__content {
|
||||
position: relative;
|
||||
min-width: 100%;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
&__connections {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&__legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
padding: 12rpx;
|
||||
background-color: $bg-secondary;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
&__path {
|
||||
padding: 10rpx 12rpx;
|
||||
background-color: rgba($accent, 0.15);
|
||||
border: 1rpx solid $accent;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
&__zoom-controls {
|
||||
position: absolute;
|
||||
bottom: 12rpx;
|
||||
right: 12rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
z-index: 20;
|
||||
}
|
||||
}
|
||||
|
||||
.zoom-btn {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: rgba($bg-primary, 0.8);
|
||||
border: 1rpx solid rgba($accent, 0.5);
|
||||
border-radius: 8rpx;
|
||||
backdrop-filter: blur(4rpx);
|
||||
|
||||
&:active {
|
||||
background-color: rgba($accent, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
.zoom-icon {
|
||||
font-size: 32rpx;
|
||||
color: $accent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.connection-line {
|
||||
position: absolute;
|
||||
height: 2rpx;
|
||||
background-color: rgba(74, 85, 104, 0.5);
|
||||
transform-origin: left center;
|
||||
|
||||
&--path {
|
||||
background-color: rgba($warning, 0.8);
|
||||
height: 3rpx;
|
||||
box-shadow: 0 0 6rpx rgba($warning, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
.map-node {
|
||||
position: absolute;
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
transform: translate(-50%, -50%);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:active {
|
||||
transform: translate(-50%, -50%) scale(1.15);
|
||||
}
|
||||
|
||||
&--current {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
&--locked {
|
||||
opacity: 0.5;
|
||||
filter: grayscale(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
.node__dot {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border-radius: 50%;
|
||||
border: 2rpx solid;
|
||||
|
||||
.map-node--safe & {
|
||||
background-color: rgba($success, 0.3);
|
||||
border-color: $success;
|
||||
}
|
||||
|
||||
.map-node--danger & {
|
||||
background-color: rgba($danger, 0.3);
|
||||
border-color: $danger;
|
||||
}
|
||||
|
||||
.map-node--dungeon & {
|
||||
background-color: rgba($accent, 0.3);
|
||||
border-color: $accent;
|
||||
}
|
||||
|
||||
.map-node--current & {
|
||||
background-color: $warning;
|
||||
border-color: #fff;
|
||||
box-shadow: 0 0 12rpx rgba($warning, 0.8);
|
||||
}
|
||||
|
||||
.map-node--locked & {
|
||||
background-color: rgba($text-muted, 0.3);
|
||||
border-color: $text-muted;
|
||||
}
|
||||
}
|
||||
|
||||
.node__pulse {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 50%;
|
||||
background-color: rgba($warning, 0.4);
|
||||
animation: pulse 1.5s ease-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
transform: translate(-50%, -50%) scale(0.8);
|
||||
opacity: 0.8;
|
||||
}
|
||||
100% {
|
||||
transform: translate(-50%, -50%) scale(1.8);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.map-node--adjacent .node__dot::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -8rpx;
|
||||
left: -8rpx;
|
||||
right: -8rpx;
|
||||
bottom: -8rpx;
|
||||
border-radius: 50%;
|
||||
border: 1rpx dashed rgba($warning, 0.6);
|
||||
}
|
||||
|
||||
.node__name {
|
||||
position: absolute;
|
||||
top: 40rpx;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 20rpx;
|
||||
color: #e2e8f0;
|
||||
white-space: nowrap;
|
||||
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.8);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.node__lock {
|
||||
position: absolute;
|
||||
top: -12rpx;
|
||||
right: -12rpx;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.node__distance {
|
||||
position: absolute;
|
||||
bottom: -12rpx;
|
||||
right: -12rpx;
|
||||
font-size: 18rpx;
|
||||
color: rgba($text-secondary, 0.8);
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
padding: 2rpx 6rpx;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
.legend-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.legend-dot {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
border-radius: 50%;
|
||||
|
||||
&--current {
|
||||
background-color: $warning;
|
||||
}
|
||||
|
||||
&--safe {
|
||||
background-color: $success;
|
||||
}
|
||||
|
||||
&--danger {
|
||||
background-color: $danger;
|
||||
}
|
||||
|
||||
&--dungeon {
|
||||
background-color: $accent;
|
||||
}
|
||||
}
|
||||
|
||||
.legend-text {
|
||||
font-size: 20rpx;
|
||||
color: $text-secondary;
|
||||
}
|
||||
|
||||
.path-text {
|
||||
font-size: 22rpx;
|
||||
color: $accent;
|
||||
}
|
||||
</style>
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="progress-bar" :style="{ height }">
|
||||
<view class="progress-bar__fill" :style="fillStyle"></view>
|
||||
<view v-if="showText" class="progress-bar__text">
|
||||
{{ value }}/{{ max }}
|
||||
{{ displayValue }}/{{ displayMax }}
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -22,6 +22,10 @@ const percentage = computed(() => {
|
||||
return Math.min(100, Math.max(0, (props.value / props.max) * 100))
|
||||
})
|
||||
|
||||
const displayValue = computed(() => Math.floor(props.value))
|
||||
|
||||
const displayMax = computed(() => Math.floor(props.max))
|
||||
|
||||
const fillStyle = computed(() => ({
|
||||
width: `${percentage.value}%`,
|
||||
backgroundColor: props.color
|
||||
|
||||
@@ -55,6 +55,12 @@
|
||||
type="warning"
|
||||
@click="unequipItem"
|
||||
/>
|
||||
<TextButton
|
||||
v-if="canRead"
|
||||
text="阅读"
|
||||
type="primary"
|
||||
@click="readItem"
|
||||
/>
|
||||
<TextButton
|
||||
v-if="canUse"
|
||||
text="使用"
|
||||
@@ -75,6 +81,7 @@ import { ref, computed } from 'vue'
|
||||
import { usePlayerStore } from '@/store/player'
|
||||
import { useGameStore } from '@/store/game'
|
||||
import { equipItem as equipItemUtil, unequipItemBySlot, useItem as useItemUtil } from '@/utils/itemSystem.js'
|
||||
import { startTask } from '@/utils/taskSystem.js'
|
||||
import FilterTabs from '@/components/common/FilterTabs.vue'
|
||||
import TextButton from '@/components/common/TextButton.vue'
|
||||
|
||||
@@ -112,6 +119,11 @@ const canUse = computed(() => {
|
||||
return selectedItem.value.type === 'consumable'
|
||||
})
|
||||
|
||||
const canRead = computed(() => {
|
||||
if (!selectedItem.value) return false
|
||||
return selectedItem.value.type === 'book'
|
||||
})
|
||||
|
||||
// 装备槽位映射
|
||||
const slotMap = {
|
||||
weapon: 'weapon',
|
||||
@@ -126,8 +138,8 @@ function isEquipped(item) {
|
||||
const slot = slotMap[item.type]
|
||||
if (!slot) return false
|
||||
const equipped = player.equipment[slot]
|
||||
// 通过 uniqueId 或 id 比较
|
||||
return equipped && (equipped.uniqueId === item.uniqueId || equipped.id === item.id)
|
||||
// 只通过 uniqueId 比较,确保每个装备独立判断
|
||||
return equipped && equipped.uniqueId === item.uniqueId
|
||||
}
|
||||
|
||||
function close() {
|
||||
@@ -163,11 +175,34 @@ function useItem() {
|
||||
if (!selectedItem.value) return
|
||||
const result = useItemUtil(player, game, selectedItem.value.id, 1)
|
||||
if (result.success) {
|
||||
// 如果阅读任务,可以在这里处理
|
||||
selectedItem.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function readItem() {
|
||||
if (!selectedItem.value) return
|
||||
|
||||
// 检查是否已经在阅读中
|
||||
const existingTask = game.activeTasks?.find(t => t.type === 'reading')
|
||||
if (existingTask) {
|
||||
game.addLog('已经在阅读其他书籍了', 'error')
|
||||
return
|
||||
}
|
||||
|
||||
const result = startTask(game, player, 'reading', {
|
||||
itemId: selectedItem.value.id,
|
||||
duration: selectedItem.value.readingTime || 60
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
game.addLog(`开始阅读《${selectedItem.value.name}》`, 'info')
|
||||
selectedItem.value = null
|
||||
emit('close') // 关闭背包以便看到阅读进度
|
||||
} else {
|
||||
game.addLog(result.message, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
function sellItem() {
|
||||
if (!selectedItem.value) return
|
||||
// 已装备的物品不能出售
|
||||
@@ -256,13 +291,6 @@ function sellItem() {
|
||||
font-size: 22rpx;
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.quality-badge {
|
||||
font-size: 18rpx;
|
||||
opacity: 0.8;
|
||||
margin-left: 8rpx;
|
||||
}
|
||||
|
||||
&__equipped-badge {
|
||||
width: 32rpx;
|
||||
@@ -278,6 +306,12 @@ function sellItem() {
|
||||
}
|
||||
}
|
||||
|
||||
.quality-badge {
|
||||
font-size: 18rpx;
|
||||
opacity: 0.8;
|
||||
margin-left: 8rpx;
|
||||
}
|
||||
|
||||
.inventory-empty {
|
||||
padding: 80rpx;
|
||||
text-align: center;
|
||||
|
||||
@@ -130,6 +130,34 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 数量选择弹窗 -->
|
||||
<view v-if="quantitySelector" class="item-detail-popup" @click="cancelQuantitySell">
|
||||
<view class="item-detail" @click.stop>
|
||||
<text class="item-detail__name">选择出售数量</text>
|
||||
<view class="quantity-selector">
|
||||
<text class="quantity-selector__item-name">{{ quantitySelector.item.icon }} {{ quantitySelector.item.name }}</text>
|
||||
<text class="quantity-selector__available">拥有: {{ quantitySelector.maxCount }}</text>
|
||||
|
||||
<view class="quantity-selector__controls">
|
||||
<TextButton text="-" type="default" @click="decreaseSellCount" :disabled="quantitySelector.selectedCount <= 1" />
|
||||
<text class="quantity-selector__count">{{ quantitySelector.selectedCount }}</text>
|
||||
<TextButton text="+" type="default" @click="increaseSellCount" :disabled="quantitySelector.selectedCount >= quantitySelector.maxCount" />
|
||||
</view>
|
||||
|
||||
<TextButton text="全部" type="default" size="small" @click="setMaxSellCount" style="margin-top: 12rpx;" />
|
||||
|
||||
<view class="quantity-selector__preview">
|
||||
<text class="quantity-selector__price-label">预计获得:</text>
|
||||
<text class="quantity-selector__price">{{ getSellPrice(quantitySelector.item) * quantitySelector.selectedCount }} 铜币</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-detail__actions">
|
||||
<TextButton text="确认出售" type="primary" @click="confirmQuantitySell" />
|
||||
<TextButton text="取消" @click="cancelQuantitySell" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -138,6 +166,7 @@ import { ref, computed } from 'vue'
|
||||
import { usePlayerStore } from '@/store/player'
|
||||
import { useGameStore } from '@/store/game'
|
||||
import { getShopConfig, getBuyPrice as calcBuyPrice, getSellPrice as calcSellPrice } from '@/config/shop.js'
|
||||
import { ITEM_CONFIG } from '@/config/items.js'
|
||||
import { addItemToInventory, removeItemFromInventory } from '@/utils/itemSystem.js'
|
||||
import FilterTabs from '@/components/common/FilterTabs.vue'
|
||||
import TextButton from '@/components/common/TextButton.vue'
|
||||
@@ -149,6 +178,8 @@ const currentMode = ref('buy')
|
||||
const selectedItem = ref(null)
|
||||
const bulkMode = ref(false)
|
||||
const selectedItems = ref([])
|
||||
// 数量选择弹窗状态
|
||||
const quantitySelector = ref(null) // { item: Object, maxCount: Number, selectedCount: Number }
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
@@ -171,10 +202,18 @@ const shopItems = computed(() => {
|
||||
return config.items
|
||||
.filter(item => item.stock === -1 || item.stock > 0)
|
||||
.map(shopItem => {
|
||||
const itemConfig = { ...shopItem }
|
||||
itemConfig.id = shopItem.itemId
|
||||
return itemConfig
|
||||
// 从 ITEM_CONFIG 获取完整物品信息
|
||||
const itemConfig = ITEM_CONFIG[shopItem.itemId]
|
||||
if (!itemConfig) return null
|
||||
|
||||
return {
|
||||
...itemConfig, // 复制所有物品属性(name, icon, description等)
|
||||
id: shopItem.itemId, // 使用 itemId 作为 id
|
||||
stock: shopItem.stock,
|
||||
baseStock: shopItem.baseStock
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
})
|
||||
|
||||
// 玩家可出售物品
|
||||
@@ -248,7 +287,7 @@ function isItemSelected(item) {
|
||||
// 处理出售列表点击
|
||||
function handleSellItemClick(item) {
|
||||
if (bulkMode.value) {
|
||||
// 批量模式:切换选中状态
|
||||
// 批量模式:切换选中状态(批量出售出售全部)
|
||||
const index = selectedItems.value.findIndex(i =>
|
||||
(i.uniqueId && i.uniqueId === item.uniqueId) || i.id === item.id
|
||||
)
|
||||
@@ -258,8 +297,18 @@ function handleSellItemClick(item) {
|
||||
selectedItems.value.push(item)
|
||||
}
|
||||
} else {
|
||||
// 普通模式:显示详情
|
||||
trySell(item)
|
||||
// 普通模式:检查是否是堆叠物品
|
||||
if (item.count > 1) {
|
||||
// 堆叠物品:显示数量选择弹窗
|
||||
quantitySelector.value = {
|
||||
item: item,
|
||||
maxCount: item.count,
|
||||
selectedCount: 1
|
||||
}
|
||||
} else {
|
||||
// 非堆叠物品:直接显示详情
|
||||
trySell(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,20 +387,68 @@ function confirmSell() {
|
||||
if (!selectedItem.value) return
|
||||
|
||||
const item = selectedItem.value
|
||||
const price = getSellPrice(item)
|
||||
const sellCount = item.sellCount || 1
|
||||
const price = getSellPrice(item) * sellCount
|
||||
|
||||
// 移除物品
|
||||
const result = removeItemFromInventory(player, item.uniqueId || item.id)
|
||||
const result = removeItemFromInventory(player, item.uniqueId || item.id, sellCount)
|
||||
|
||||
if (result.success) {
|
||||
// 增加金币
|
||||
player.currency.copper += price
|
||||
game.addLog(`出售了 ${item.name},获得 ${price} 铜币`, 'reward')
|
||||
const countText = sellCount > 1 ? `x${sellCount}` : ''
|
||||
game.addLog(`出售了 ${item.name}${countText},获得 ${price} 铜币`, 'reward')
|
||||
}
|
||||
|
||||
selectedItem.value = null
|
||||
}
|
||||
|
||||
// 确认数量选择出售
|
||||
function confirmQuantitySell() {
|
||||
if (!quantitySelector.value) return
|
||||
|
||||
const { item, selectedCount } = quantitySelector.value
|
||||
const price = getSellPrice(item) * selectedCount
|
||||
|
||||
// 移除指定数量的物品
|
||||
const result = removeItemFromInventory(player, item.uniqueId || item.id, selectedCount)
|
||||
|
||||
if (result.success) {
|
||||
// 增加金币
|
||||
player.currency.copper += price
|
||||
game.addLog(`出售了 ${item.name}x${selectedCount},获得 ${price} 铜币`, 'reward')
|
||||
}
|
||||
|
||||
// 关闭弹窗
|
||||
quantitySelector.value = null
|
||||
}
|
||||
|
||||
// 取消数量选择
|
||||
function cancelQuantitySell() {
|
||||
quantitySelector.value = null
|
||||
}
|
||||
|
||||
// 增加出售数量
|
||||
function increaseSellCount() {
|
||||
if (quantitySelector.value && quantitySelector.value.selectedCount < quantitySelector.value.maxCount) {
|
||||
quantitySelector.value.selectedCount++
|
||||
}
|
||||
}
|
||||
|
||||
// 减少出售数量
|
||||
function decreaseSellCount() {
|
||||
if (quantitySelector.value && quantitySelector.value.selectedCount > 1) {
|
||||
quantitySelector.value.selectedCount--
|
||||
}
|
||||
}
|
||||
|
||||
// 设置最大出售数量
|
||||
function setMaxSellCount() {
|
||||
if (quantitySelector.value) {
|
||||
quantitySelector.value.selectedCount = quantitySelector.value.maxCount
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
emit('close')
|
||||
}
|
||||
@@ -630,4 +727,58 @@ function close() {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
// 数量选择器样式
|
||||
.quantity-selector {
|
||||
&__item-name {
|
||||
display: block;
|
||||
color: $text-primary;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
&__available {
|
||||
display: block;
|
||||
color: $text-secondary;
|
||||
font-size: 24rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
&__controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 24rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
&__count {
|
||||
min-width: 80rpx;
|
||||
text-align: center;
|
||||
color: $text-primary;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
&__preview {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16rpx;
|
||||
background-color: $bg-tertiary;
|
||||
border-radius: 8rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
&__price-label {
|
||||
color: $text-secondary;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
&__price {
|
||||
color: $accent;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
<text class="description-text">{{ currentLocation.description }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 迷你地图 -->
|
||||
<view class="map-panel__minimap">
|
||||
<MiniMap />
|
||||
</view>
|
||||
|
||||
<!-- 战斗状态 -->
|
||||
<view v-if="game.inCombat" class="combat-status">
|
||||
<text class="combat-status__title">⚔️ 战斗中</text>
|
||||
@@ -32,6 +37,17 @@
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 寻找敌人中状态 -->
|
||||
<view v-if="game.isSearching && !game.inCombat" class="searching-status">
|
||||
<text class="searching-status__title">🔍 寻找中...</text>
|
||||
<text class="searching-status__desc">正在寻找新的敌人</text>
|
||||
<view class="searching-status__dots">
|
||||
<text class="dot">●</text>
|
||||
<text class="dot">●</text>
|
||||
<text class="dot">●</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 区域列表 -->
|
||||
<view class="map-panel__locations-header">
|
||||
<text class="locations-title">可前往的区域</text>
|
||||
@@ -108,10 +124,11 @@ import { NPC_CONFIG } from '@/config/npcs.js'
|
||||
import { ENEMY_CONFIG, getRandomEnemyForLocation } from '@/config/enemies.js'
|
||||
import { getShopConfig } from '@/config/shop.js'
|
||||
import { initCombat, getEnvironmentType } from '@/utils/combatSystem.js'
|
||||
import { triggerExploreEvent, tryFlee } from '@/utils/eventSystem.js'
|
||||
import { triggerExploreEvent, tryFlee, startNPCDialogue } from '@/utils/eventSystem.js'
|
||||
import TextButton from '@/components/common/TextButton.vue'
|
||||
import ProgressBar from '@/components/common/ProgressBar.vue'
|
||||
import FilterTabs from '@/components/common/FilterTabs.vue'
|
||||
import MiniMap from '@/components/common/MiniMap.vue'
|
||||
|
||||
const game = useGameStore()
|
||||
const player = usePlayerStore()
|
||||
@@ -235,16 +252,8 @@ const availableNPCs = computed(() => {
|
||||
function talkToNPC(npc) {
|
||||
game.addLog(`与 ${npc.name} 开始对话...`, 'info')
|
||||
|
||||
// 打开 NPC 对话
|
||||
if (npc.dialogue && npc.dialogue.first) {
|
||||
game.drawerState.event = true
|
||||
game.currentEvent = {
|
||||
type: 'npc_dialogue',
|
||||
npcId: npc.id,
|
||||
dialogue: npc.dialogue.first,
|
||||
choices: npc.dialogue.first.choices || []
|
||||
}
|
||||
}
|
||||
// 使用 eventSystem 的 startNPCDialogue 来处理对话
|
||||
startNPCDialogue(game, npc.id, 'first', player)
|
||||
}
|
||||
|
||||
function openInventory() {
|
||||
@@ -343,14 +352,15 @@ function startCombat() {
|
||||
// 获取环境类型
|
||||
const environment = getEnvironmentType(player.currentLocation)
|
||||
|
||||
// 使用 initCombat 初始化战斗
|
||||
game.combatState = initCombat(enemyConfig.id, enemyConfig, environment)
|
||||
// 使用 initCombat 初始化战斗,传入偏好的战斗姿态
|
||||
game.combatState = initCombat(enemyConfig.id, enemyConfig, environment, game.preferredStance)
|
||||
game.inCombat = true
|
||||
}
|
||||
|
||||
function changeStance(stance) {
|
||||
if (game.combatState) {
|
||||
game.combatState.stance = stance
|
||||
game.preferredStance = stance // 记住玩家选择的姿态
|
||||
game.addLog(`切换到${stanceTabs.find(t => t.id === stance)?.label}姿态`, 'combat')
|
||||
}
|
||||
}
|
||||
@@ -380,6 +390,8 @@ function toggleAutoCombat() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 关闭自动战斗时,清除寻找中状态
|
||||
game.isSearching = false
|
||||
game.addLog('自动战斗已关闭', 'info')
|
||||
}
|
||||
}
|
||||
@@ -411,6 +423,10 @@ function toggleAutoCombat() {
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
&__minimap {
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
&__locations-header {
|
||||
padding: 12rpx 16rpx 8rpx;
|
||||
}
|
||||
@@ -472,6 +488,62 @@ function toggleAutoCombat() {
|
||||
}
|
||||
}
|
||||
|
||||
// 寻找中状态样式
|
||||
.searching-status {
|
||||
padding: 16rpx;
|
||||
background-color: rgba($accent, 0.1);
|
||||
border: 1rpx solid $accent;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 16rpx;
|
||||
text-align: center;
|
||||
|
||||
&__title {
|
||||
display: block;
|
||||
color: $accent;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
&__desc {
|
||||
display: block;
|
||||
color: $text-secondary;
|
||||
font-size: 24rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
&__dots {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 12rpx;
|
||||
|
||||
.dot {
|
||||
color: $accent;
|
||||
font-size: 24rpx;
|
||||
animation: pulse 1.5s ease-in-out infinite;
|
||||
|
||||
&:nth-child(2) {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% {
|
||||
opacity: 0.3;
|
||||
transform: scale(0.8);
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
transform: scale(1.2);
|
||||
}
|
||||
}
|
||||
|
||||
.locations-title {
|
||||
color: $text-secondary;
|
||||
font-size: 24rpx;
|
||||
|
||||
@@ -73,30 +73,58 @@
|
||||
<view class="equipment-slots">
|
||||
<view class="equipment-slot" :class="{ 'equipment-slot--empty': !player.equipment.weapon }">
|
||||
<text class="equipment-slot__label">武器</text>
|
||||
<text v-if="player.equipment.weapon" class="equipment-slot__item">
|
||||
{{ player.equipment.weapon.icon }} {{ player.equipment.weapon.name }}
|
||||
</text>
|
||||
<view v-if="player.equipment.weapon" class="equipment-slot__item">
|
||||
<text class="equipment-slot__name" :style="{ color: player.equipment.weapon.qualityColor }">
|
||||
{{ player.equipment.weapon.icon }} {{ player.equipment.weapon.name }}
|
||||
</text>
|
||||
<text class="equipment-slot__stats">攻{{ player.equipment.weapon.finalDamage }}</text>
|
||||
<text class="equipment-slot__quality">[{{ player.equipment.weapon.qualityName }}]</text>
|
||||
</view>
|
||||
<text v-else class="equipment-slot__empty">空</text>
|
||||
</view>
|
||||
<view class="equipment-slot" :class="{ 'equipment-slot--empty': !player.equipment.armor }">
|
||||
<text class="equipment-slot__label">防具</text>
|
||||
<text v-if="player.equipment.armor" class="equipment-slot__item">
|
||||
{{ player.equipment.armor.icon }} {{ player.equipment.armor.name }}
|
||||
</text>
|
||||
<view v-if="player.equipment.armor" class="equipment-slot__item">
|
||||
<text class="equipment-slot__name" :style="{ color: player.equipment.armor.qualityColor }">
|
||||
{{ player.equipment.armor.icon }} {{ player.equipment.armor.name }}
|
||||
</text>
|
||||
<text class="equipment-slot__stats">防{{ player.equipment.armor.finalDefense }}</text>
|
||||
<text class="equipment-slot__quality">[{{ player.equipment.armor.qualityName }}]</text>
|
||||
</view>
|
||||
<text v-else class="equipment-slot__empty">空</text>
|
||||
</view>
|
||||
<view class="equipment-slot" :class="{ 'equipment-slot--empty': !player.equipment.shield }">
|
||||
<text class="equipment-slot__label">盾牌</text>
|
||||
<text v-if="player.equipment.shield" class="equipment-slot__item">
|
||||
{{ player.equipment.shield.icon }} {{ player.equipment.shield.name }}
|
||||
</text>
|
||||
<view v-if="player.equipment.shield" class="equipment-slot__item">
|
||||
<text class="equipment-slot__name" :style="{ color: player.equipment.shield.qualityColor }">
|
||||
{{ player.equipment.shield.icon }} {{ player.equipment.shield.name }}
|
||||
</text>
|
||||
<text class="equipment-slot__stats">格挡{{ player.equipment.shield.finalShield }}</text>
|
||||
<text class="equipment-slot__quality">[{{ player.equipment.shield.qualityName }}]</text>
|
||||
</view>
|
||||
<text v-else class="equipment-slot__empty">空</text>
|
||||
</view>
|
||||
<view class="equipment-slot" :class="{ 'equipment-slot--empty': !player.equipment.accessory }">
|
||||
<text class="equipment-slot__label">饰品</text>
|
||||
<text v-if="player.equipment.accessory" class="equipment-slot__item">
|
||||
{{ player.equipment.accessory.icon }} {{ player.equipment.accessory.name }}
|
||||
</text>
|
||||
<view v-if="player.equipment.accessory" class="equipment-slot__item">
|
||||
<text class="equipment-slot__name" :style="{ color: player.equipment.accessory.qualityColor }">
|
||||
{{ player.equipment.accessory.icon }} {{ player.equipment.accessory.name }}
|
||||
</text>
|
||||
<text class="equipment-slot__quality">[{{ player.equipment.accessory.qualityName }}]</text>
|
||||
</view>
|
||||
<text v-else class="equipment-slot__empty">空</text>
|
||||
</view>
|
||||
<view class="equipment-slot" :class="{ 'equipment-slot--empty': !player.equipment.prosthetic }">
|
||||
<text class="equipment-slot__label">义体</text>
|
||||
<view v-if="player.equipment.prosthetic" class="equipment-slot__item">
|
||||
<text class="equipment-slot__name" style="color: #ff6b9d;">
|
||||
{{ player.equipment.prosthetic.icon }} {{ player.equipment.prosthetic.name }}
|
||||
</text>
|
||||
<text v-if="player.equipment.prosthetic.stats" class="equipment-slot__stats">
|
||||
{{ formatProstheticStats(player.equipment.prosthetic.stats) }}
|
||||
</text>
|
||||
<text v-if="player.equipment.prosthetic.skill" class="equipment-slot__quality">[{{ getProstheticSkillName(player.equipment.prosthetic.skill) }}]</text>
|
||||
</view>
|
||||
<text v-else class="equipment-slot__empty">空</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -127,18 +155,47 @@
|
||||
<!-- 技能列表 -->
|
||||
<scroll-view class="status-panel__skills" scroll-y>
|
||||
<view v-for="skill in filteredSkills" :key="skill.id" class="skill-item">
|
||||
<text class="skill-item__icon">{{ skill.icon || '⚡' }}</text>
|
||||
<view class="skill-item__info">
|
||||
<text class="skill-item__name">{{ skill.name }}</text>
|
||||
<text class="skill-item__level">Lv.{{ skill.level }}</text>
|
||||
<view class="skill-item__main" @click="toggleSkillDetail(skill.id)">
|
||||
<text class="skill-item__icon">{{ skill.icon || '⚡' }}</text>
|
||||
<view class="skill-item__info">
|
||||
<text class="skill-item__name">{{ skill.name }}</text>
|
||||
<text class="skill-item__level">Lv.{{ skill.level }}/{{ skill.maxLevel }}</text>
|
||||
</view>
|
||||
<view class="skill-item__bar">
|
||||
<ProgressBar
|
||||
:value="skill.exp"
|
||||
:max="skill.maxExp"
|
||||
height="8rpx"
|
||||
:showText="false"
|
||||
/>
|
||||
<text class="skill-item__progress">{{ Math.floor(skill.exp) }}/{{ Math.floor(skill.maxExp) }}</text>
|
||||
</view>
|
||||
<text class="skill-item__expand">{{ expandedSkills.includes(skill.id) ? '▼' : '▶' }}</text>
|
||||
</view>
|
||||
<view class="skill-item__bar">
|
||||
<ProgressBar
|
||||
:value="skill.exp"
|
||||
:max="skill.maxExp"
|
||||
height="8rpx"
|
||||
:showText="false"
|
||||
/>
|
||||
|
||||
<!-- 技能详情(展开后显示) -->
|
||||
<view v-if="expandedSkills.includes(skill.id)" class="skill-item__detail">
|
||||
<!-- 已获得的增幅 -->
|
||||
<view v-if="getActiveMilestones(skill).length > 0" class="skill-detail__section">
|
||||
<text class="skill-detail__title">✓ 已获得增幅</text>
|
||||
<view v-for="m in getActiveMilestones(skill)" :key="m.level" class="skill-detail__bonus">
|
||||
<text class="skill-detail__bonus-level">Lv.{{ m.level }}</text>
|
||||
<text class="skill-detail__bonus-desc">{{ m.desc }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 即将获得的增幅 -->
|
||||
<view v-if="getUpcomingMilestones(skill).length > 0" class="skill-detail__section">
|
||||
<text class="skill-detail__title">即将解锁</text>
|
||||
<view v-for="m in getUpcomingMilestones(skill)" :key="m.level" class="skill-detail__bonus upcoming">
|
||||
<text class="skill-detail__bonus-level">Lv.{{ m.level }}</text>
|
||||
<text class="skill-detail__bonus-desc">{{ m.desc }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="getActiveMilestones(skill).length === 0 && getUpcomingMilestones(skill).length === 0" class="skill-detail__empty">
|
||||
<text class="skill-detail__empty-text">暂无增幅效果</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="filteredSkills.length === 0" class="skill-empty">
|
||||
@@ -261,7 +318,7 @@ import { usePlayerStore } from '@/store/player'
|
||||
import { useGameStore } from '@/store/game'
|
||||
import { SKILL_CONFIG } from '@/config/skills'
|
||||
import { ITEM_CONFIG } from '@/config/items'
|
||||
import { startTask } from '@/utils/taskSystem'
|
||||
import { startTask, endTask } from '@/utils/taskSystem'
|
||||
import { getSkillDisplayInfo } from '@/utils/skillSystem'
|
||||
import ProgressBar from '@/components/common/ProgressBar.vue'
|
||||
import StatItem from '@/components/common/StatItem.vue'
|
||||
@@ -276,6 +333,7 @@ const currentSkillFilter = ref('all')
|
||||
const showBooks = ref(false)
|
||||
const showTraining = ref(false)
|
||||
const showTasks = ref(true)
|
||||
const expandedSkills = ref([]) // 展开的技能ID列表
|
||||
|
||||
const skillFilterTabs = [
|
||||
{ id: 'all', label: '全部' },
|
||||
@@ -381,6 +439,42 @@ const readingTimeText = computed(() => {
|
||||
return `剩余 ${minutes}:${String(seconds).padStart(2, '0')}`
|
||||
})
|
||||
|
||||
// 技能详情相关函数
|
||||
function toggleSkillDetail(skillId) {
|
||||
const index = expandedSkills.value.indexOf(skillId)
|
||||
if (index > -1) {
|
||||
expandedSkills.value.splice(index, 1)
|
||||
} else {
|
||||
expandedSkills.value.push(skillId)
|
||||
}
|
||||
}
|
||||
|
||||
function getActiveMilestones(skill) {
|
||||
const config = SKILL_CONFIG[skill.id]
|
||||
if (!config || !config.milestones) return []
|
||||
|
||||
return Object.entries(config.milestones)
|
||||
.filter(([level]) => parseInt(level) <= skill.level)
|
||||
.map(([level, milestone]) => ({
|
||||
level: parseInt(level),
|
||||
desc: milestone.desc
|
||||
}))
|
||||
.sort((a, b) => a.level - b.level)
|
||||
}
|
||||
|
||||
function getUpcomingMilestones(skill) {
|
||||
const config = SKILL_CONFIG[skill.id]
|
||||
if (!config || !config.milestones) return []
|
||||
|
||||
return Object.entries(config.milestones)
|
||||
.filter(([level]) => parseInt(level) > skill.level)
|
||||
.map(([level, milestone]) => ({
|
||||
level: parseInt(level),
|
||||
desc: milestone.desc
|
||||
}))
|
||||
.sort((a, b) => a.level - b.level)
|
||||
}
|
||||
|
||||
function startReading(book) {
|
||||
const result = startTask(game, player, 'reading', {
|
||||
itemId: book.id,
|
||||
@@ -426,7 +520,7 @@ const trainingTask = computed(() => {
|
||||
function startTraining(skill) {
|
||||
const result = startTask(game, player, 'training', {
|
||||
skillId: skill.id,
|
||||
duration: 300 // 5分钟
|
||||
duration: 60 // 1分钟
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
@@ -438,7 +532,6 @@ function startTraining(skill) {
|
||||
|
||||
function stopTraining() {
|
||||
if (trainingTask.value) {
|
||||
const { endTask } = require('@/utils/taskSystem')
|
||||
endTask(game, player, trainingTask.value.taskId, false)
|
||||
game.addLog('停止了训练', 'info')
|
||||
}
|
||||
@@ -495,6 +588,26 @@ function cancelActiveTask(task) {
|
||||
endTask(game, player, task.id, false)
|
||||
game.addLog(`取消了 ${task.name}`, 'info')
|
||||
}
|
||||
|
||||
// 义体相关辅助函数
|
||||
function formatProstheticStats(stats) {
|
||||
if (!stats) return ''
|
||||
const parts = []
|
||||
if (stats.strength) parts.push(`力+${stats.strength}`)
|
||||
if (stats.agility) parts.push(`敏+${stats.agility}`)
|
||||
if (stats.dexterity) parts.push(`灵+${stats.dexterity}`)
|
||||
if (stats.intuition) parts.push(`智+${stats.intuition}`)
|
||||
if (stats.vitality) parts.push(`体+${stats.vitality}`)
|
||||
if (stats.attack) parts.push(`攻+${stats.attack}`)
|
||||
if (stats.defense) parts.push(`防+${stats.defense}`)
|
||||
return parts.join(' ')
|
||||
}
|
||||
|
||||
function getProstheticSkillName(skillId) {
|
||||
const { SKILL_CONFIG } = require('@/config/skills')
|
||||
const skill = SKILL_CONFIG[skillId]
|
||||
return skill ? skill.name : skillId
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -598,12 +711,19 @@ function cancelActiveTask(task) {
|
||||
|
||||
.skill-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
padding: 12rpx;
|
||||
flex-direction: column;
|
||||
background-color: $bg-secondary;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 8rpx;
|
||||
overflow: hidden;
|
||||
|
||||
&__main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
padding: 12rpx;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
font-size: 32rpx;
|
||||
@@ -631,6 +751,81 @@ function cancelActiveTask(task) {
|
||||
&__bar {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
&__progress {
|
||||
color: $text-muted;
|
||||
font-size: 20rpx;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
&__expand {
|
||||
color: $text-muted;
|
||||
font-size: 20rpx;
|
||||
padding-left: 8rpx;
|
||||
}
|
||||
|
||||
&__detail {
|
||||
padding: 12rpx;
|
||||
padding-top: 0;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.skill-detail {
|
||||
&__section {
|
||||
margin-bottom: 12rpx;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&__title {
|
||||
color: $text-primary;
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 8rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&__bonus {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
padding: 6rpx 12rpx;
|
||||
background-color: rgba(78, 205, 196, 0.1);
|
||||
border-radius: 4rpx;
|
||||
margin-bottom: 6rpx;
|
||||
|
||||
&.upcoming {
|
||||
background-color: rgba(255, 107, 107, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
&__bonus-level {
|
||||
color: $accent;
|
||||
font-size: 22rpx;
|
||||
font-weight: bold;
|
||||
min-width: 60rpx;
|
||||
}
|
||||
|
||||
&__bonus-desc {
|
||||
color: $text-secondary;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
&__empty {
|
||||
padding: 16rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__empty-text {
|
||||
color: $text-muted;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,8 +873,26 @@ function cancelActiveTask(task) {
|
||||
}
|
||||
|
||||
&__item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 2rpx;
|
||||
}
|
||||
|
||||
&__name {
|
||||
color: $text-primary;
|
||||
font-size: 22rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__stats {
|
||||
color: $accent;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
&__quality {
|
||||
color: $text-muted;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
|
||||
&__empty {
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* 成就系统配置
|
||||
*/
|
||||
export const ACHIEVEMENT_CONFIG = {
|
||||
// ===== 战斗成就 =====
|
||||
first_blood: {
|
||||
id: 'first_blood',
|
||||
name: '初露锋芒',
|
||||
description: '击败第一个敌人',
|
||||
icon: '⚔️',
|
||||
condition: { type: 'kill', count: 1 },
|
||||
reward: { copper: 100, exp: 20 }
|
||||
},
|
||||
|
||||
hunter: {
|
||||
id: 'hunter',
|
||||
name: '狩猎者',
|
||||
description: '击败10个敌人',
|
||||
icon: '🏹',
|
||||
condition: { type: 'kill', count: 10 },
|
||||
reward: { copper: 500, exp: 100 }
|
||||
},
|
||||
|
||||
slayer: {
|
||||
id: 'slayer',
|
||||
name: '屠戮者',
|
||||
description: '击败100个敌人',
|
||||
icon: '💀',
|
||||
condition: { type: 'kill', count: 100 },
|
||||
reward: { copper: 5000, exp: 1000, item: 'iron_sword' }
|
||||
},
|
||||
|
||||
// ===== Boss成就 =====
|
||||
boss_slayer: {
|
||||
id: 'boss_slayer',
|
||||
name: '弑君者',
|
||||
description: '击败一个Boss',
|
||||
icon: '👑',
|
||||
condition: { type: 'boss_kill', count: 1 },
|
||||
reward: { copper: 2000, exp: 500 }
|
||||
},
|
||||
|
||||
// ===== 义体成就 =====
|
||||
prosthetic_user: {
|
||||
id: 'prosthetic_user',
|
||||
name: '机械飞升',
|
||||
description: '安装第一个义体',
|
||||
icon: '🦾',
|
||||
condition: { type: 'equip_prosthetic', count: 1 },
|
||||
reward: { copper: 1000, exp: 200 }
|
||||
},
|
||||
|
||||
full_conversion: {
|
||||
id: 'full_conversion',
|
||||
name: '完全机械化',
|
||||
description: '同时装备4个义体',
|
||||
icon: '🤖',
|
||||
condition: { type: 'equip_prosthetic', count: 4 },
|
||||
reward: { copper: 10000, exp: 2000 }
|
||||
},
|
||||
|
||||
// ===== 技能成就 =====
|
||||
skill_master: {
|
||||
id: 'skill_master',
|
||||
name: '宗师',
|
||||
description: '任意技能达到20级',
|
||||
icon: '📜',
|
||||
condition: { type: 'skill_level', level: 20 },
|
||||
reward: { copper: 3000, exp: 500 }
|
||||
},
|
||||
|
||||
// ===== 探索成就 =====
|
||||
explorer: {
|
||||
id: 'explorer',
|
||||
name: '探险家',
|
||||
description: '访问所有区域',
|
||||
icon: '🗺️',
|
||||
condition: { type: 'visit_locations', count: 99 },
|
||||
reward: { copper: 2000, exp: 300 }
|
||||
},
|
||||
|
||||
// ===== 财富成就 =====
|
||||
wealthy: {
|
||||
id: 'wealthy',
|
||||
name: '小有积蓄',
|
||||
description: '累计获得10000铜币',
|
||||
icon: '💰',
|
||||
condition: { type: 'total_earned', amount: 10000 },
|
||||
reward: { item: 'lucky_ring' }
|
||||
},
|
||||
|
||||
// ===== 生存成就 =====
|
||||
survivor: {
|
||||
id: 'survivor',
|
||||
name: '幸存者',
|
||||
description: '存活10天',
|
||||
icon: '🌅',
|
||||
condition: { type: 'survive_days', days: 10 },
|
||||
reward: { copper: 1000, exp: 200 }
|
||||
},
|
||||
|
||||
veteran: {
|
||||
id: 'veteran',
|
||||
name: '老兵',
|
||||
description: '存活30天',
|
||||
icon: '🎖️',
|
||||
condition: { type: 'survive_days', days: 30 },
|
||||
reward: { copper: 5000, exp: 1000, item: 'iron_armor' }
|
||||
}
|
||||
}
|
||||
+43
-7
@@ -1,4 +1,4 @@
|
||||
// 游戏数值常量
|
||||
// 游戏数值常量 - 与数学模型文档保持一致
|
||||
export const GAME_CONSTANTS = {
|
||||
// 时间流速:现实1秒 = 游戏时间5分钟
|
||||
TIME_SCALE: 5,
|
||||
@@ -14,13 +14,49 @@ export const GAME_CONSTANTS = {
|
||||
// 经验倍率
|
||||
EXP_PARTIAL_SUCCESS: 0.5, // 部分成功时经验比例
|
||||
|
||||
// 品质等级
|
||||
// 品质等级 - 与数学模型文档一致
|
||||
QUALITY_LEVELS: {
|
||||
1: { name: '垃圾', color: '#808080', range: [0, 49], multiplier: 1.0 },
|
||||
1: { name: '垃圾', color: '#6b7280', range: [0, 49], multiplier: 0.5 },
|
||||
2: { name: '普通', color: '#ffffff', range: [50, 99], multiplier: 1.0 },
|
||||
3: { name: '优秀', color: '#4ade80', range: [100, 129], multiplier: 1.1 },
|
||||
4: { name: '稀有', color: '#60a5fa', range: [130, 159], multiplier: 1.3 },
|
||||
5: { name: '史诗', color: '#a855f7', range: [160, 199], multiplier: 1.6 },
|
||||
6: { name: '传说', color: '#f97316', range: [200, 250], multiplier: 2.0 }
|
||||
3: { name: '优秀', color: '#22c55e', range: [100, 139], multiplier: 1.2 },
|
||||
4: { name: '稀有', color: '#3b82f6', range: [140, 169], multiplier: 1.5 },
|
||||
5: { name: '史诗', color: '#a855f7', range: [170, 199], multiplier: 2.0 },
|
||||
6: { name: '传说', color: '#f59e0b', range: [200, 250], multiplier: 3.0 }
|
||||
},
|
||||
|
||||
// 属性缩放系数
|
||||
STAT_SCALING: {
|
||||
STRENGTH_TO_ATTACK: 1.0, // 1力量 = 1攻击力
|
||||
AGILITY_TO_DODGE: 0.5, // 1敏捷 = 0.5%闪避
|
||||
DEXTERITY_TO_CRIT: 0.3, // 1灵巧 = 0.3%暴击
|
||||
INTUITION_TO_QUALITY: 0.5, // 1智力 = 0.5品质
|
||||
VITALITY_TO_HP: 10, // 1体质 = 10生命
|
||||
VITALITY_TO_REGEN: 0.05 // 1体质 = 0.05 HP/秒回复
|
||||
},
|
||||
|
||||
// 装备品质系统
|
||||
QUALITY: {
|
||||
BASE_MULTIPLIER: 0.01, // 品质每1点 = 1%属性
|
||||
LEVEL_BONUS: 2, // 每级额外+2品质
|
||||
MAX_QUALITY: 250,
|
||||
MIN_QUALITY: 0
|
||||
},
|
||||
|
||||
// 词缀系统
|
||||
AFFIX: {
|
||||
MAX_COUNT: 3, // 每件装备最多词缀数量
|
||||
COMMON_CHANCE: 0.60, // 普通词缀概率
|
||||
RARE_CHANCE: 0.30, // 稀有词缀概率
|
||||
EPIC_CHANCE: 0.09, // 史诗词缀概率
|
||||
LEGENDARY_CHANCE: 0.01 // 传说词缀概率
|
||||
},
|
||||
|
||||
// 怪物缩放
|
||||
MONSTER: {
|
||||
HP_SCALING: 1.12, // 每级HP增长12%
|
||||
ATTACK_SCALING: 1.08, // 每级攻击增长8%
|
||||
DEFENSE_SCALING: 1.06, // 每级防御增长6%
|
||||
EXP_SCALING: 1.10, // 每级经验奖励增长10%
|
||||
LEVEL_VARANCE: 0.2 // 等级浮动±20%
|
||||
}
|
||||
}
|
||||
|
||||
+46
-8
@@ -14,11 +14,16 @@ export const ENEMY_CONFIG = {
|
||||
health: 35,
|
||||
attack: 8,
|
||||
defense: 2,
|
||||
strength: 8, // 力量,影响攻击
|
||||
agility: 6, // 敏捷,影响闪避(降低EP,提高玩家命中率)
|
||||
dexterity: 7, // 灵巧,影响命中
|
||||
intuition: 3, // 智力,影响AP/EP
|
||||
vitality: 8, // 体质
|
||||
speed: 1.2
|
||||
},
|
||||
derivedStats: {
|
||||
ap: 8,
|
||||
ep: 10
|
||||
ep: 6 // 降低EP值,使玩家更容易命中
|
||||
},
|
||||
expReward: 20,
|
||||
skillExpReward: 12,
|
||||
@@ -36,11 +41,16 @@ export const ENEMY_CONFIG = {
|
||||
health: 20,
|
||||
attack: 5,
|
||||
defense: 1,
|
||||
strength: 5,
|
||||
agility: 10, // 高敏捷,难命中
|
||||
dexterity: 6,
|
||||
intuition: 2,
|
||||
vitality: 5,
|
||||
speed: 1.5
|
||||
},
|
||||
derivedStats: {
|
||||
ap: 6,
|
||||
ep: 12
|
||||
ep: 11 // 高闪避,符合老鼠特性
|
||||
},
|
||||
expReward: 10,
|
||||
skillExpReward: 6,
|
||||
@@ -58,11 +68,16 @@ export const ENEMY_CONFIG = {
|
||||
health: 50,
|
||||
attack: 15,
|
||||
defense: 5,
|
||||
strength: 14,
|
||||
agility: 10,
|
||||
dexterity: 12,
|
||||
intuition: 6,
|
||||
vitality: 12,
|
||||
speed: 1.3
|
||||
},
|
||||
derivedStats: {
|
||||
ap: 14,
|
||||
ep: 13
|
||||
ep: 11
|
||||
},
|
||||
expReward: 40,
|
||||
skillExpReward: 20,
|
||||
@@ -80,6 +95,11 @@ export const ENEMY_CONFIG = {
|
||||
health: 60,
|
||||
attack: 18,
|
||||
defense: 8,
|
||||
strength: 16,
|
||||
agility: 9,
|
||||
dexterity: 14,
|
||||
intuition: 8,
|
||||
vitality: 15,
|
||||
speed: 1.0
|
||||
},
|
||||
derivedStats: {
|
||||
@@ -103,17 +123,23 @@ export const ENEMY_CONFIG = {
|
||||
health: 250,
|
||||
attack: 30,
|
||||
defense: 15,
|
||||
strength: 25,
|
||||
agility: 14,
|
||||
dexterity: 20,
|
||||
intuition: 12,
|
||||
vitality: 25,
|
||||
speed: 1.1
|
||||
},
|
||||
derivedStats: {
|
||||
ap: 30,
|
||||
ep: 18
|
||||
ep: 16
|
||||
},
|
||||
expReward: 200,
|
||||
skillExpReward: 80,
|
||||
drops: [
|
||||
{ itemId: 'basement_key', chance: 1.0, count: { min: 1, max: 1 } },
|
||||
{ itemId: 'dog_skin', chance: 0.5, count: { min: 2, max: 4 } }
|
||||
{ itemId: 'dog_skin', chance: 0.5, count: { min: 2, max: 4 } },
|
||||
{ itemId: 'steel_arm_prosthetic', chance: 0.3, count: { min: 1, max: 1 }, fixedQuality: true } // 义体掉落
|
||||
],
|
||||
isBoss: true
|
||||
},
|
||||
@@ -127,11 +153,16 @@ export const ENEMY_CONFIG = {
|
||||
health: 40,
|
||||
attack: 25,
|
||||
defense: 3,
|
||||
strength: 20,
|
||||
agility: 16, // 高闪避
|
||||
dexterity: 18,
|
||||
intuition: 6,
|
||||
vitality: 8,
|
||||
speed: 1.8
|
||||
},
|
||||
derivedStats: {
|
||||
ap: 22,
|
||||
ep: 24
|
||||
ep: 18 // 高闪避,但不是不可能命中
|
||||
},
|
||||
expReward: 70,
|
||||
skillExpReward: 35,
|
||||
@@ -149,17 +180,24 @@ export const ENEMY_CONFIG = {
|
||||
health: 500,
|
||||
attack: 50,
|
||||
defense: 25,
|
||||
strength: 45,
|
||||
agility: 18,
|
||||
dexterity: 35,
|
||||
intuition: 20,
|
||||
vitality: 50,
|
||||
speed: 0.9
|
||||
},
|
||||
derivedStats: {
|
||||
ap: 50,
|
||||
ep: 25
|
||||
ep: 22
|
||||
},
|
||||
expReward: 500,
|
||||
skillExpReward: 200,
|
||||
drops: [
|
||||
{ itemId: 'rare_gem', chance: 0.8, count: { min: 1, max: 1 } },
|
||||
{ itemId: 'iron_sword', chance: 0.3, count: { min: 1, max: 1 } }
|
||||
{ itemId: 'iron_sword', chance: 0.3, count: { min: 1, max: 1 } },
|
||||
{ itemId: 'optical_eye_prosthetic', chance: 0.4, count: { min: 1, max: 1 }, fixedQuality: true },
|
||||
{ itemId: 'dermal_armor_prosthetic', chance: 0.3, count: { min: 1, max: 1 }, fixedQuality: true }
|
||||
],
|
||||
isBoss: true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,498 @@
|
||||
/**
|
||||
* 游戏数值模型配置
|
||||
*
|
||||
* 本文件定义了游戏中所有数值计算的核心公式
|
||||
* 包括:角色属性、装备属性、技能效果、怪物属性等
|
||||
*/
|
||||
|
||||
// ==================== 核心常量 ====================
|
||||
|
||||
export const GAME_FORMULAS = {
|
||||
// 经验曲线系数
|
||||
EXP_BASE: 100, // 基础经验值
|
||||
EXP_GROWTH: 1.15, // 每级经验增长倍数
|
||||
|
||||
// 属性缩放系数
|
||||
STAT_SCALING: {
|
||||
STRENGTH_TO_ATTACK: 1.0, // 1力量 = 1攻击力
|
||||
AGILITY_TO_DODGE: 0.5, // 1敏捷 = 0.5%闪避
|
||||
DEXTERITY_TO_CRIT: 0.3, // 1灵巧 = 0.3%暴击
|
||||
INTUITION_TO_QUALITY: 0.5, // 1智力 = 0.5品质
|
||||
VITALITY_TO_HP: 10, // 1体质 = 10生命
|
||||
VITALITY_TO_REGEN: 0.05 // 1体质 = 0.05 HP/秒回复
|
||||
},
|
||||
|
||||
// 装备品质系统
|
||||
QUALITY: {
|
||||
BASE_MULTIPLIER: 0.01, // 品质每1点 = 1%属性
|
||||
LEVEL_BONUS: 2, // 每级额外+2品质
|
||||
MAX_QUALITY: 250,
|
||||
MIN_QUALITY: 0
|
||||
},
|
||||
|
||||
// 词缀系统
|
||||
AFFIX: {
|
||||
MAX_COUNT: 3, // 每件装备最多词缀数量
|
||||
COMMON_CHANCE: 0.60, // 普通词缀概率
|
||||
RARE_CHANCE: 0.30, // 稀有词缀概率
|
||||
EPIC_CHANCE: 0.09, // 史诗词缀概率
|
||||
LEGENDARY_CHANCE: 0.01 // 传说词缀概率
|
||||
},
|
||||
|
||||
// 怪物缩放
|
||||
MONSTER: {
|
||||
HP_SCALING: 1.12, // 每级HP增长12%
|
||||
ATTACK_SCALING: 1.08, // 每级攻击增长8%
|
||||
DEFENSE_SCALING: 1.06, // 每级防御增长6%
|
||||
EXP_SCALING: 1.10, // 每级经验奖励增长10%
|
||||
LEVEL_VARANCE: 0.2 // 等级浮动±20%
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 角色属性计算 ====================
|
||||
|
||||
/**
|
||||
* 计算角色基础属性
|
||||
* @param {Object} baseStats - 基础属性 {strength, agility, dexterity, intuition, vitality}
|
||||
* @param {Number} level - 角色等级
|
||||
* @returns {Object} 计算后的属性
|
||||
*/
|
||||
export function calculateCharacterStats(baseStats, level = 1) {
|
||||
const s = GAME_FORMULAS.STAT_SCALING
|
||||
|
||||
// 基础生命值 = 100 + 体质 * 10 + 等级 * 5
|
||||
const baseHP = 100 + (baseStats.vitality || 10) * s.VITALITY_TO_HP + level * 5
|
||||
|
||||
// 基础耐力 = 80 + 体质 * 5 + 等级 * 3
|
||||
const baseStamina = 80 + (baseStats.vitality || 10) * 5 + level * 3
|
||||
|
||||
// 基础精神 = 100 + 智力 * 3
|
||||
const baseSanity = 100 + (baseStats.intuition || 10) * 3
|
||||
|
||||
// 基础攻击力 = 力量 * 1 + 等级 * 2
|
||||
const baseAttack = (baseStats.strength || 10) * s.STRENGTH_TO_ATTACK + level * 2
|
||||
|
||||
// 基础防御 = 敏捷 * 0.3 + 体质 * 0.2 + 等级
|
||||
const baseDefense = (baseStats.agility || 8) * 0.3 + (baseStats.vitality || 10) * 0.2 + level
|
||||
|
||||
// 基础暴击率 = 灵巧 * 0.3% (基础值5%)
|
||||
const baseCritRate = 5 + (baseStats.dexterity || 8) * s.DEXTERITY_TO_CRIT
|
||||
|
||||
// 基础闪避率 = 敏捷 * 0.5%
|
||||
const baseDodgeRate = (baseStats.agility || 8) * s.AGILITY_TO_DODGE
|
||||
|
||||
return {
|
||||
hp: Math.floor(baseHP),
|
||||
stamina: Math.floor(baseStamina),
|
||||
sanity: Math.floor(baseSanity),
|
||||
attack: Math.floor(baseAttack),
|
||||
defense: Math.floor(baseDefense),
|
||||
critRate: Math.floor(baseCritRate * 10) / 10,
|
||||
dodgeRate: Math.floor(baseDodgeRate * 10) / 10
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算装备后的最终属性
|
||||
* @param {Object} baseStats - 基础属性
|
||||
* @param {Object} equipmentStats - 装备提供的属性
|
||||
* @returns {Object} 最终属性
|
||||
*/
|
||||
export function calculateFinalStats(baseStats, equipmentStats = {}) {
|
||||
const final = { ...baseStats }
|
||||
|
||||
// 装备属性加成(百分比和固定值混合)
|
||||
if (equipmentStats.attackBonus) {
|
||||
final.attack += Math.floor(baseStats.attack * (equipmentStats.attackBonus / 100))
|
||||
final.attack += equipmentStats.attack || 0
|
||||
}
|
||||
if (equipmentStats.defenseBonus) {
|
||||
final.defense += Math.floor(baseStats.defense * (equipmentStats.defenseBonus / 100))
|
||||
final.defense += equipmentStats.defense || 0
|
||||
}
|
||||
if (equipmentStats.critRate) {
|
||||
final.critRate += equipmentStats.critRate
|
||||
}
|
||||
if (equipmentStats.dodgeRate) {
|
||||
final.dodgeRate += equipmentStats.dodgeRate
|
||||
}
|
||||
if (equipmentStats.maxHP) {
|
||||
final.hp += equipmentStats.maxHP
|
||||
}
|
||||
if (equipmentStats.maxStamina) {
|
||||
final.stamina += equipmentStats.maxStamina
|
||||
}
|
||||
|
||||
// 限制范围
|
||||
final.critRate = Math.min(95, Math.max(0, final.critRate))
|
||||
final.dodgeRate = Math.min(80, Math.max(0, final.dodgeRate))
|
||||
|
||||
return final
|
||||
}
|
||||
|
||||
// ==================== 装备属性计算 ====================
|
||||
|
||||
/**
|
||||
* 计算装备的最终属性
|
||||
* @param {Object} baseItem - 基础物品配置
|
||||
* @param {Number} quality - 品质值 (0-250)
|
||||
* @param {Number} itemLevel - 物品等级
|
||||
* @param {Array} affixes - 词缀列表
|
||||
* @returns {Object} 计算后的装备属性
|
||||
*/
|
||||
export function calculateEquipmentStats(baseItem, quality = 100, itemLevel = 1, affixes = []) {
|
||||
const q = GAME_FORMULAS.QUALITY
|
||||
const stats = { ...baseItem }
|
||||
|
||||
// 1. 品质倍率计算
|
||||
// 品质倍率 = 1 + (品质 - 100) * 0.01
|
||||
// 品质100 = 1.0倍,品质150 = 1.5倍,品质50 = 0.5倍
|
||||
const qualityMultiplier = 1 + (quality - 100) * q.BASE_MULTIPLIER
|
||||
|
||||
// 2. 等级倍率
|
||||
// 每级增加2%属性
|
||||
const levelMultiplier = 1 + (itemLevel - 1) * 0.02
|
||||
|
||||
// 3. 综合倍率
|
||||
const totalMultiplier = qualityMultiplier * levelMultiplier
|
||||
|
||||
// 4. 计算基础属性
|
||||
if (baseItem.baseDamage) {
|
||||
stats.finalDamage = Math.max(1, Math.floor(baseItem.baseDamage * totalMultiplier))
|
||||
}
|
||||
if (baseItem.baseDefense) {
|
||||
stats.finalDefense = Math.max(1, Math.floor(baseItem.baseDefense * totalMultiplier))
|
||||
}
|
||||
if (baseItem.blockRate) {
|
||||
stats.finalBlockRate = Math.min(75, baseItem.blockRate + quality * 0.02)
|
||||
}
|
||||
|
||||
// 5. 应用词缀
|
||||
const affixStats = calculateAffixStats(affixes, itemLevel)
|
||||
Object.assign(stats, affixStats)
|
||||
|
||||
// 6. 计算价值
|
||||
stats.finalValue = Math.floor(baseItem.baseValue * totalMultiplier * (1 + affixes.length * 0.2))
|
||||
|
||||
// 7. 品质信息
|
||||
stats.quality = quality
|
||||
stats.itemLevel = itemLevel
|
||||
stats.qualityLevel = getQualityLevel(quality)
|
||||
stats.affixes = affixes
|
||||
|
||||
return stats
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算词缀属性
|
||||
* @param {Array} affixes - 词缀列表
|
||||
* @param {Number} itemLevel - 物品等级
|
||||
* @returns {Object} 词缀提供的属性
|
||||
*/
|
||||
export function calculateAffixStats(affixes, itemLevel = 1) {
|
||||
const stats = {}
|
||||
|
||||
for (const affix of affixes) {
|
||||
// 词缀属性随物品等级缩放
|
||||
const scale = 1 + (itemLevel - 1) * 0.1
|
||||
|
||||
switch (affix.type) {
|
||||
case 'attack':
|
||||
stats.attackBonus = (stats.attackBonus || 0) + affix.value * scale
|
||||
break
|
||||
case 'defense':
|
||||
stats.defenseBonus = (stats.defenseBonus || 0) + affix.value * scale
|
||||
break
|
||||
case 'critRate':
|
||||
stats.critRate = (stats.critRate || 0) + affix.value * scale
|
||||
break
|
||||
case 'dodge':
|
||||
stats.dodgeRate = (stats.dodgeRate || 0) + affix.value * scale
|
||||
break
|
||||
case 'hp':
|
||||
stats.maxHP = (stats.maxHP || 0) + affix.value * scale
|
||||
break
|
||||
case 'stamina':
|
||||
stats.maxStamina = (stats.maxStamina || 0) + affix.value * scale
|
||||
break
|
||||
case 'fireDamage':
|
||||
stats.fireDamage = (stats.fireDamage || 0) + affix.value * scale
|
||||
break
|
||||
case 'speed':
|
||||
stats.attackSpeed = (stats.attackSpeed || 1) + affix.value * 0.01 * scale
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return stats
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取品质等级
|
||||
* 与 constants.js 中的 QUALITY_LEVELS 保持一致
|
||||
*/
|
||||
export function getQualityLevel(quality) {
|
||||
if (quality < 50) return { level: 1, name: '垃圾', color: '#6b7280', multiplier: 0.5 }
|
||||
if (quality < 100) return { level: 2, name: '普通', color: '#ffffff', multiplier: 1.0 }
|
||||
if (quality < 140) return { level: 3, name: '优秀', color: '#22c55e', multiplier: 1.2 }
|
||||
if (quality < 170) return { level: 4, name: '稀有', color: '#3b82f6', multiplier: 1.5 }
|
||||
if (quality < 200) return { level: 5, name: '史诗', color: '#a855f7', multiplier: 2.0 }
|
||||
return { level: 6, name: '传说', color: '#f59e0b', multiplier: 3.0 }
|
||||
}
|
||||
|
||||
// ==================== 词缀生成 ====================
|
||||
|
||||
/**
|
||||
* 词缀池定义
|
||||
*/
|
||||
export const AFFIX_POOL = {
|
||||
// 武器词缀
|
||||
weapon: [
|
||||
{ id: 'sharp', name: '锋利', type: 'attack', value: 5, rarity: 'common' },
|
||||
{ id: 'keen', name: '锐利', type: 'critRate', value: 3, rarity: 'common' },
|
||||
{ id: 'swift', name: '轻盈', type: 'speed', value: 10, rarity: 'common' },
|
||||
{ id: 'vicious', name: '残暴', type: 'attack', value: 12, rarity: 'rare' },
|
||||
{ id: 'deadly', name: '致命', type: 'critRate', value: 8, rarity: 'rare' },
|
||||
{ id: 'flaming', name: '烈焰', type: 'fireDamage', value: 10, rarity: 'epic' },
|
||||
{ id: 'godslayer', name: '弑神', type: 'attack', value: 25, rarity: 'legendary' }
|
||||
],
|
||||
// 防具词缀
|
||||
armor: [
|
||||
{ id: 'sturdy', name: '坚固', type: 'defense', value: 5, rarity: 'common' },
|
||||
{ id: 'agile', name: '灵活', type: 'dodge', value: 3, rarity: 'common' },
|
||||
{ id: 'healthy', name: '健康', type: 'hp', value: 20, rarity: 'common' },
|
||||
{ id: 'fortified', name: '强化', type: 'defense', value: 12, rarity: 'rare' },
|
||||
{ id: 'enduring', name: '耐久', type: 'stamina', value: 15, rarity: 'rare' },
|
||||
{ id: 'ironclad', name: '铁壁', type: 'defense', value: 25, rarity: 'epic' },
|
||||
{ id: 'immortal', name: '不朽', type: 'hp', value: 100, rarity: 'legendary' }
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成词缀
|
||||
* @param {String} itemType - 物品类型 (weapon/armor)
|
||||
* @param {Number} quality - 品质值
|
||||
* @returns {Array} 词缀数组
|
||||
*/
|
||||
export function generateAffixes(itemType, quality) {
|
||||
const pool = AFFIX_POOL[itemType] || []
|
||||
if (pool.length === 0) return []
|
||||
|
||||
// 根据品质决定最大词缀数量
|
||||
const maxAffixes = quality < 90 ? 0
|
||||
: quality < 130 ? 1
|
||||
: quality < 160 ? 2
|
||||
: GAME_FORMULAS.AFFIX.MAX_COUNT
|
||||
|
||||
if (maxAffixes === 0) return []
|
||||
|
||||
const affixes = []
|
||||
const used = new Set()
|
||||
|
||||
// 决定每个词缀的稀有度
|
||||
for (let i = 0; i < maxAffixes; i++) {
|
||||
const roll = Math.random()
|
||||
let rarity
|
||||
|
||||
if (roll < GAME_FORMULAS.AFFIX.LEGENDARY_CHANCE) rarity = 'legendary'
|
||||
else if (roll < GAME_FORMULAS.AFFIX.LEGENDARY_CHANCE + GAME_FORMULAS.AFFIX.EPIC_CHANCE) rarity = 'epic'
|
||||
else if (roll < GAME_FORMULAS.AFFIX.LEGENDARY_CHANCE + GAME_FORMULAS.AFFIX.EPIC_CHANCE + GAME_FORMULAS.AFFIX.RARE_CHANCE) rarity = 'rare'
|
||||
else rarity = 'common'
|
||||
|
||||
// 从对应稀有度池中选择词缀
|
||||
const available = pool.filter(a => a.rarity === rarity && !used.has(a.id))
|
||||
|
||||
// 如果该稀有度没有可用词缀,降级选择
|
||||
const fallback = available.length > 0 ? available : pool.filter(a => !used.has(a.id))
|
||||
|
||||
if (fallback.length > 0) {
|
||||
const affix = fallback[Math.floor(Math.random() * fallback.length)]
|
||||
affixes.push(affix)
|
||||
used.add(affix.id)
|
||||
}
|
||||
}
|
||||
|
||||
return affixes
|
||||
}
|
||||
|
||||
// ==================== 怪物属性计算 ====================
|
||||
|
||||
/**
|
||||
* 计算怪物属性
|
||||
* @param {Object} baseMonster - 基础怪物配置
|
||||
* @param {Number} level - 怪物等级
|
||||
* @param {Number} difficulty - 难度系数 (0.8 - 1.5)
|
||||
* @returns {Object} 计算后的怪物属性
|
||||
*/
|
||||
export function calculateMonsterStats(baseMonster, level = 1, difficulty = 1.0) {
|
||||
const m = GAME_FORMULAS.MONSTER
|
||||
|
||||
// 等级缩放公式:基础值 * (1 + 增长率)^(等级-1)
|
||||
const levelBonus = Math.pow(m.HP_SCALING, level - 1)
|
||||
const attackBonus = Math.pow(m.ATTACK_SCALING, level - 1)
|
||||
const defenseBonus = Math.pow(m.DEFENSE_SCALING, level - 1)
|
||||
const expBonus = Math.pow(m.EXP_SCALING, level - 1)
|
||||
|
||||
return {
|
||||
...baseMonster,
|
||||
level,
|
||||
// HP = 基础HP * 等级倍率 * 难度系数
|
||||
hp: Math.floor(baseMonster.hp * levelBonus * difficulty),
|
||||
maxHp: Math.floor(baseMonster.hp * levelBonus * difficulty),
|
||||
// 攻击 = 基础攻击 * 等级倍率 * 难度系数
|
||||
attack: Math.floor(baseMonster.attack * attackBonus * difficulty),
|
||||
// 防御 = 基础防御 * 等级倍率 * 难度系数
|
||||
defense: Math.floor(baseMonster.defense * defenseBonus * difficulty),
|
||||
// 经验奖励 = 基础经验 * 等级倍率
|
||||
expReward: Math.floor(baseMonster.expReward * expBonus),
|
||||
// 暴击率随等级略微提升
|
||||
critRate: Math.min(30, (baseMonster.critRate || 0) + level * 0.5),
|
||||
// 速度随等级略微提升
|
||||
speed: baseMonster.speed + level * 0.5
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算怪物等级范围
|
||||
* @param {Number} baseLevel - 基础等级
|
||||
* @returns {Object} { min, max }
|
||||
*/
|
||||
export function getMonsterLevelRange(baseLevel) {
|
||||
const v = GAME_FORMULAS.MONSTER.LEVEL_VARANCE
|
||||
const variance = Math.max(1, Math.floor(baseLevel * v))
|
||||
return {
|
||||
min: Math.max(1, baseLevel - variance),
|
||||
max: baseLevel + variance
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 经验计算 ====================
|
||||
|
||||
/**
|
||||
* 计算升级所需经验
|
||||
* 与 levelingSystem.js 中的公式保持一致
|
||||
* @param {Number} currentLevel - 当前等级
|
||||
* @returns {Number} 所需经验
|
||||
*/
|
||||
export function getExpForLevel(currentLevel) {
|
||||
const f = GAME_FORMULAS
|
||||
if (currentLevel <= 1) return 0
|
||||
// 混合曲线公式: base * (1.15 ^ (level - 2)) * (level - 1) * 0.8
|
||||
// 与 levelingSystem.js 的 HYBRID 曲线保持一致
|
||||
return Math.floor(f.EXP_BASE * Math.pow(f.EXP_GROWTH, currentLevel - 2) * (currentLevel - 1) * 0.8)
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算战斗经验
|
||||
* @param {Number} monsterLevel - 怪物等级
|
||||
* @param {Number} playerLevel - 玩家等级
|
||||
* @param {Number} baseExp - 基础经验
|
||||
* @returns {Number} 实际获得经验
|
||||
*/
|
||||
export function calculateCombatExp(monsterLevel, playerLevel, baseExp) {
|
||||
// 等级差惩罚
|
||||
const levelDiff = monsterLevel - playerLevel
|
||||
|
||||
let multiplier = 1.0
|
||||
|
||||
if (levelDiff > 5) {
|
||||
// 怪物高5级以上,额外奖励
|
||||
multiplier = 1 + (levelDiff - 5) * 0.1
|
||||
} else if (levelDiff < -5) {
|
||||
// 怪物低5级以上,大幅衰减
|
||||
multiplier = Math.max(0.1, 0.5 + (levelDiff + 5) * 0.1)
|
||||
} else if (levelDiff < 0) {
|
||||
// 怪物等级略低,小幅衰减
|
||||
multiplier = 1 + levelDiff * 0.05
|
||||
}
|
||||
|
||||
return Math.max(1, Math.floor(baseExp * multiplier))
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算技能经验
|
||||
* @param {Number} skillLevel - 技能当前等级
|
||||
* @param {Number} actionExp - 动作基础经验
|
||||
* @returns {Number} 实际获得经验
|
||||
*/
|
||||
export function calculateSkillExp(skillLevel, actionExp) {
|
||||
// 等级越高,获得经验越难
|
||||
const decay = Math.pow(0.95, skillLevel - 1)
|
||||
return Math.max(1, Math.floor(actionExp * decay))
|
||||
}
|
||||
|
||||
// ==================== 伤害计算 ====================
|
||||
|
||||
/**
|
||||
* 计算普通伤害
|
||||
* @param {Number} attack - 攻击力
|
||||
* @param {Number} defense - 防御力
|
||||
* @param {Number} level - 等级加成
|
||||
* @returns {Number} 伤害值
|
||||
*/
|
||||
export function calculateDamage(attack, defense, level = 1) {
|
||||
// 基础伤害 = 攻击力 - 防御力 * 0.5
|
||||
// 最小伤害为攻击力的20%
|
||||
const baseDamage = attack - defense * 0.5
|
||||
const minDamage = attack * 0.2
|
||||
|
||||
// 加入等级加成
|
||||
const levelBonus = 1 + level * 0.02
|
||||
|
||||
return Math.max(minDamage, baseDamage) * levelBonus
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算暴击伤害
|
||||
* @param {Number} baseDamage - 基础伤害
|
||||
* @param {Number} critMultiplier - 暴击倍率
|
||||
* @returns {Number} 暴击伤害
|
||||
*/
|
||||
export function calculateCritDamage(baseDamage, critMultiplier = 1.5) {
|
||||
return Math.floor(baseDamage * critMultiplier)
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算是否暴击
|
||||
* @param {Number} critRate - 暴击率 (0-100)
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function rollCrit(critRate) {
|
||||
return Math.random() * 100 < critRate
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算是否命中
|
||||
* @param {Number} hitRate - 命中率 (0-100)
|
||||
* @param {Number} dodgeRate - 闪避率 (0-100)
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function rollHit(hitRate = 90, dodgeRate = 0) {
|
||||
const actualHitRate = Math.max(5, Math.min(95, hitRate - dodgeRate))
|
||||
return Math.random() * 100 < actualHitRate
|
||||
}
|
||||
|
||||
// ==================== 价值计算 ====================
|
||||
|
||||
/**
|
||||
* 计算物品出售价格
|
||||
* @param {Number} baseValue - 基础价值
|
||||
* @param {Number} quality - 品质
|
||||
* @param {Number} affixCount - 词缀数量
|
||||
* @returns {Number} 出售价格
|
||||
*/
|
||||
export function calculateSellPrice(baseValue, quality = 100, affixCount = 0) {
|
||||
const qualityMultiplier = 1 + (quality - 100) * 0.005
|
||||
const affixMultiplier = 1 + affixCount * 0.15
|
||||
return Math.floor(baseValue * qualityMultiplier * affixMultiplier)
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算物品购买价格
|
||||
* @param {Number} sellPrice - 出售价格
|
||||
* @param {Number} merchantRate - 商人倍率 (通常 2.0 - 3.0)
|
||||
* @returns {Number} 购买价格
|
||||
*/
|
||||
export function calculateBuyPrice(sellPrice, merchantRate = 2.0) {
|
||||
return Math.floor(sellPrice * merchantRate)
|
||||
}
|
||||
@@ -494,6 +494,71 @@ export const ITEM_CONFIG = {
|
||||
description: '一本神圣的书籍,可以用来祈祷。',
|
||||
stackable: false,
|
||||
effect: { sanity: 10 }
|
||||
},
|
||||
|
||||
// ===== 义体(仅Boss掉落,无品质) =====
|
||||
steel_arm_prosthetic: {
|
||||
id: 'steel_arm_prosthetic',
|
||||
name: '合金臂义体',
|
||||
type: 'prosthetic',
|
||||
subtype: 'arm',
|
||||
icon: '🦾',
|
||||
baseValue: 2000,
|
||||
quality: 150, // 固定品质
|
||||
fixedQuality: true, // 标记为固定品质
|
||||
stats: { strength: 8, attack: 10 },
|
||||
skill: 'steel_arm_slash', // 提供的技能
|
||||
skillUnlocked: true,
|
||||
description: '用合金制成的义体手臂,大幅增强力量。可使用【合金斩击】技能。',
|
||||
bossOnly: true // 仅Boss掉落
|
||||
},
|
||||
|
||||
optical_eye_prosthetic: {
|
||||
id: 'optical_eye_prosthetic',
|
||||
name: '光学义眼',
|
||||
type: 'prosthetic',
|
||||
subtype: 'head',
|
||||
icon: '👁️',
|
||||
baseValue: 1800,
|
||||
quality: 140,
|
||||
fixedQuality: true,
|
||||
stats: { dexterity: 8, intuition: 5 },
|
||||
skill: 'target_lock', // 提供的技能
|
||||
skillUnlocked: true,
|
||||
description: '植入式义眼,提高命中和暴击。可使用【目标锁定】技能。',
|
||||
bossOnly: true
|
||||
},
|
||||
|
||||
spinal_boost_prosthetic: {
|
||||
id: 'spinal_boost_prosthetic',
|
||||
name: '脊柱加速器',
|
||||
type: 'prosthetic',
|
||||
subtype: 'spine',
|
||||
icon: '🦴',
|
||||
baseValue: 2500,
|
||||
quality: 160,
|
||||
fixedQuality: true,
|
||||
stats: { agility: 10, speed: 15 },
|
||||
skill: 'overdrive', // 提供的技能
|
||||
skillUnlocked: true,
|
||||
description: '植入脊柱的加速装置,极大提升速度。可使用【过载】技能。',
|
||||
bossOnly: true
|
||||
},
|
||||
|
||||
dermal_armor_prosthetic: {
|
||||
id: 'dermal_armor_prosthetic',
|
||||
name: '真皮装甲',
|
||||
type: 'prosthetic',
|
||||
subtype: 'body',
|
||||
icon: '🦾',
|
||||
baseValue: 2200,
|
||||
quality: 155,
|
||||
fixedQuality: true,
|
||||
stats: { defense: 15, vitality: 8 },
|
||||
skill: 'iron_skin', // 提供的技能
|
||||
skillUnlocked: true,
|
||||
description: '植入皮下的装甲层,提供强大防御。可使用【钢铁皮肤】技能。',
|
||||
bossOnly: true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,6 +571,7 @@ export const ITEM_CATEGORIES = {
|
||||
armor: { id: 'armor', name: '防具', icon: '🛡️' },
|
||||
shield: { id: 'shield', name: '盾牌', icon: '🛡️' },
|
||||
accessory: { id: 'accessory', name: '饰品', icon: '💍' },
|
||||
prosthetic: { id: 'prosthetic', name: '义体', icon: '🦾' },
|
||||
consumable: { id: 'consumable', name: '消耗品', icon: '🧪' },
|
||||
book: { id: 'book', name: '书籍', icon: '📖' },
|
||||
material: { id: 'material', name: '素材', icon: '📦' },
|
||||
|
||||
@@ -40,5 +40,53 @@ export const NPC_CONFIG = {
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
ripper_doc: {
|
||||
id: 'ripper_doc',
|
||||
name: '义体医生',
|
||||
location: 'blackmarket',
|
||||
icon: '👨⚕️',
|
||||
dialogue: {
|
||||
first: {
|
||||
text: '嗯...你是新面孔。我看你的身体还很"原始",需要做点升级吗?',
|
||||
choices: [
|
||||
{ text: '什么是义体?', next: 'explain_prosthetic' },
|
||||
{ text: '我想安装义体', next: 'install_prosthetic' },
|
||||
{ text: '我想卸下义体', next: 'remove_prosthetic' },
|
||||
{ text: '离开', next: null }
|
||||
]
|
||||
},
|
||||
explain_prosthetic: {
|
||||
text: '义体是机械植入物,可以大幅增强你的能力。它们通常只有从强大的敌人身上才能获得。装备义体后,你还能获得特殊的攻击技能。',
|
||||
choices: [
|
||||
{ text: '我想安装义体', next: 'install_prosthetic' },
|
||||
{ text: '离开', next: null }
|
||||
]
|
||||
},
|
||||
install_prosthetic: {
|
||||
text: '让我看看...你有以下义体可以安装:\n{prosthetic_list}\n\n选择一件装备吧。',
|
||||
choices: [
|
||||
{ text: '{refresh}', next: 'install_prosthetic', action: 'refresh_list' },
|
||||
{ text: '返回', next: 'first' }
|
||||
],
|
||||
dynamicChoices: 'prosthetic_inventory'
|
||||
},
|
||||
remove_prosthetic: {
|
||||
text: '卸下义体是个精细的手术...你确定吗?当前装备的义体:\n{equipped_prosthetic}',
|
||||
choices: [
|
||||
{ text: '确定卸下', next: null, action: 'remove_prosthetic' },
|
||||
{ text: '返回', next: 'first' }
|
||||
]
|
||||
}
|
||||
},
|
||||
services: {
|
||||
install_prosthetic: {
|
||||
cost: 500 // 安装费用
|
||||
},
|
||||
remove_prosthetic: {
|
||||
cost: 200 // 卸下费用
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,5 +111,111 @@ export const SKILL_CONFIG = {
|
||||
15: { desc: '所有制药成功率+20%', effect: { herbingSuccessRate: 20 } }
|
||||
},
|
||||
unlockCondition: null
|
||||
},
|
||||
|
||||
// ===== 义体相关技能 =====
|
||||
prosthetic_adaptation: {
|
||||
id: 'prosthetic_adaptation',
|
||||
name: '义体适应性',
|
||||
type: 'passive',
|
||||
category: 'prosthetic',
|
||||
icon: '🦾',
|
||||
maxLevel: 20,
|
||||
expPerLevel: (level) => level * 50,
|
||||
parentSkill: null,
|
||||
milestones: {
|
||||
1: { desc: '解锁义体装备功能', effect: {} },
|
||||
3: { desc: '义体技能伤害+10%', effect: { prostheticSkillDamage: 10 } },
|
||||
5: { desc: '义体耐力消耗-20%', effect: { prostheticStaminaCost: -0.2 } },
|
||||
10: { desc: '义体技能伤害+25%', effect: { prostheticSkillDamage: 25 } },
|
||||
15: { desc: '义体冷却时间-30%', effect: { prostheticCooldown: -0.3 } },
|
||||
20: { desc: '义体所有效果+50%', effect: { prostheticAllEffect: 50 } }
|
||||
},
|
||||
unlockCondition: {
|
||||
type: 'item',
|
||||
item: 'any_prosthetic'
|
||||
},
|
||||
desc: '使用义体时提升,增强义体效果'
|
||||
},
|
||||
|
||||
// ===== 义体攻击技能 =====
|
||||
steel_arm_slash: {
|
||||
id: 'steel_arm_slash',
|
||||
name: '合金斩击',
|
||||
type: 'combat',
|
||||
category: 'prosthetic_skill',
|
||||
icon: '⚔️',
|
||||
maxLevel: 1, // 义体技能不可升级
|
||||
expPerLevel: () => 0,
|
||||
parentSkill: null,
|
||||
milestones: {},
|
||||
unlockCondition: {
|
||||
type: 'equipment',
|
||||
item: 'steel_arm_prosthetic'
|
||||
},
|
||||
desc: '合金臂义体专属技能。造成200%攻击力的伤害。',
|
||||
staminaCost: 15,
|
||||
cooldown: 0,
|
||||
damageMultiplier: 2.0
|
||||
},
|
||||
|
||||
target_lock: {
|
||||
id: 'target_lock',
|
||||
name: '目标锁定',
|
||||
type: 'combat',
|
||||
category: 'prosthetic_skill',
|
||||
icon: '🎯',
|
||||
maxLevel: 1,
|
||||
expPerLevel: () => 0,
|
||||
parentSkill: null,
|
||||
milestones: {},
|
||||
unlockCondition: {
|
||||
type: 'equipment',
|
||||
item: 'optical_eye_prosthetic'
|
||||
},
|
||||
desc: '光学义眼专属技能。下一次攻击必定暴击。',
|
||||
staminaCost: 8,
|
||||
cooldown: 3,
|
||||
buff: 'guaranteedCrit'
|
||||
},
|
||||
|
||||
overdrive: {
|
||||
id: 'overdrive',
|
||||
name: '过载',
|
||||
type: 'combat',
|
||||
category: 'prosthetic_skill',
|
||||
icon: '⚡',
|
||||
maxLevel: 1,
|
||||
expPerLevel: () => 0,
|
||||
parentSkill: null,
|
||||
milestones: {},
|
||||
unlockCondition: {
|
||||
type: 'equipment',
|
||||
item: 'spinal_boost_prosthetic'
|
||||
},
|
||||
desc: '脊柱加速器专属技能。3秒内攻击速度+100%。',
|
||||
staminaCost: 20,
|
||||
cooldown: 5,
|
||||
buff: 'attackSpeedBoost'
|
||||
},
|
||||
|
||||
iron_skin: {
|
||||
id: 'iron_skin',
|
||||
name: '钢铁皮肤',
|
||||
type: 'combat',
|
||||
category: 'prosthetic_skill',
|
||||
icon: '🛡️',
|
||||
maxLevel: 1,
|
||||
expPerLevel: () => 0,
|
||||
parentSkill: null,
|
||||
milestones: {},
|
||||
unlockCondition: {
|
||||
type: 'equipment',
|
||||
item: 'dermal_armor_prosthetic'
|
||||
},
|
||||
desc: '真皮装甲专属技能。3秒内防御力+50%。',
|
||||
staminaCost: 15,
|
||||
cooldown: 4,
|
||||
buff: 'defenseBoost'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
# 游戏数值模型文档
|
||||
|
||||
本文档详细描述了游戏中所有数值计算的核心公式和设计理念。
|
||||
|
||||
## 目录
|
||||
|
||||
1. [设计原则](#设计原则)
|
||||
2. [角色属性系统](#角色属性系统)
|
||||
3. [装备属性系统](#装备属性系统)
|
||||
4. [词缀系统](#词缀系统)
|
||||
5. [怪物属性系统](#怪物属性系统)
|
||||
6. [经验与升级系统](#经验与升级系统)
|
||||
7. [战斗伤害计算](#战斗伤害计算)
|
||||
8. [经济系统](#经济系统)
|
||||
|
||||
---
|
||||
|
||||
## 设计原则
|
||||
|
||||
### 1. 线性与指数平衡
|
||||
|
||||
- **低等级(1-20)**:使用线性增长,确保新手体验平滑
|
||||
- **中等级(21-50)**:引入指数增长,增加挑战
|
||||
- **高等级(51+)**:指数加速,突出后期成就
|
||||
|
||||
### 2. 边际收益递减
|
||||
|
||||
- 属性越高,继续提升的成本越大
|
||||
- 防止某一项属性无限堆叠
|
||||
|
||||
### 3. 有意义的多样性
|
||||
|
||||
- 不同属性有不同用途,避免单一最优解
|
||||
- 词缀系统提供随机性和惊喜
|
||||
|
||||
---
|
||||
|
||||
## 角色属性系统
|
||||
|
||||
### 基础属性
|
||||
|
||||
| 属性 | 符号 | 默认值 | 说明 |
|
||||
|------|------|--------|------|
|
||||
| 力量 | STR | 10 | 影响攻击力 |
|
||||
| 敏捷 | AGI | 8 | 影响闪避、防御 |
|
||||
| 灵巧 | DEX | 8 | 影响暴击 |
|
||||
| 智力 | INT | 10 | 影响品质、魔法 |
|
||||
| 体质 | VIT | 10 | 影响生命、回复 |
|
||||
|
||||
### 派生属性计算
|
||||
|
||||
```javascript
|
||||
// 基础生命值
|
||||
HP = 100 + VIT × 10 + Level × 5
|
||||
|
||||
// 基础耐力
|
||||
Stamina = 80 + VIT × 5 + Level × 3
|
||||
|
||||
// 基础精神
|
||||
Sanity = 100 + INT × 3
|
||||
|
||||
// 基础攻击力
|
||||
Attack = STR × 1.0 + Level × 2
|
||||
|
||||
// 基础防御力
|
||||
Defense = AGI × 0.3 + VIT × 0.2 + Level
|
||||
|
||||
// 基础暴击率 (%)
|
||||
CritRate = 5 + DEX × 0.3
|
||||
|
||||
// 基础闪避率 (%)
|
||||
DodgeRate = AGI × 0.5
|
||||
```
|
||||
|
||||
### 属性效果示例
|
||||
|
||||
| 属性值 | 效果 |
|
||||
|--------|------|
|
||||
| STR 10 → 20 | 攻击力 +10 |
|
||||
| AGI 10 → 20 | 闪避 +5%,防御 +3 |
|
||||
| DEX 10 → 20 | 暴击 +3% |
|
||||
| VIT 10 → 20 | HP +100,回复 +0.5/秒 |
|
||||
| INT 10 → 20 | 装备品质期望 +5 |
|
||||
|
||||
---
|
||||
|
||||
## 装备属性系统
|
||||
|
||||
### 装备品质
|
||||
|
||||
品质范围:0-250,影响装备属性的百分比加成。
|
||||
|
||||
| 品质范围 | 名称 | 倍率 | 颜色 |
|
||||
|----------|------|------|------|
|
||||
| 0-49 | 垃圾 | 0.5x | 灰色 |
|
||||
| 50-89 | 普通 | 1.0x | 白色 |
|
||||
| 90-129 | 优秀 | 1.2x | 绿色 |
|
||||
| 130-159 | 稀有 | 1.5x | 蓝色 |
|
||||
| 160-199 | 史诗 | 2.0x | 紫色 |
|
||||
| 200-250 | 传说 | 3.0x | 橙色 |
|
||||
|
||||
### 装备最终属性计算
|
||||
|
||||
```javascript
|
||||
// 品质倍率
|
||||
QualityMultiplier = 1 + (Quality - 100) × 0.01
|
||||
|
||||
// 等级倍率(每级 +2%)
|
||||
LevelMultiplier = 1 + (ItemLevel - 1) × 0.02
|
||||
|
||||
// 综合倍率
|
||||
TotalMultiplier = QualityMultiplier × LevelMultiplier
|
||||
|
||||
// 最终伤害
|
||||
FinalDamage = BaseDamage × TotalMultiplier
|
||||
|
||||
// 最终防御
|
||||
FinalDefense = BaseDefense × TotalMultiplier
|
||||
```
|
||||
|
||||
### 装备品质示例
|
||||
|
||||
以攻击力20的基础武器为例:
|
||||
|
||||
| 品质 | 等级 | 最终攻击力 |
|
||||
|------|------|------------|
|
||||
| 100 (普通) | 1 | 20 |
|
||||
| 150 (优秀) | 1 | 30 |
|
||||
| 200 (史诗) | 1 | 40 |
|
||||
| 100 (普通) | 10 | 24 |
|
||||
| 150 (优秀) | 10 | 36 |
|
||||
| 200 (史诗) | 10 | 48 |
|
||||
|
||||
---
|
||||
|
||||
## 词缀系统
|
||||
|
||||
### 词缀稀有度
|
||||
|
||||
每件装备最多3个词缀,词缀数量和稀有度受品质影响。
|
||||
|
||||
| 品质范围 | 最大词缀数 | 词缀稀有度倾向 |
|
||||
|----------|------------|----------------|
|
||||
| 0-89 | 0 | 无 |
|
||||
| 90-129 | 1 | 普通60%,稀有30% |
|
||||
| 130-159 | 2 | 稀有为主 |
|
||||
| 160-199 | 3 | 史诗为主 |
|
||||
| 200-250 | 3 | 传说9% |
|
||||
|
||||
### 词缀属性
|
||||
|
||||
词缀属性随物品等级缩放:
|
||||
```
|
||||
词缀最终值 = 词缀基础值 × (1 + (物品等级 - 1) × 0.1)
|
||||
```
|
||||
|
||||
### 武器词缀示例
|
||||
|
||||
| 名称 | 类型 | 基础值 | 稀有度 |
|
||||
|------|------|--------|--------|
|
||||
| 锋利 | 攻击+5% | 5 | 普通 |
|
||||
| 残暴 | 攻击+12% | 12 | 稀有 |
|
||||
| 弑神 | 攻击+25% | 25 | 传说 |
|
||||
| 锐利 | 暴击+3% | 3 | 普通 |
|
||||
| 致命 | 暴击+8% | 8 | 稀有 |
|
||||
| 烈焰 | 火伤+10 | 10 | 史诗 |
|
||||
|
||||
### 防具词缀示例
|
||||
|
||||
| 名称 | 类型 | 基础值 | 稀有度 |
|
||||
|------|------|--------|--------|
|
||||
| 坚固 | 防御+5% | 5 | 普通 |
|
||||
| 强化 | 防御+12% | 12 | 稀有 |
|
||||
| 铁壁 | 防御+25% | 25 | 史诗 |
|
||||
| 灵活 | 闪避+3% | 3 | 普通 |
|
||||
| 耐久 | 耐力+15 | 15 | 稀有 |
|
||||
| 不朽 | 生命+100 | 100 | 传说 |
|
||||
|
||||
---
|
||||
|
||||
## 怪物属性系统
|
||||
|
||||
### 怪物等级缩放
|
||||
|
||||
```javascript
|
||||
// 生命值缩放(每级 +12%)
|
||||
MonsterHP = BaseHP × 1.12^(Level - 1)
|
||||
|
||||
// 攻击力缩放(每级 +8%)
|
||||
MonsterAttack = BaseAttack × 1.08^(Level - 1)
|
||||
|
||||
// 防御力缩放(每级 +6%)
|
||||
MonsterDefense = BaseDefense × 1.06^(Level - 1)
|
||||
|
||||
// 经验奖励缩放(每级 +10%)
|
||||
MonsterEXP = BaseEXP × 1.10^(Level - 1)
|
||||
```
|
||||
|
||||
### 怪物等级范围
|
||||
|
||||
怪物实际等级在基础等级 ±20% 范围内浮动:
|
||||
```javascript
|
||||
LevelVariance = BaseLevel × 0.2
|
||||
MinLevel = Max(1, BaseLevel - LevelVariance)
|
||||
MaxLevel = BaseLevel + LevelVariance
|
||||
```
|
||||
|
||||
### 难度系数
|
||||
|
||||
```javascript
|
||||
// 基础难度
|
||||
Difficulty = 1.0
|
||||
|
||||
// 精英怪
|
||||
Elite: Difficulty = 1.5
|
||||
|
||||
// Boss
|
||||
Boss: Difficulty = 2.0
|
||||
|
||||
// 弱小怪
|
||||
Weak: Difficulty = 0.7
|
||||
```
|
||||
|
||||
### 怪物属性示例
|
||||
|
||||
以基础攻击10的怪物为例:
|
||||
|
||||
| 等级 | HP | 攻击 | 防御 | 经验 |
|
||||
|------|-----|------|------|------|
|
||||
| 1 | 100 | 10 | 5 | 20 |
|
||||
| 5 | 157 | 14 | 7 | 29 |
|
||||
| 10 | 278 | 20 | 10 | 47 |
|
||||
| 20 | 872 | 43 | 17 | 122 |
|
||||
| 50 | 18403 | 184 | 74 | 5851 |
|
||||
|
||||
---
|
||||
|
||||
## 经验与升级系统
|
||||
|
||||
### 角色升级经验
|
||||
|
||||
```javascript
|
||||
// 所需经验 = 基础值 × 增长系数^(等级-1)
|
||||
ExpNeeded = 100 × 1.15^(Level - 1)
|
||||
```
|
||||
|
||||
| 等级 | 所需经验 | 累计经验 |
|
||||
|------|----------|----------|
|
||||
| 1 | 100 | 0 |
|
||||
| 5 | 174 | 674 |
|
||||
| 10 | 352 | 2261 |
|
||||
| 20 | 1458 | 12674 |
|
||||
| 50 | 84049 | 424058 |
|
||||
|
||||
### 战斗经验计算
|
||||
|
||||
```javascript
|
||||
// 等级差调整
|
||||
LevelDiff = MonsterLevel - PlayerLevel
|
||||
|
||||
if (LevelDiff > 5) {
|
||||
// 怪物高5级以上,额外奖励
|
||||
ExpMultiplier = 1 + (LevelDiff - 5) × 0.1
|
||||
} else if (LevelDiff < -5) {
|
||||
// 怪物低5级以上,大幅衰减
|
||||
ExpMultiplier = Max(0.1, 0.5 + (LevelDiff + 5) × 0.1)
|
||||
} else {
|
||||
// 等级相近,正常或小幅衰减
|
||||
ExpMultiplier = 1 + LevelDiff × 0.05
|
||||
}
|
||||
|
||||
// 实际经验
|
||||
ActualExp = BaseExp × ExpMultiplier
|
||||
```
|
||||
|
||||
### 经验衰减表
|
||||
|
||||
| 玩家等级 vs 怪物等级 | 经验倍率 |
|
||||
|---------------------|----------|
|
||||
| +5级或更高 | 100%+ |
|
||||
| 相同等级 | 100% |
|
||||
| -3级 | 85% |
|
||||
| -5级 | 50% |
|
||||
| -10级 | 10% |
|
||||
|
||||
### 技能经验
|
||||
|
||||
```javascript
|
||||
// 技能经验衰减(等级越高越难升级)
|
||||
Decay = 0.95^(SkillLevel - 1)
|
||||
ActualExp = ActionExp × Decay
|
||||
```
|
||||
|
||||
| 技能等级 | 经验衰减 | 获得100经验实际得到 |
|
||||
|----------|----------|-------------------|
|
||||
| 1 | 100% | 100 |
|
||||
| 5 | 81% | 81 |
|
||||
| 10 | 63% | 63 |
|
||||
| 20 | 36% | 36 |
|
||||
|
||||
---
|
||||
|
||||
## 战斗伤害计算
|
||||
|
||||
### 普通伤害
|
||||
|
||||
```javascript
|
||||
// 基础伤害
|
||||
BaseDamage = Attack - Defense × 0.5
|
||||
|
||||
// 最小伤害保证(攻击力的20%)
|
||||
MinDamage = Attack × 0.2
|
||||
|
||||
// 实际伤害
|
||||
ActualDamage = Max(MinDamage, BaseDamage)
|
||||
```
|
||||
|
||||
### 暴击系统
|
||||
|
||||
```javascript
|
||||
// 暴击判定
|
||||
IsCrit = Random(0, 100) < CritRate
|
||||
|
||||
// 暴击伤害
|
||||
if (IsCrit) {
|
||||
CritDamage = BaseDamage × 1.5 // 基础暴击倍率
|
||||
// 可通过装备/技能提升
|
||||
}
|
||||
```
|
||||
|
||||
### 命中系统
|
||||
|
||||
```javascript
|
||||
// 实际命中率
|
||||
ActualHitRate = Clamp(5, 95, HitRate - DodgeRate)
|
||||
|
||||
// 命中判定
|
||||
IsHit = Random(0, 100) < ActualHitRate
|
||||
```
|
||||
|
||||
### 伤害示例
|
||||
|
||||
| 攻击 | 防御 | 基础伤害 | 最小伤害 | 实际伤害 |
|
||||
|------|------|----------|----------|----------|
|
||||
| 20 | 5 | 17.5 | 4 | 17-18 |
|
||||
| 50 | 10 | 45 | 10 | 45 |
|
||||
| 50 | 30 | 35 | 10 | 35 |
|
||||
| 100 | 50 | 75 | 20 | 75 |
|
||||
| 30 | 40 | 10 | 6 | 10 |
|
||||
|
||||
---
|
||||
|
||||
## 经济系统
|
||||
|
||||
### 物品价值
|
||||
|
||||
```javascript
|
||||
// 出售价格
|
||||
SellPrice = BaseValue × QualityMultiplier × (1 + AffixCount × 0.15)
|
||||
|
||||
// 购买价格(商人倍率)
|
||||
BuyPrice = SellPrice × MerchantRate
|
||||
|
||||
// 商人收购价
|
||||
BuybackPrice = SellPrice × 0.3
|
||||
```
|
||||
|
||||
### 商人类型
|
||||
|
||||
| 商人 | 出售倍率 | 收购倍率 |
|
||||
|------|----------|----------|
|
||||
| 普通商人 | 200% | 30% |
|
||||
| 黑市商人 | 250% | 50% |
|
||||
| 特殊商人 | 150% | 40% |
|
||||
|
||||
### 价值示例
|
||||
|
||||
以基础价值100的物品为例:
|
||||
|
||||
| 品质 | 词缀 | 出售价 | 购买价(普通) | 购买价(黑市) |
|
||||
|------|------|--------|-------------|-------------|
|
||||
| 100 | 0 | 100 | 200 | 250 |
|
||||
| 150 | 1 | 145 | 290 | 362 |
|
||||
| 200 | 2 | 250 | 500 | 625 |
|
||||
| 200 | 3 | 287 | 574 | 717 |
|
||||
|
||||
---
|
||||
|
||||
## 平衡性检查
|
||||
|
||||
### 攻击期望
|
||||
|
||||
玩家攻击期望 = 基础攻击 × (1 + 暴击率 × 暴击倍率)
|
||||
|
||||
例如:攻击100,暴击率20%,暴击倍率1.5
|
||||
```
|
||||
期望伤害 = 100 × (1 + 0.2 × 0.5) = 100 × 1.1 = 110
|
||||
```
|
||||
|
||||
### 生存期望
|
||||
|
||||
玩家有效生命 = HP × (1 + 闪避率 / (1 - 闪避率))
|
||||
|
||||
例如:HP 1000,闪避30%
|
||||
```
|
||||
有效生命 = 1000 × (1 + 0.3 / 0.7) = 1000 × 1.43 = 1430
|
||||
```
|
||||
|
||||
### DPT(每回合伤害)
|
||||
|
||||
```javascript
|
||||
PlayerDPT = PlayerAttack × PlayerHitRate
|
||||
MonsterDPT = MonsterAttack × (1 - PlayerDodgeRate)
|
||||
|
||||
// 生存回合
|
||||
SurvivalTurns = PlayerHP / MonsterDPT
|
||||
|
||||
// 击杀回合
|
||||
KillTurns = MonsterHP / PlayerDPT
|
||||
|
||||
// 战斗评价
|
||||
if (KillTurns < SurvivalTurns) {
|
||||
// 玩家优势
|
||||
} else {
|
||||
// 怪物优势
|
||||
}
|
||||
```
|
||||
+76
-1
@@ -28,6 +28,8 @@ export const useGameStore = defineStore('game', () => {
|
||||
const inCombat = ref(false)
|
||||
const combatState = ref(null)
|
||||
const autoCombat = ref(false) // 自动战斗模式
|
||||
const isSearching = ref(false) // 正在寻找敌人中(自动战斗间隔期间)
|
||||
const preferredStance = ref('balance') // 记住玩家偏好的战斗姿态
|
||||
|
||||
// 活动任务
|
||||
const activeTasks = ref([])
|
||||
@@ -44,6 +46,16 @@ export const useGameStore = defineStore('game', () => {
|
||||
// 当前事件
|
||||
const currentEvent = ref(null)
|
||||
|
||||
// 成就系统
|
||||
const achievements = ref({})
|
||||
const achievementProgress = ref({
|
||||
totalKills: 0,
|
||||
bossKills: 0,
|
||||
prostheticEquipped: 0,
|
||||
visitedLocations: new Set(),
|
||||
totalEarned: 0
|
||||
})
|
||||
|
||||
// 添加日志
|
||||
function addLog(message, type = 'info') {
|
||||
const time = `${String(gameTime.value.hour).padStart(2, '0')}:${String(gameTime.value.minute).padStart(2, '0')}`
|
||||
@@ -59,6 +71,54 @@ export const useGameStore = defineStore('game', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 检查成就
|
||||
function checkAchievements(triggerType, data = {}) {
|
||||
const { ACHIEVEMENT_CONFIG } = require('@/config/achievements.js')
|
||||
let newAchievements = []
|
||||
|
||||
for (const [id, achievement] of Object.entries(ACHIEVEMENT_CONFIG)) {
|
||||
// 已完成的跳过
|
||||
if (achievements.value[id]) continue
|
||||
|
||||
let unlocked = false
|
||||
|
||||
switch (achievement.condition.type) {
|
||||
case 'kill':
|
||||
unlocked = achievementProgress.value.totalKills >= achievement.condition.count
|
||||
break
|
||||
case 'boss_kill':
|
||||
unlocked = achievementProgress.value.bossKills >= achievement.condition.count
|
||||
break
|
||||
case 'equip_prosthetic':
|
||||
unlocked = data.prostheticCount >= achievement.condition.count
|
||||
break
|
||||
case 'skill_level':
|
||||
unlocked = data.maxSkillLevel >= achievement.condition.level
|
||||
break
|
||||
case 'visit_locations':
|
||||
unlocked = achievementProgress.value.visitedLocations.size >= achievement.condition.count
|
||||
break
|
||||
case 'total_earned':
|
||||
unlocked = achievementProgress.value.totalEarned >= achievement.condition.amount
|
||||
break
|
||||
case 'survive_days':
|
||||
unlocked = gameTime.value.day >= achievement.condition.days
|
||||
break
|
||||
}
|
||||
|
||||
if (unlocked) {
|
||||
achievements.value[id] = {
|
||||
unlocked: true,
|
||||
timestamp: Date.now()
|
||||
}
|
||||
newAchievements.push(achievement)
|
||||
addLog(`🏆 解锁成就: ${achievement.icon} ${achievement.name}`, 'reward')
|
||||
}
|
||||
}
|
||||
|
||||
return newAchievements
|
||||
}
|
||||
|
||||
// 重置游戏状态
|
||||
function resetGame() {
|
||||
currentTab.value = 'status'
|
||||
@@ -77,6 +137,8 @@ export const useGameStore = defineStore('game', () => {
|
||||
inCombat.value = false
|
||||
combatState.value = null
|
||||
autoCombat.value = false
|
||||
isSearching.value = false
|
||||
preferredStance.value = 'balance'
|
||||
activeTasks.value = []
|
||||
negativeStatus.value = []
|
||||
marketPrices.value = {
|
||||
@@ -84,6 +146,14 @@ export const useGameStore = defineStore('game', () => {
|
||||
prices: {}
|
||||
}
|
||||
currentEvent.value = null
|
||||
achievements.value = {}
|
||||
achievementProgress.value = {
|
||||
totalKills: 0,
|
||||
bossKills: 0,
|
||||
prostheticEquipped: 0,
|
||||
visitedLocations: new Set(),
|
||||
totalEarned: 0
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -94,11 +164,16 @@ export const useGameStore = defineStore('game', () => {
|
||||
inCombat,
|
||||
combatState,
|
||||
autoCombat,
|
||||
isSearching,
|
||||
preferredStance,
|
||||
activeTasks,
|
||||
negativeStatus,
|
||||
marketPrices,
|
||||
currentEvent,
|
||||
achievements,
|
||||
achievementProgress,
|
||||
addLog,
|
||||
resetGame
|
||||
resetGame,
|
||||
checkAchievements
|
||||
}
|
||||
})
|
||||
|
||||
+21
-4
@@ -5,7 +5,7 @@ export const usePlayerStore = defineStore('player', () => {
|
||||
// 基础属性
|
||||
const baseStats = ref({
|
||||
strength: 10, // 力量
|
||||
agility: 8, // 敏捷
|
||||
agility: 6, // 敏捷(降低以提高被命中率)
|
||||
dexterity: 8, // 灵巧
|
||||
intuition: 10, // 智力
|
||||
vitality: 10 // 体质(影响HP)
|
||||
@@ -36,9 +36,13 @@ export const usePlayerStore = defineStore('player', () => {
|
||||
weapon: null,
|
||||
armor: null,
|
||||
shield: null,
|
||||
accessory: null
|
||||
accessory: null,
|
||||
prosthetic: null // 义体装备位
|
||||
})
|
||||
|
||||
// 义体适应性(使用义体时增加)
|
||||
const prostheticAdaptation = ref(0)
|
||||
|
||||
// 背包
|
||||
const inventory = ref([])
|
||||
|
||||
@@ -53,6 +57,12 @@ export const usePlayerStore = defineStore('player', () => {
|
||||
// 标记
|
||||
const flags = ref({})
|
||||
|
||||
// 击杀统计(用于成就和解锁条件)
|
||||
const killCount = ref({})
|
||||
|
||||
// 访问过的位置
|
||||
const visitedLocations = ref(new Set())
|
||||
|
||||
// 计算属性:总货币
|
||||
const totalCurrency = computed(() => {
|
||||
return {
|
||||
@@ -66,7 +76,7 @@ export const usePlayerStore = defineStore('player', () => {
|
||||
function resetPlayer() {
|
||||
baseStats.value = {
|
||||
strength: 10,
|
||||
agility: 8,
|
||||
agility: 6, // 降低以提高被命中率
|
||||
dexterity: 8,
|
||||
intuition: 10,
|
||||
vitality: 10
|
||||
@@ -89,12 +99,16 @@ export const usePlayerStore = defineStore('player', () => {
|
||||
weapon: null,
|
||||
armor: null,
|
||||
shield: null,
|
||||
accessory: null
|
||||
accessory: null,
|
||||
prosthetic: null
|
||||
}
|
||||
prostheticAdaptation.value = 0
|
||||
inventory.value = []
|
||||
currency.value = { copper: 0 }
|
||||
currentLocation.value = 'camp'
|
||||
flags.value = {}
|
||||
killCount.value = {}
|
||||
visitedLocations.value = new Set()
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -103,11 +117,14 @@ export const usePlayerStore = defineStore('player', () => {
|
||||
level,
|
||||
skills,
|
||||
equipment,
|
||||
prostheticAdaptation,
|
||||
inventory,
|
||||
currency,
|
||||
totalCurrency,
|
||||
currentLocation,
|
||||
flags,
|
||||
killCount,
|
||||
visitedLocations,
|
||||
resetPlayer
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
/**
|
||||
* 数值模型测试
|
||||
* 验证数学模型文档中的各种计算
|
||||
*/
|
||||
|
||||
// 导入公式模块 - 使用require以兼容Jest
|
||||
// 注意:实际使用时需要确保模块路径正确
|
||||
const GAME_CONSTANTS = {
|
||||
QUALITY_LEVELS: {
|
||||
1: { name: '垃圾', color: '#6b7280', range: [0, 49], multiplier: 0.5 },
|
||||
2: { name: '普通', color: '#ffffff', range: [50, 89], multiplier: 1.0 },
|
||||
3: { name: '优秀', color: '#22c55e', range: [90, 129], multiplier: 1.2 },
|
||||
4: { name: '稀有', color: '#3b82f6', range: [130, 159], multiplier: 1.5 },
|
||||
5: { name: '史诗', color: '#a855f7', range: [160, 199], multiplier: 2.0 },
|
||||
6: { name: '传说', color: '#f59e0b', range: [200, 250], multiplier: 3.0 }
|
||||
},
|
||||
QUALITY: {
|
||||
BASE_MULTIPLIER: 0.01
|
||||
},
|
||||
STAT_SCALING: {
|
||||
STRENGTH_TO_ATTACK: 1.0,
|
||||
AGILITY_TO_DODGE: 0.5,
|
||||
DEXTERITY_TO_CRIT: 0.3,
|
||||
VITALITY_TO_HP: 10
|
||||
},
|
||||
MONSTER: {
|
||||
HP_SCALING: 1.12,
|
||||
ATTACK_SCALING: 1.08,
|
||||
DEFENSE_SCALING: 1.06,
|
||||
EXP_SCALING: 1.10
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 核心计算函数 ====================
|
||||
|
||||
function calculateCharacterStats(baseStats, level = 1) {
|
||||
const s = GAME_CONSTANTS.STAT_SCALING
|
||||
|
||||
const baseHP = 100 + (baseStats.vitality || 10) * s.VITALITY_TO_HP + level * 5
|
||||
const baseStamina = 80 + (baseStats.vitality || 10) * 5 + level * 3
|
||||
const baseSanity = 100 + (baseStats.intuition || 10) * 3
|
||||
const baseAttack = (baseStats.strength || 10) * s.STRENGTH_TO_ATTACK + level * 2
|
||||
const baseDefense = (baseStats.agility || 8) * 0.3 + (baseStats.vitality || 10) * 0.2 + level
|
||||
const baseCritRate = 5 + (baseStats.dexterity || 8) * s.DEXTERITY_TO_CRIT
|
||||
const baseDodgeRate = (baseStats.agility || 8) * s.AGILITY_TO_DODGE
|
||||
|
||||
return {
|
||||
hp: Math.floor(baseHP),
|
||||
stamina: Math.floor(baseStamina),
|
||||
sanity: Math.floor(baseSanity),
|
||||
attack: Math.floor(baseAttack),
|
||||
defense: Math.floor(baseDefense),
|
||||
critRate: Math.floor(baseCritRate * 10) / 10,
|
||||
dodgeRate: Math.floor(baseDodgeRate * 10) / 10
|
||||
}
|
||||
}
|
||||
|
||||
function calculateEquipmentStats(baseItem, quality = 100, itemLevel = 1, affixes = []) {
|
||||
const qualityMultiplier = 1 + (quality - 100) * GAME_CONSTANTS.QUALITY.BASE_MULTIPLIER
|
||||
const levelMultiplier = 1 + (itemLevel - 1) * 0.02
|
||||
const totalMultiplier = qualityMultiplier * levelMultiplier
|
||||
|
||||
const stats = { ...baseItem }
|
||||
if (baseItem.baseDamage) {
|
||||
stats.finalDamage = Math.max(1, Math.floor(baseItem.baseDamage * totalMultiplier))
|
||||
}
|
||||
if (baseItem.baseDefense) {
|
||||
stats.finalDefense = Math.max(1, Math.floor(baseItem.baseDefense * totalMultiplier))
|
||||
}
|
||||
if (baseItem.baseValue) {
|
||||
stats.finalValue = Math.floor(baseItem.baseValue * totalMultiplier)
|
||||
}
|
||||
|
||||
const affixStats = calculateAffixStats(affixes, itemLevel)
|
||||
Object.assign(stats, affixStats)
|
||||
|
||||
return stats
|
||||
}
|
||||
|
||||
function calculateAffixStats(affixes, itemLevel = 1) {
|
||||
const stats = {}
|
||||
for (const affix of affixes) {
|
||||
const scale = 1 + (itemLevel - 1) * 0.1
|
||||
switch (affix.type) {
|
||||
case 'attack':
|
||||
stats.attackBonus = (stats.attackBonus || 0) + affix.value * scale
|
||||
break
|
||||
case 'critRate':
|
||||
stats.critRate = (stats.critRate || 0) + affix.value * scale
|
||||
break
|
||||
}
|
||||
}
|
||||
return stats
|
||||
}
|
||||
|
||||
function calculateMonsterStats(baseMonster, level = 1, difficulty = 1.0) {
|
||||
const m = GAME_CONSTANTS.MONSTER
|
||||
const levelBonus = Math.pow(m.HP_SCALING, level - 1)
|
||||
const attackBonus = Math.pow(m.ATTACK_SCALING, level - 1)
|
||||
const defenseBonus = Math.pow(m.DEFENSE_SCALING, level - 1)
|
||||
const expBonus = Math.pow(m.EXP_SCALING, level - 1)
|
||||
|
||||
return {
|
||||
...baseMonster,
|
||||
level,
|
||||
hp: Math.floor(baseMonster.hp * levelBonus * difficulty),
|
||||
maxHp: Math.floor(baseMonster.hp * levelBonus * difficulty),
|
||||
attack: Math.floor(baseMonster.attack * attackBonus * difficulty),
|
||||
defense: Math.floor(baseMonster.defense * defenseBonus * difficulty),
|
||||
expReward: Math.floor(baseMonster.expReward * expBonus)
|
||||
}
|
||||
}
|
||||
|
||||
function getExpForLevel(level) {
|
||||
return Math.floor(100 * Math.pow(1.15, level - 2) * (level - 1) * 0.8)
|
||||
}
|
||||
|
||||
function calculateCombatExp(enemyLevel, playerLevel, baseExp) {
|
||||
const levelDiff = enemyLevel - playerLevel
|
||||
let multiplier = 1.0
|
||||
if (levelDiff > 5) multiplier = 1 + (levelDiff - 5) * 0.1
|
||||
else if (levelDiff < -5) multiplier = Math.max(0.1, 0.5 + (levelDiff + 5) * 0.1)
|
||||
else multiplier = 1 + levelDiff * 0.05
|
||||
return Math.max(1, Math.floor(baseExp * multiplier))
|
||||
}
|
||||
|
||||
function calculateSkillExp(skillLevel, actionExp) {
|
||||
return Math.max(1, Math.floor(actionExp * Math.pow(0.95, skillLevel - 1)))
|
||||
}
|
||||
|
||||
function calculateDamage(attack, defense) {
|
||||
const baseDamage = attack - defense * 0.5
|
||||
const minDamage = attack * 0.2
|
||||
return Math.max(minDamage, baseDamage)
|
||||
}
|
||||
|
||||
function calculateCritDamage(baseDamage, critMultiplier = 1.5) {
|
||||
return Math.floor(baseDamage * critMultiplier)
|
||||
}
|
||||
|
||||
function rollCrit(critRate) {
|
||||
return Math.random() * 100 < critRate
|
||||
}
|
||||
|
||||
function calculateSellPrice(baseValue, quality, affixCount) {
|
||||
const qualityMultiplier = 1 + (quality - 100) * 0.005
|
||||
const affixMultiplier = 1 + affixCount * 0.15
|
||||
return Math.floor(baseValue * qualityMultiplier * affixMultiplier)
|
||||
}
|
||||
|
||||
function calculateBuyPrice(sellPrice, merchantRate = 2.0) {
|
||||
return Math.floor(sellPrice * merchantRate)
|
||||
}
|
||||
|
||||
function getQualityLevel(quality) {
|
||||
if (quality < 50) return { name: '垃圾', color: '#6b7280', multiplier: 0.5 }
|
||||
if (quality < 90) return { name: '普通', color: '#ffffff', multiplier: 1.0 }
|
||||
if (quality < 130) return { name: '优秀', color: '#22c55e', multiplier: 1.2 }
|
||||
if (quality < 160) return { name: '稀有', color: '#3b82f6', multiplier: 1.5 }
|
||||
if (quality < 200) return { name: '史诗', color: '#a855f7', multiplier: 2.0 }
|
||||
return { name: '传说', color: '#f59e0b', multiplier: 3.0 }
|
||||
}
|
||||
|
||||
function generateAffixes(itemType, quality) {
|
||||
// 简化版本用于测试
|
||||
if (quality < 90) return []
|
||||
if (quality < 130) return [{ type: 'attack', value: 5 }]
|
||||
if (quality < 160) return [{ type: 'attack', value: 5 }, { type: 'critRate', value: 3 }]
|
||||
return [{ type: 'attack', value: 5 }, { type: 'critRate', value: 3 }, { type: 'attack', value: 12 }]
|
||||
}
|
||||
|
||||
describe('数学模型验证', () => {
|
||||
describe('角色属性计算', () => {
|
||||
it('应该正确计算基础属性', () => {
|
||||
const baseStats = {
|
||||
strength: 10,
|
||||
agility: 8,
|
||||
dexterity: 8,
|
||||
intuition: 10,
|
||||
vitality: 10
|
||||
}
|
||||
|
||||
const stats = calculateCharacterStats(baseStats, 1)
|
||||
|
||||
// HP = 100 + 10*10 + 1*5 = 205
|
||||
expect(stats.hp).toBe(205)
|
||||
// Attack = 10*1 + 1*2 = 12
|
||||
expect(stats.attack).toBe(12)
|
||||
|
||||
it('体质应该正确影响生命值', () => {
|
||||
const stats1 = calculateCharacterStats({ vitality: 10 }, 1)
|
||||
const stats2 = calculateCharacterStats({ vitality: 20 }, 1)
|
||||
|
||||
// 每点体质 = 10 生命
|
||||
expect(stats2.hp - stats1.hp).toBe(100)
|
||||
})
|
||||
|
||||
it('力量应该正确影响攻击力', () => {
|
||||
const stats1 = calculateCharacterStats({ strength: 10 }, 1)
|
||||
const stats2 = calculateCharacterStats({ strength: 20 }, 1)
|
||||
|
||||
// 每点力量 = 1 攻击力
|
||||
expect(stats2.attack - stats1.attack).toBe(10)
|
||||
})
|
||||
})
|
||||
|
||||
describe('装备品质计算', () => {
|
||||
it('品质100应该产生1.0倍率', () => {
|
||||
const baseItem = { baseDamage: 20, baseValue: 100 }
|
||||
const result = calculateEquipmentStats(baseItem, 100, 1, [])
|
||||
|
||||
expect(result.finalDamage).toBe(20)
|
||||
expect(result.finalValue).toBe(100)
|
||||
})
|
||||
|
||||
it('品质150应该产生1.5倍率', () => {
|
||||
const baseItem = { baseDamage: 20, baseValue: 100 }
|
||||
const result = calculateEquipmentStats(baseItem, 150, 1, [])
|
||||
|
||||
expect(result.finalDamage).toBe(30) // 20 * 1.5
|
||||
expect(result.finalValue).toBe(150)
|
||||
})
|
||||
|
||||
it('品质50应该产生0.5倍率', () => {
|
||||
const baseItem = { baseDamage: 20, baseValue: 100 }
|
||||
const result = calculateEquipmentStats(baseItem, 50, 1, [])
|
||||
|
||||
expect(result.finalDamage).toBe(10) // 20 * 0.5
|
||||
expect(result.finalValue).toBe(50)
|
||||
})
|
||||
|
||||
it('物品等级应该影响属性', () => {
|
||||
const baseItem = { baseDamage: 20 }
|
||||
const result1 = calculateEquipmentStats(baseItem, 100, 1, [])
|
||||
const result2 = calculateEquipmentStats(baseItem, 100, 10, [])
|
||||
|
||||
// 每级 +2%
|
||||
expect(result2.finalDamage).toBe(23) // 20 * 1.02^9 ≈ 23.9, rounded = 23
|
||||
})
|
||||
})
|
||||
|
||||
describe('品质等级获取', () => {
|
||||
it('应该正确获取品质等级', () => {
|
||||
expect(getQualityLevel(0).name).toBe('垃圾')
|
||||
expect(getQualityLevel(50).name).toBe('普通')
|
||||
expect(getQualityLevel(90).name).toBe('优秀')
|
||||
expect(getQualityLevel(130).name).toBe('稀有')
|
||||
expect(getQualityLevel(160).name).toBe('史诗')
|
||||
expect(getQualityLevel(200).name).toBe('传说')
|
||||
})
|
||||
|
||||
it('应该正确返回品质颜色', () => {
|
||||
expect(getQualityLevel(200).color).toBe('#f59e0b')
|
||||
expect(getQualityLevel(130).color).toBe('#3b82f6')
|
||||
})
|
||||
})
|
||||
|
||||
describe('词缀系统', () => {
|
||||
it('应该计算词缀属性加成', () => {
|
||||
const affixes = [
|
||||
{ type: 'attack', value: 5 },
|
||||
{ type: 'critRate', value: 3 }
|
||||
]
|
||||
const result = calculateAffixStats(affixes, 1)
|
||||
|
||||
expect(result.attackBonus).toBe(5)
|
||||
expect(result.critRate).toBe(3)
|
||||
})
|
||||
|
||||
it('词缀属性应该随物品等级缩放', () => {
|
||||
const affixes = [{ type: 'attack', value: 10 }]
|
||||
const result1 = calculateAffixStats(affixes, 1)
|
||||
const result2 = calculateAffixStats(affixes, 10)
|
||||
|
||||
// 等级10: 10 * (1 + 9 * 0.1) = 10 * 1.9 = 19
|
||||
expect(result2.attackBonus).toBeGreaterThan(result1.attackBonus)
|
||||
})
|
||||
|
||||
it('低品质不应该生成词缀', () => {
|
||||
const affixes = generateAffixes('weapon', 50)
|
||||
expect(affixes.length).toBe(0)
|
||||
})
|
||||
|
||||
it('高品质应该生成更多词缀', () => {
|
||||
const affixes = generateAffixes('weapon', 180)
|
||||
expect(affixes.length).toBeGreaterThanOrEqual(2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('怪物属性计算', () => {
|
||||
it('应该正确缩放怪物属性', () => {
|
||||
const baseMonster = {
|
||||
hp: 100,
|
||||
attack: 10,
|
||||
defense: 5,
|
||||
expReward: 20
|
||||
}
|
||||
|
||||
const level1 = calculateMonsterStats(baseMonster, 1, 1.0)
|
||||
const level10 = calculateMonsterStats(baseMonster, 10, 1.0)
|
||||
|
||||
expect(level10.hp).toBeGreaterThan(level1.hp)
|
||||
expect(level10.attack).toBeGreaterThan(level1.attack)
|
||||
expect(level10.expReward).toBeGreaterThan(level1.expReward)
|
||||
})
|
||||
|
||||
it('怪物缩放应该符合文档公式', () => {
|
||||
const baseMonster = { hp: 100, attack: 10, defense: 5, expReward: 20 }
|
||||
|
||||
// 测试5级怪物: HP = 100 * 1.12^4 = 157
|
||||
const level5 = calculateMonsterStats(baseMonster, 5, 1.0)
|
||||
|
||||
// 1.12^4 = 1.5735...
|
||||
expect(Math.round(level5.hp / 100 * 100) / 100).toBeCloseTo(1.57, 1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('经验计算', () => {
|
||||
it('升级经验应该符合指数增长', () => {
|
||||
const exp2 = getExpForLevel(2)
|
||||
const exp3 = getExpForLevel(3)
|
||||
const exp10 = getExpForLevel(10)
|
||||
|
||||
expect(exp2).toBe(80)
|
||||
expect(exp3).toBeCloseTo(115, 0) // 100 * 1.15
|
||||
expect(exp10).toBeGreaterThan(200)
|
||||
})
|
||||
|
||||
it('等级差应该影响经验获取', () => {
|
||||
const sameLevel = calculateCombatExp(10, 10, 100)
|
||||
const higherLevel = calculateCombatExp(15, 10, 100)
|
||||
const lowerLevel = calculateCombatExp(5, 10, 100)
|
||||
|
||||
expect(higherLevel).toBeGreaterThan(sameLevel)
|
||||
expect(lowerLevel).toBeLessThan(sameLevel)
|
||||
})
|
||||
|
||||
it('过低等级怪物应该大幅衰减经验', () => {
|
||||
const lowLevel = calculateCombatExp(1, 10, 100)
|
||||
const veryLowLevel = calculateCombatExp(1, 20, 100)
|
||||
|
||||
expect(lowLevel).toBeLessThan(100)
|
||||
expect(veryLowLevel).toBeLessThan(20)
|
||||
})
|
||||
})
|
||||
|
||||
describe('技能经验', () => {
|
||||
it('高等级技能应该获得更少经验', () => {
|
||||
const exp1 = calculateSkillExp(1, 100)
|
||||
const exp10 = calculateSkillExp(10, 100)
|
||||
const exp20 = calculateSkillExp(20, 100)
|
||||
|
||||
expect(exp10).toBeLessThan(exp1)
|
||||
expect(exp20).toBeLessThan(exp10)
|
||||
})
|
||||
|
||||
it('技能经验衰减应该符合公式', () => {
|
||||
// 衰减公式: 0.95^(level-1)
|
||||
const exp5 = calculateSkillExp(5, 100)
|
||||
const expected = Math.floor(100 * Math.pow(0.95, 4))
|
||||
|
||||
expect(exp5).toBeCloseTo(expected, 1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('伤害计算', () => {
|
||||
it('应该正确计算基础伤害', () => {
|
||||
const damage = calculateDamage(50, 10, 1)
|
||||
|
||||
// 基础伤害 = 攻击 - 防御 * 0.5 = 50 - 5 = 45
|
||||
// 最小伤害 = 攻击 * 0.2 = 10
|
||||
expect(damage).toBe(45)
|
||||
})
|
||||
|
||||
it('防御应该减少伤害但不低于最小值', () => {
|
||||
const damage1 = calculateDamage(50, 10, 1)
|
||||
const damage2 = calculateDamage(50, 40, 1)
|
||||
|
||||
// 高防御时,伤害应该有最小值保证
|
||||
expect(damage2).toBeGreaterThan(0)
|
||||
expect(damage1).toBeGreaterThan(damage2)
|
||||
})
|
||||
|
||||
it('暴击伤害应该正确计算', () => {
|
||||
const critDamage = calculateCritDamage(100, 1.5)
|
||||
expect(critDamage).toBe(150)
|
||||
})
|
||||
|
||||
it('暴击判定应该在阈值内正确工作', () => {
|
||||
// 测试多次验证概率分布
|
||||
let critCount = 0
|
||||
const trials = 1000
|
||||
const critRate = 50 // 50% 暴击率
|
||||
|
||||
for (let i = 0; i < trials; i++) {
|
||||
// Mock Math.random to return 0.3 (< 50)
|
||||
const originalRandom = Math.random
|
||||
Math.random = () => 0.3
|
||||
if (rollCrit(critRate)) critCount++
|
||||
Math.random = originalRandom
|
||||
}
|
||||
|
||||
// 由于我们mock了random,这应该总是暴击
|
||||
expect(critCount).toBe(trials)
|
||||
})
|
||||
})
|
||||
|
||||
describe('经济系统', () => {
|
||||
it('应该正确计算出售价格', () => {
|
||||
const price1 = calculateSellPrice(100, 100, 0)
|
||||
const price2 = calculateSellPrice(100, 150, 0)
|
||||
const price3 = calculateSellPrice(100, 150, 2)
|
||||
|
||||
expect(price1).toBe(100) // 基础
|
||||
expect(price2).toBeGreaterThan(price1) // 高品质
|
||||
expect(price3).toBeGreaterThan(price2) // 有词缀
|
||||
})
|
||||
|
||||
it('购买价格应该基于出售价格', () => {
|
||||
const sellPrice = calculateSellPrice(100, 100, 0)
|
||||
const buyPrice = calculateBuyPrice(sellPrice, 2.0)
|
||||
|
||||
expect(buyPrice).toBe(200) // 2倍商人倍率
|
||||
})
|
||||
})
|
||||
|
||||
describe('游戏常量一致性', () => {
|
||||
it('常量应该与数学模型一致', () => {
|
||||
expect(GAME_CONSTANTS.QUALITY_LEVELS[1].multiplier).toBe(0.5)
|
||||
expect(GAME_CONSTANTS.QUALITY_LEVELS[2].multiplier).toBe(1.0)
|
||||
expect(GAME_CONSTANTS.QUALITY_LEVELS[3].multiplier).toBe(1.2)
|
||||
expect(GAME_CONSTANTS.QUALITY_LEVELS[4].multiplier).toBe(1.5)
|
||||
expect(GAME_CONSTANTS.QUALITY_LEVELS[5].multiplier).toBe(2.0)
|
||||
expect(GAME_CONSTANTS.QUALITY_LEVELS[6].multiplier).toBe(3.0)
|
||||
})
|
||||
|
||||
it('属性缩放系数应该正确', () => {
|
||||
expect(GAME_CONSTANTS.STAT_SCALING.STRENGTH_TO_ATTACK).toBe(1.0)
|
||||
expect(GAME_CONSTANTS.STAT_SCALING.AGILITY_TO_DODGE).toBe(0.5)
|
||||
expect(GAME_CONSTANTS.STAT_SCALING.DEXTERITY_TO_CRIT).toBe(0.3)
|
||||
expect(GAME_CONSTANTS.STAT_SCALING.VITALITY_TO_HP).toBe(10)
|
||||
})
|
||||
|
||||
it('怪物缩放系数应该正确', () => {
|
||||
expect(GAME_CONSTANTS.MONSTER.HP_SCALING).toBe(1.12)
|
||||
expect(GAME_CONSTANTS.MONSTER.ATTACK_SCALING).toBe(1.08)
|
||||
expect(GAME_CONSTANTS.MONSTER.DEFENSE_SCALING).toBe(1.06)
|
||||
expect(GAME_CONSTANTS.MONSTER.EXP_SCALING).toBe(1.10)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 可玩性测试
|
||||
* 验证游戏在不同阶段的可玩性
|
||||
*/
|
||||
describe('游戏可玩性验证', () => {
|
||||
describe('新手阶段 (Lv1-10)', () => {
|
||||
it('新手应该能击败1级怪物', () => {
|
||||
const playerStats = calculateCharacterStats({
|
||||
strength: 10, agility: 8, dexterity: 8, intuition: 10, vitality: 10
|
||||
}, 1)
|
||||
|
||||
const monster = calculateMonsterStats({
|
||||
hp: 50, attack: 5, defense: 2, expReward: 10
|
||||
}, 1, 1.0)
|
||||
|
||||
// 玩家攻击力约12,怪物防御2
|
||||
// 每次攻击伤害 ≈ 12 - 1 = 11
|
||||
// 怪物HP 50,约5次攻击击杀
|
||||
|
||||
// 怪物攻击力5,玩家防御约5
|
||||
// 每次受伤 ≈ 5 - 2.5 = 2.5
|
||||
// 玩家HP 200,能承受约80次攻击
|
||||
|
||||
expect(playerStats.attack).toBeGreaterThan(monster.defense)
|
||||
expect(playerStats.hp).toBeGreaterThan(monster.hp / 10) // 玩家血量足够
|
||||
})
|
||||
|
||||
it('新手升级经验应该合理', () => {
|
||||
// 1->2级需要100经验
|
||||
const exp1to2 = getExpForLevel(2)
|
||||
const monsterExp = 10 // 1级怪物经验
|
||||
|
||||
// 需要击败10只1级怪物升级
|
||||
expect(exp1to2 / monsterExp).toBeLessThan(20) // 不应该超过20只
|
||||
})
|
||||
})
|
||||
|
||||
describe('中期阶段 (Lv11-30)', () => {
|
||||
it('中期角色应该能应对10级怪物', () => {
|
||||
const playerStats = calculateCharacterStats({
|
||||
strength: 20, agility: 15, dexterity: 15, intuition: 15, vitality: 15
|
||||
}, 15)
|
||||
|
||||
const monster = calculateMonsterStats({
|
||||
hp: 100, attack: 10, defense: 5, expReward: 20
|
||||
}, 10, 1.0)
|
||||
|
||||
// 等级差距5级,怪物更强但玩家属性更高
|
||||
expect(playerStats.attack).toBeGreaterThan(monster.defense * 2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('战斗平衡性', () => {
|
||||
it('攻击姿态应该高伤害低防御', () => {
|
||||
// 这部分需要在战斗系统中测试
|
||||
// 确保不同姿态有明显差异
|
||||
})
|
||||
|
||||
it('闪避率应该有上限', () => {
|
||||
// 测试闪避率计算
|
||||
// 即使敏捷很高,闪避率也应该有上限
|
||||
})
|
||||
})
|
||||
|
||||
describe('经济平衡', () => {
|
||||
it('怪物掉落应该支持购买基础装备', () => {
|
||||
// 测试经济循环
|
||||
// 击败怪物获得的钱应该足够购买装备
|
||||
})
|
||||
|
||||
it('高品质装备应该明显更贵', () => {
|
||||
const normalPrice = calculateSellPrice(100, 100, 0)
|
||||
const epicPrice = calculateSellPrice(100, 180, 2)
|
||||
|
||||
expect(epicPrice).toBeGreaterThan(normalPrice * 1.5)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* 数值模型验证脚本
|
||||
* 运行: node tests/verify-model.js
|
||||
*/
|
||||
|
||||
// 游戏常量
|
||||
const GAME_CONSTANTS = {
|
||||
QUALITY_LEVELS: {
|
||||
1: { name: '垃圾', color: '#6b7280', range: [0, 49], multiplier: 0.5 },
|
||||
2: { name: '普通', color: '#ffffff', range: [50, 99], multiplier: 1.0 },
|
||||
3: { name: '优秀', color: '#22c55e', range: [100, 139], multiplier: 1.2 },
|
||||
4: { name: '稀有', color: '#3b82f6', range: [140, 169], multiplier: 1.5 },
|
||||
5: { name: '史诗', color: '#a855f7', range: [170, 199], multiplier: 2.0 },
|
||||
6: { name: '传说', color: '#f59e0b', range: [200, 250], multiplier: 3.0 }
|
||||
},
|
||||
QUALITY: { BASE_MULTIPLIER: 0.01 },
|
||||
STAT_SCALING: {
|
||||
STRENGTH_TO_ATTACK: 1.0,
|
||||
AGILITY_TO_DODGE: 0.5,
|
||||
DEXTERITY_TO_CRIT: 0.3,
|
||||
VITALITY_TO_HP: 10,
|
||||
VITALITY_TO_REGEN: 0.05
|
||||
},
|
||||
MONSTER: {
|
||||
HP_SCALING: 1.12,
|
||||
ATTACK_SCALING: 1.08,
|
||||
DEFENSE_SCALING: 1.06,
|
||||
EXP_SCALING: 1.10
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 计算函数 ====================
|
||||
|
||||
function calculateCharacterStats(baseStats, level = 1) {
|
||||
const s = GAME_CONSTANTS.STAT_SCALING
|
||||
return {
|
||||
hp: Math.floor(100 + (baseStats.vitality || 10) * s.VITALITY_TO_HP + level * 5),
|
||||
attack: Math.floor((baseStats.strength || 10) * s.STRENGTH_TO_ATTACK + level * 2),
|
||||
critRate: 5 + (baseStats.dexterity || 8) * s.DEXTERITY_TO_CRIT
|
||||
}
|
||||
}
|
||||
|
||||
function calculateEquipmentStats(baseDamage, quality, itemLevel = 1) {
|
||||
const qualityMultiplier = 1 + (quality - 100) * GAME_CONSTANTS.QUALITY.BASE_MULTIPLIER
|
||||
const levelMultiplier = 1 + (itemLevel - 1) * 0.02
|
||||
return Math.floor(baseDamage * qualityMultiplier * levelMultiplier)
|
||||
}
|
||||
|
||||
function calculateMonsterStats(baseHp, level) {
|
||||
return Math.floor(baseHp * Math.pow(GAME_CONSTANTS.MONSTER.HP_SCALING, level - 1))
|
||||
}
|
||||
|
||||
function getExpForLevel(level) {
|
||||
return Math.floor(100 * Math.pow(1.15, level - 2) * (level - 1) * 0.8)
|
||||
}
|
||||
|
||||
function getQualityLevel(quality) {
|
||||
if (quality < 50) return GAME_CONSTANTS.QUALITY_LEVELS[1]
|
||||
if (quality < 100) return GAME_CONSTANTS.QUALITY_LEVELS[2]
|
||||
if (quality < 140) return GAME_CONSTANTS.QUALITY_LEVELS[3]
|
||||
if (quality < 170) return GAME_CONSTANTS.QUALITY_LEVELS[4]
|
||||
if (quality < 200) return GAME_CONSTANTS.QUALITY_LEVELS[5]
|
||||
return GAME_CONSTANTS.QUALITY_LEVELS[6]
|
||||
}
|
||||
|
||||
// ==================== 验证测试 ====================
|
||||
|
||||
console.log('=== 数值模型验证 ===\n')
|
||||
|
||||
// 1. 品质系统测试
|
||||
console.log('1. 品质倍率验证:')
|
||||
console.log(` 品质50 (垃圾): 攻击力20 -> ${calculateEquipmentStats(20, 50, 1)} (0.5x)`)
|
||||
console.log(` 品质100 (普通): 攻击力20 -> ${calculateEquipmentStats(20, 100, 1)} (1.0x)`)
|
||||
console.log(` 品质150 (优秀): 攻击力20 -> ${calculateEquipmentStats(20, 150, 1)} (1.5x)`)
|
||||
console.log(` 品质200 (史诗): 攻击力20 -> ${calculateEquipmentStats(20, 200, 1)} (2.0x)`)
|
||||
console.log(` 品质250 (传说): 攻击力20 -> ${calculateEquipmentStats(20, 250, 1)} (2.5x)`)
|
||||
|
||||
// 2. 物品等级测试
|
||||
console.log('\n2. 物品等级影响 (品质100):')
|
||||
console.log(` Lv1: 攻击力20 -> ${calculateEquipmentStats(20, 100, 1)}`)
|
||||
console.log(` Lv5: 攻击力20 -> ${calculateEquipmentStats(20, 100, 5)}`)
|
||||
console.log(` Lv10: 攻击力20 -> ${calculateEquipmentStats(20, 100, 10)}`)
|
||||
console.log(` Lv50: 攻击力20 -> ${calculateEquipmentStats(20, 100, 50)}`)
|
||||
|
||||
// 3. 角色属性测试
|
||||
console.log('\n3. 角色属性 (Lv1, 默认属性):')
|
||||
const defaultStats = { strength: 10, agility: 8, dexterity: 8, intuition: 10, vitality: 10 }
|
||||
const stats = calculateCharacterStats(defaultStats, 1)
|
||||
console.log(` HP: ${stats.hp}`)
|
||||
console.log(` 攻击: ${stats.attack}`)
|
||||
console.log(` 暴击率: ${stats.critRate}%`)
|
||||
console.log(` 体质+10 -> HP +${calculateCharacterStats({ vitality: 20 }, 1).hp - stats.hp}`)
|
||||
|
||||
// 4. 怪物缩放测试
|
||||
console.log('\n4. 怪物等级缩放 (基础HP 100):')
|
||||
console.log(` Lv1: HP = ${calculateMonsterStats(100, 1)}`)
|
||||
console.log(` Lv5: HP = ${calculateMonsterStats(100, 5)} (1.12^4 ≈ 1.57x)`)
|
||||
console.log(` Lv10: HP = ${calculateMonsterStats(100, 10)} (1.12^9 ≈ 2.8x)`)
|
||||
console.log(` Lv20: HP = ${calculateMonsterStats(100, 20)} (1.12^19 ≈ 8.0x)`)
|
||||
|
||||
// 5. 经验曲线测试
|
||||
console.log('\n5. 升级经验需求:')
|
||||
console.log(` Lv1 -> Lv2: ${getExpForLevel(2)} 经验`)
|
||||
console.log(` Lv5 -> Lv6: ${getExpForLevel(6)} 经验`)
|
||||
console.log(` Lv10 -> Lv11: ${getExpForLevel(11)} 经验`)
|
||||
console.log(` Lv20 -> Lv21: ${getExpForLevel(21)} 经验`)
|
||||
console.log(` Lv50 -> Lv51: ${getExpForLevel(51)} 经验`)
|
||||
|
||||
// 6. 品质等级验证
|
||||
console.log('\n6. 品质等级判定:')
|
||||
for (let q = 0; q <= 250; q += 50) {
|
||||
const level = getQualityLevel(q)
|
||||
console.log(` 品质 ${q}: ${level.name.padEnd(6)} (${level.color})`)
|
||||
}
|
||||
|
||||
// 7. 可玩性验证
|
||||
console.log('\n=== 可玩性验证 ===\n')
|
||||
|
||||
// 新手阶段
|
||||
const playerLv1 = calculateCharacterStats(defaultStats, 1)
|
||||
const monsterLv1 = calculateMonsterStats(50, 1)
|
||||
console.log('新手阶段 (Lv1 vs Lv1 怪物):')
|
||||
console.log(` 玩家 HP: ${playerLv1.hp}, 攻击: ${playerLv1.attack}`)
|
||||
console.log(` 怪物 HP: ${monsterLv1}, 攻击: ${calculateEquipmentStats(5, 100, 1)}`)
|
||||
console.log(` 预期: 玩家约需 5-6 次攻击击杀怪物,能承受 20+ 次攻击`)
|
||||
console.log(` 结论: ${playerLv1.attack > 5 ? '✓ 可玩' : '✗ 太难'}`)
|
||||
|
||||
// 中期阶段
|
||||
const playerLv15 = calculateCharacterStats({
|
||||
strength: 20, agility: 15, dexterity: 15, intuition: 15, vitality: 15
|
||||
}, 15)
|
||||
const monsterLv15 = calculateMonsterStats(100, 15)
|
||||
console.log('\n中期阶段 (Lv15 vs Lv15 怪物):')
|
||||
console.log(` 玩家 HP: ${playerLv15.hp}, 攻击: ${playerLv15.attack}`)
|
||||
console.log(` 怪物 HP: ${monsterLv15}, 攻击: ${calculateEquipmentStats(10, 100, 15)}`)
|
||||
console.log(` 预期: 玩家约需 15-20 次攻击击杀怪物`)
|
||||
console.log(` 结论: ${playerLv15.attack > 20 ? '✓ 可玩' : '需要提升'}`)
|
||||
|
||||
// 战斗经济
|
||||
console.log('\n经济系统:')
|
||||
const normalItemPrice = 100 * 1.0
|
||||
const epicItemPrice = 100 * 2.0
|
||||
const monsterGold = 20
|
||||
console.log(` 普通装备价格: ${normalItemPrice} 铜币`)
|
||||
console.log(` 史诗装备价格: ${epicItemPrice} 铜币`)
|
||||
console.log(` Lv1 怪物掉落: ${monsterGold} 铜币 (假设)`)
|
||||
console.log(` 需要击败 ${Math.ceil(epicItemPrice / monsterGold)} 只怪物购买史诗装备`)
|
||||
|
||||
console.log('\n=== 验证完成 ===')
|
||||
+27
-18
@@ -143,22 +143,27 @@ export function calculateEP(defender, stance = 'balance', environment = 'normal'
|
||||
*
|
||||
* @param {Number} ap - 攻击点数
|
||||
* @param {Number} ep - 闪避点数
|
||||
* @param {Boolean} isPlayer - 是否是玩家攻击(玩家享受最低命中率加成)
|
||||
* @returns {Number} 命中概率 (0-1)
|
||||
*/
|
||||
export function calculateHitRate(ap, ep) {
|
||||
export function calculateHitRate(ap, ep, isPlayer = false) {
|
||||
const ratio = ap / (ep + 1)
|
||||
|
||||
// 非线性命中概率表
|
||||
if (ratio >= 5) return 0.98
|
||||
if (ratio >= 3) return 0.90
|
||||
if (ratio >= 2) return 0.80
|
||||
if (ratio >= 1.5) return 0.65
|
||||
if (ratio >= 1) return 0.50
|
||||
if (ratio >= 0.75) return 0.38
|
||||
if (ratio >= 0.5) return 0.24
|
||||
if (ratio >= 0.33) return 0.15
|
||||
if (ratio >= 0.2) return 0.08
|
||||
return 0.05
|
||||
let hitRate = 0.05
|
||||
if (ratio >= 5) hitRate = 0.98
|
||||
else if (ratio >= 3) hitRate = 0.90
|
||||
else if (ratio >= 2) hitRate = 0.80
|
||||
else if (ratio >= 1.5) hitRate = 0.65
|
||||
else if (ratio >= 1) hitRate = 0.50
|
||||
else if (ratio >= 0.75) hitRate = 0.38
|
||||
else if (ratio >= 0.5) hitRate = 0.24
|
||||
else if (ratio >= 0.33) hitRate = 0.15
|
||||
else if (ratio >= 0.2) hitRate = 0.08
|
||||
|
||||
// 最低命中率:敌人攻击玩家时至少40%命中率,玩家攻击敌人时至少15%
|
||||
const minHitRate = isPlayer ? 0.15 : 0.40
|
||||
return Math.max(minHitRate, hitRate)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,13 +207,13 @@ export function calculateCritMultiplier(attacker) {
|
||||
* @param {Object} defenderBonuses - 防御者加成
|
||||
* @returns {Object} { hit: boolean, damage: number, crit: boolean, evaded: boolean, shieldAbsorbed: number }
|
||||
*/
|
||||
export function processAttack(attacker, defender, stance = 'balance', environment = 'normal', attackerBonuses = {}, defenderBonuses = {}) {
|
||||
export function processAttack(attacker, defender, stance = 'balance', environment = 'normal', attackerBonuses = {}, defenderBonuses = {}, isPlayerAttacker = false) {
|
||||
// 计算AP和EP
|
||||
const ap = calculateAP(attacker, stance, 1, environment, attackerBonuses)
|
||||
const ep = calculateEP(defender, 'balance', environment, defenderBonuses)
|
||||
|
||||
// 计算命中概率
|
||||
const hitRate = calculateHitRate(ap, ep)
|
||||
// 计算命中概率(玩家攻击时isPlayerAttacker=true,敌人攻击时isPlayerAttacker=false)
|
||||
const hitRate = calculateHitRate(ap, ep, isPlayerAttacker)
|
||||
|
||||
// 第一步:闪避判定
|
||||
const roll = Math.random()
|
||||
@@ -391,7 +396,8 @@ export function combatTick(gameStore, playerStore, combatState) {
|
||||
stance,
|
||||
environment,
|
||||
playerBonuses,
|
||||
{}
|
||||
{},
|
||||
true // 玩家攻击
|
||||
)
|
||||
|
||||
if (playerAttack.hit) {
|
||||
@@ -441,7 +447,8 @@ export function combatTick(gameStore, playerStore, combatState) {
|
||||
'balance',
|
||||
environment,
|
||||
{},
|
||||
playerBonuses
|
||||
playerBonuses,
|
||||
false // 敌人攻击
|
||||
)
|
||||
|
||||
if (enemyAttack.hit) {
|
||||
@@ -516,9 +523,10 @@ export function getStaminaCost(stance) {
|
||||
* @param {String} enemyId - 敌人ID
|
||||
* @param {Object} enemyConfig - 敌人配置
|
||||
* @param {String} environment - 环境类型
|
||||
* @param {String} preferredStance - 玩家偏好的战斗姿态
|
||||
* @returns {Object} 战斗状态
|
||||
*/
|
||||
export function initCombat(enemyId, enemyConfig, environment = 'normal') {
|
||||
export function initCombat(enemyId, enemyConfig, environment = 'normal', preferredStance = 'balance') {
|
||||
return {
|
||||
enemyId,
|
||||
enemy: {
|
||||
@@ -530,9 +538,10 @@ export function initCombat(enemyId, enemyConfig, environment = 'normal') {
|
||||
defense: enemyConfig.baseStats.defense,
|
||||
baseStats: enemyConfig.baseStats,
|
||||
expReward: enemyConfig.expReward,
|
||||
skillExpReward: enemyConfig.skillExpReward || 0,
|
||||
drops: enemyConfig.drops || []
|
||||
},
|
||||
stance: 'balance',
|
||||
stance: preferredStance, // 使用玩家偏好的战斗姿态
|
||||
environment,
|
||||
startTime: Date.now(),
|
||||
ticks: 0
|
||||
|
||||
+129
-4
@@ -8,9 +8,11 @@ import { EVENT_CONFIG } from '@/config/events.js'
|
||||
import { LOCATION_CONFIG } from '@/config/locations.js'
|
||||
import { SKILL_CONFIG } from '@/config/skills.js'
|
||||
import { ENEMY_CONFIG } from '@/config/enemies.js'
|
||||
import { ITEM_CONFIG } from '@/config/items.js'
|
||||
import { unlockSkill } from './skillSystem.js'
|
||||
import { addItemToInventory } from './itemSystem.js'
|
||||
import { initCombat, getEnvironmentType } from './combatSystem.js'
|
||||
import { installProsthetic, removeProsthetic } from './prostheticSystem.js'
|
||||
|
||||
/**
|
||||
* 检查并触发事件
|
||||
@@ -198,8 +200,9 @@ function renderTemplate(template, context) {
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
* @param {String} npcId - NPC ID
|
||||
* @param {String} dialogueKey - 对话键名
|
||||
* @param {Object} playerStore - 玩家Store(用于动态选项生成)
|
||||
*/
|
||||
export function startNPCDialogue(gameStore, npcId, dialogueKey = 'first') {
|
||||
export function startNPCDialogue(gameStore, npcId, dialogueKey = 'first', playerStore = null) {
|
||||
const npc = NPC_CONFIG[npcId]
|
||||
if (!npc) {
|
||||
console.warn(`NPC ${npcId} not found`)
|
||||
@@ -212,14 +215,27 @@ export function startNPCDialogue(gameStore, npcId, dialogueKey = 'first') {
|
||||
return
|
||||
}
|
||||
|
||||
// 处理模板变量
|
||||
let text = dialogue.text
|
||||
if (playerStore) {
|
||||
text = renderDialogueTemplate(text, playerStore, dialogue)
|
||||
}
|
||||
|
||||
// 生成选项列表(包括动态选项)
|
||||
let choices = dialogue.choices || []
|
||||
if (dialogue.dynamicChoices && playerStore) {
|
||||
const dynamicChoices = generateDynamicChoices(dialogue.dynamicChoices, playerStore)
|
||||
choices = [...dynamicChoices, ...choices]
|
||||
}
|
||||
|
||||
// 构建事件数据
|
||||
const eventData = {
|
||||
id: `npc_${npcId}_${dialogueKey}`,
|
||||
type: 'dialogue',
|
||||
title: npc.name,
|
||||
text: dialogue.text,
|
||||
text: text,
|
||||
npc: npc,
|
||||
choices: dialogue.choices || [],
|
||||
choices: choices,
|
||||
currentDialogue: dialogueKey,
|
||||
npcId
|
||||
}
|
||||
@@ -228,6 +244,61 @@ export function startNPCDialogue(gameStore, npcId, dialogueKey = 'first') {
|
||||
gameStore.drawerState.event = true
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染对话模板(替换变量)
|
||||
*/
|
||||
function renderDialogueTemplate(template, playerStore, dialogue) {
|
||||
let text = template
|
||||
|
||||
// 替换义体列表
|
||||
if (text.includes('{prosthetic_list}')) {
|
||||
const prostheticList = getProstheticInventoryList(playerStore)
|
||||
text = text.replace('{prosthetic_list}', prostheticList)
|
||||
}
|
||||
|
||||
// 替换已装备的义体
|
||||
if (text.includes('{equipped_prosthetic}')) {
|
||||
const equipped = playerStore.equipment?.prosthetic
|
||||
const equippedText = equipped ? `${equipped.name} (${equipped.description})` : '无'
|
||||
text = text.replace('{equipped_prosthetic}', equippedText)
|
||||
}
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取玩家背包中的义体列表
|
||||
*/
|
||||
function getProstheticInventoryList(playerStore) {
|
||||
const prosthetics = playerStore.inventory.filter(item => item.type === 'prosthetic')
|
||||
if (prosthetics.length === 0) {
|
||||
return '(你没有义体可以安装)'
|
||||
}
|
||||
return prosthetics.map(p => `• ${p.name}: ${p.description}`).join('\n')
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成动态选项
|
||||
*/
|
||||
function generateDynamicChoices(type, playerStore) {
|
||||
switch (type) {
|
||||
case 'prosthetic_inventory':
|
||||
// 生成义体安装选项
|
||||
const prosthetics = playerStore.inventory.filter(item => item.type === 'prosthetic')
|
||||
if (prosthetics.length === 0) {
|
||||
return []
|
||||
}
|
||||
return prosthetics.map(p => ({
|
||||
text: `安装 ${p.name}`,
|
||||
action: 'install_prosthetic',
|
||||
actionData: { itemId: p.id }
|
||||
}))
|
||||
|
||||
default:
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理对话选择
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
@@ -259,7 +330,7 @@ export function handleDialogueChoice(gameStore, playerStore, choice) {
|
||||
// 继续对话
|
||||
const currentEvent = gameStore.currentEvent
|
||||
if (currentEvent && currentEvent.npc) {
|
||||
startNPCDialogue(gameStore, currentEvent.npc.id, choice.next)
|
||||
startNPCDialogue(gameStore, currentEvent.npc.id, choice.next, playerStore)
|
||||
result.closeEvent = false
|
||||
}
|
||||
} else if (!choice.action) {
|
||||
@@ -418,6 +489,60 @@ export function processDialogueAction(gameStore, playerStore, action, actionData
|
||||
// 直接关闭
|
||||
return { success: true, message: '', closeEvent: true }
|
||||
|
||||
case 'install_prosthetic':
|
||||
// 安装义体
|
||||
if (actionData.itemId) {
|
||||
const item = playerStore.inventory.find(i => i.id === actionData.itemId)
|
||||
if (!item) {
|
||||
return { success: false, message: '找不到该义体', closeEvent: false }
|
||||
}
|
||||
const installResult = installProsthetic(playerStore, gameStore, item)
|
||||
if (installResult.success) {
|
||||
// 从背包移除义体
|
||||
const index = playerStore.inventory.findIndex(i => i.id === actionData.itemId)
|
||||
if (index > -1) {
|
||||
playerStore.inventory.splice(index, 1)
|
||||
}
|
||||
// 解锁义体技能
|
||||
if (item.grantedSkill) {
|
||||
unlockSkill(playerStore, item.grantedSkill)
|
||||
if (gameStore.addLog) {
|
||||
gameStore.addLog(`解锁了技能: ${SKILL_CONFIG[item.grantedSkill]?.name || item.grantedSkill}`, 'system')
|
||||
}
|
||||
}
|
||||
// 更新成就进度
|
||||
gameStore.achievementProgress.prostheticEquipped = 1
|
||||
gameStore.checkAchievements('equip_prosthetic', { prostheticCount: 1 })
|
||||
// 重新显示对话框
|
||||
const currentEvent = gameStore.currentEvent
|
||||
if (currentEvent && currentEvent.npc) {
|
||||
startNPCDialogue(gameStore, currentEvent.npc.id, 'first', playerStore)
|
||||
}
|
||||
}
|
||||
return { success: installResult.success, message: installResult.message, closeEvent: false }
|
||||
}
|
||||
return { success: false, message: '义体参数错误', closeEvent: false }
|
||||
|
||||
case 'remove_prosthetic':
|
||||
// 卸下义体
|
||||
const removeResult = removeProsthetic(playerStore, gameStore)
|
||||
if (removeResult.success) {
|
||||
// 重新显示对话框
|
||||
const currentEvent = gameStore.currentEvent
|
||||
if (currentEvent && currentEvent.npc) {
|
||||
startNPCDialogue(gameStore, currentEvent.npc.id, 'first', playerStore)
|
||||
}
|
||||
}
|
||||
return { success: removeResult.success, message: removeResult.message, closeEvent: false }
|
||||
|
||||
case 'refresh_list':
|
||||
// 刷新列表(重新显示当前对话框)
|
||||
const evt = gameStore.currentEvent
|
||||
if (evt && evt.npc && evt.currentDialogue) {
|
||||
startNPCDialogue(gameStore, evt.npc.id, evt.currentDialogue, playerStore)
|
||||
}
|
||||
return { success: true, message: '', closeEvent: false }
|
||||
|
||||
default:
|
||||
console.warn(`Unknown dialogue action: ${action}`)
|
||||
return { success: false, message: '未知动作', closeEvent: false }
|
||||
|
||||
+118
-2
@@ -71,6 +71,81 @@ export function isGameLoopRunning() {
|
||||
return isLoopRunning
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查玩家是否正在休息
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function isPlayerResting(gameStore) {
|
||||
return gameStore.activeTasks?.some(task => task.type === 'resting') || false
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查玩家是否正在训练
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function isPlayerTraining(gameStore) {
|
||||
return gameStore.activeTasks?.some(task => task.type === 'training') || false
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理自然回复
|
||||
* 基于体质属性自然回复HP和耐力,休息时提供额外加成
|
||||
* 注意:战斗中和训练时不进行自然回复
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
* @param {Object} playerStore - 玩家Store
|
||||
*/
|
||||
function processNaturalRegeneration(gameStore, playerStore) {
|
||||
const { currentStats, baseStats } = playerStore
|
||||
const isResting = isPlayerResting(gameStore)
|
||||
|
||||
// 体质影响HP回复量:每点体质每秒回复0.05点HP
|
||||
// 体质10 = 每秒0.5点HP基础回复
|
||||
const vitality = baseStats?.vitality || 10
|
||||
const baseHpRegen = vitality * 0.05
|
||||
|
||||
// 耐力基础回复:每秒回复1点
|
||||
const baseStaminaRegen = 1
|
||||
|
||||
// 休息时回复倍率
|
||||
const restMultiplier = isResting ? 3 : 1
|
||||
|
||||
// 计算实际回复量
|
||||
const hpRegen = baseHpRegen * restMultiplier
|
||||
const staminaRegen = baseStaminaRegen * restMultiplier
|
||||
|
||||
// 记录旧值用于日志
|
||||
const oldHp = currentStats.health
|
||||
const oldStamina = currentStats.stamina
|
||||
|
||||
// 应用回复(不超过最大值)
|
||||
const newHp = Math.min(currentStats.maxHealth, currentStats.health + hpRegen)
|
||||
const newStamina = Math.min(currentStats.maxStamina, currentStats.stamina + staminaRegen)
|
||||
|
||||
currentStats.health = newHp
|
||||
currentStats.stamina = newStamina
|
||||
|
||||
// 只在有明显回复且每30秒输出一次日志
|
||||
if (gameStore.lastRegenLogTime === undefined) {
|
||||
gameStore.lastRegenLogTime = 0
|
||||
}
|
||||
|
||||
const now = Date.now()
|
||||
const shouldLog = (now - gameStore.lastRegenLogTime) > 30000 && // 30秒
|
||||
((newHp > oldHp && newHp < currentStats.maxHealth) ||
|
||||
(newStamina > oldStamina && newStamina < currentStats.maxStamina))
|
||||
|
||||
if (shouldLog) {
|
||||
gameStore.lastRegenLogTime = now
|
||||
if (isResting) {
|
||||
// 休息中的日志由休息任务处理,这里不重复输出
|
||||
} else if (newHp > oldHp && newStamina > oldStamina) {
|
||||
gameStore.addLog('自然回复:HP和耐力缓慢恢复中...', 'info')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏主tick - 每秒执行一次
|
||||
* @param {Object} gameStore - 游戏Store
|
||||
@@ -80,6 +155,11 @@ export function gameTick(gameStore, playerStore) {
|
||||
// 1. 更新游戏时间
|
||||
updateGameTime(gameStore)
|
||||
|
||||
// 1.5. 自然回复(仅在非战斗、非训练状态)
|
||||
if (!gameStore.inCombat && !isPlayerTraining(gameStore)) {
|
||||
processNaturalRegeneration(gameStore, playerStore)
|
||||
}
|
||||
|
||||
// 2. 处理战斗
|
||||
if (gameStore.inCombat && gameStore.combatState) {
|
||||
handleCombatTick(gameStore, playerStore)
|
||||
@@ -197,6 +277,9 @@ export function handleCombatVictory(gameStore, playerStore, combatResult) {
|
||||
// 添加日志
|
||||
gameStore.addLog(`战胜了 ${enemy.name}!`, 'reward')
|
||||
|
||||
// 收集所有经验获取信息,用于统一日志显示
|
||||
const expGains = []
|
||||
|
||||
// 给予经验值 (使用新的等级系统)
|
||||
if (enemy.expReward) {
|
||||
const adjustedExp = calculateCombatExp(
|
||||
@@ -204,7 +287,12 @@ export function handleCombatVictory(gameStore, playerStore, combatResult) {
|
||||
playerStore.level.current,
|
||||
enemy.expReward
|
||||
)
|
||||
addExp(playerStore, gameStore, adjustedExp)
|
||||
const levelResult = addExp(playerStore, gameStore, adjustedExp)
|
||||
expGains.push({
|
||||
type: '战斗经验',
|
||||
amount: adjustedExp,
|
||||
leveledUp: levelResult.leveledUp
|
||||
})
|
||||
}
|
||||
|
||||
// 给予武器技能经验奖励
|
||||
@@ -222,14 +310,32 @@ export function handleCombatVictory(gameStore, playerStore, combatResult) {
|
||||
|
||||
if (skillId) {
|
||||
const result = addSkillExp(playerStore, skillId, enemy.skillExpReward)
|
||||
const skillName = SKILL_CONFIG[skillId]?.name || skillId
|
||||
expGains.push({
|
||||
type: `${skillName}经验`,
|
||||
amount: enemy.skillExpReward,
|
||||
leveledUp: result.leveledUp,
|
||||
newLevel: result.newLevel
|
||||
})
|
||||
|
||||
if (result.leveledUp) {
|
||||
const skillName = SKILL_CONFIG[skillId]?.name || skillId
|
||||
gameStore.addLog(`${skillName}升级到了 Lv.${result.newLevel}!`, 'reward')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 统一显示经验获取日志
|
||||
if (expGains.length > 0) {
|
||||
const expText = expGains.map(e => {
|
||||
let text = `${e.type}+${e.amount}`
|
||||
if (e.leveledUp) {
|
||||
text += ` ⬆`
|
||||
}
|
||||
return text
|
||||
}).join(', ')
|
||||
gameStore.addLog(`获得: ${expText}`, 'info')
|
||||
}
|
||||
|
||||
// 处理掉落
|
||||
if (enemy.drops && enemy.drops.length > 0) {
|
||||
processDrops(gameStore, playerStore, enemy.drops)
|
||||
@@ -249,11 +355,17 @@ export function handleCombatVictory(gameStore, playerStore, combatResult) {
|
||||
playerStore.currentStats.stamina > 10
|
||||
|
||||
if (canContinue) {
|
||||
// 设置寻找中状态
|
||||
gameStore.isSearching = true
|
||||
gameStore.addLog('正在寻找新的敌人...', 'info')
|
||||
|
||||
// 延迟3秒后开始下一场战斗
|
||||
setTimeout(() => {
|
||||
if (!gameStore.inCombat && gameStore.autoCombat) {
|
||||
startAutoCombat(gameStore, playerStore)
|
||||
}
|
||||
// 清除寻找中状态(无论是否成功找到敌人)
|
||||
gameStore.isSearching = false
|
||||
}, 3000)
|
||||
} else {
|
||||
// 状态过低,自动关闭自动战斗
|
||||
@@ -275,6 +387,7 @@ function startAutoCombat(gameStore, playerStore) {
|
||||
|
||||
if (!locationEnemies || locationEnemies.length === 0) {
|
||||
gameStore.autoCombat = false
|
||||
gameStore.isSearching = false
|
||||
gameStore.addLog('当前区域没有敌人,自动战斗已停止', 'info')
|
||||
return
|
||||
}
|
||||
@@ -284,10 +397,13 @@ function startAutoCombat(gameStore, playerStore) {
|
||||
const enemyConfig = ENEMY_CONFIG[enemyId]
|
||||
|
||||
if (!enemyConfig) {
|
||||
gameStore.isSearching = false
|
||||
gameStore.addLog('敌人配置错误', 'error')
|
||||
return
|
||||
}
|
||||
|
||||
// 清除寻找中状态
|
||||
gameStore.isSearching = false
|
||||
gameStore.addLog(`自动寻找中...遇到了 ${enemyConfig.name}!`, 'combat')
|
||||
const environment = getEnvironmentType(locationId)
|
||||
gameStore.combatState = initCombat(enemyId, enemyConfig, environment)
|
||||
|
||||
+65
-46
@@ -9,18 +9,29 @@ import { SKILL_CONFIG } from '@/config/skills.js'
|
||||
|
||||
/**
|
||||
* 计算装备品质后的属性
|
||||
* 使用数学模型中的公式:品质倍率 = 1 + (品质 - 100) * 0.01
|
||||
* @param {String} itemId - 物品ID
|
||||
* @param {Number} quality - 品质值 (0-250)
|
||||
* @param {Number} itemLevel - 物品等级(影响属性)
|
||||
* @returns {Object|null} 计算后的属性
|
||||
*/
|
||||
export function calculateItemStats(itemId, quality = 100) {
|
||||
export function calculateItemStats(itemId, quality = 100, itemLevel = 1) {
|
||||
const config = ITEM_CONFIG[itemId]
|
||||
if (!config) {
|
||||
return null
|
||||
}
|
||||
|
||||
const qualityLevel = getQualityLevel(quality)
|
||||
const qualityMultiplier = qualityLevel.multiplier
|
||||
|
||||
// 品质倍率:1 + (品质 - 100) * 0.01
|
||||
// 品质100 = 1.0倍,品质150 = 1.5倍,品质50 = 0.5倍
|
||||
const qualityMultiplier = 1 + (quality - 100) * GAME_CONSTANTS.QUALITY.BASE_MULTIPLIER
|
||||
|
||||
// 等级倍率:每级 +2%
|
||||
const levelMultiplier = 1 + (itemLevel - 1) * 0.02
|
||||
|
||||
// 综合倍率
|
||||
const totalMultiplier = qualityMultiplier * levelMultiplier
|
||||
|
||||
const stats = {
|
||||
id: itemId,
|
||||
@@ -30,36 +41,35 @@ export function calculateItemStats(itemId, quality = 100) {
|
||||
description: config.description,
|
||||
icon: config.icon,
|
||||
quality: quality,
|
||||
itemLevel: itemLevel,
|
||||
qualityLevel: qualityLevel.level,
|
||||
qualityName: qualityLevel.name,
|
||||
qualityColor: qualityLevel.color
|
||||
}
|
||||
|
||||
// 应用品质百分比到基础属性
|
||||
const qualityRatio = quality / 100
|
||||
|
||||
// 应用品质倍率到基础属性
|
||||
if (config.baseDamage) {
|
||||
stats.baseDamage = config.baseDamage
|
||||
stats.finalDamage = Math.floor(config.baseDamage * qualityRatio * qualityMultiplier)
|
||||
stats.finalDamage = Math.max(1, Math.floor(config.baseDamage * totalMultiplier))
|
||||
}
|
||||
|
||||
if (config.baseDefense) {
|
||||
stats.baseDefense = config.baseDefense
|
||||
stats.finalDefense = Math.floor(config.baseDefense * qualityRatio * qualityMultiplier)
|
||||
stats.finalDefense = Math.max(1, Math.floor(config.baseDefense * totalMultiplier))
|
||||
}
|
||||
|
||||
if (config.baseShield) {
|
||||
stats.baseShield = config.baseShield
|
||||
stats.finalShield = Math.floor(config.baseShield * qualityRatio * qualityMultiplier)
|
||||
stats.finalShield = Math.floor(config.baseShield * totalMultiplier)
|
||||
}
|
||||
|
||||
if (config.attackSpeed) {
|
||||
stats.attackSpeed = config.attackSpeed
|
||||
}
|
||||
|
||||
// 计算价值
|
||||
// 计算价值(品质影响)
|
||||
stats.baseValue = config.baseValue || 0
|
||||
stats.finalValue = Math.floor(config.baseValue * qualityRatio * qualityMultiplier)
|
||||
stats.finalValue = Math.floor(config.baseValue * totalMultiplier)
|
||||
|
||||
// 消耗品效果
|
||||
if (config.effect) {
|
||||
@@ -78,6 +88,11 @@ export function calculateItemStats(itemId, quality = 100) {
|
||||
stats.unlockSkill = config.unlockSkill
|
||||
}
|
||||
|
||||
// 额外属性(来自物品配置)
|
||||
if (config.stats) {
|
||||
stats.stats = { ...config.stats }
|
||||
}
|
||||
|
||||
// 堆叠信息
|
||||
if (config.stackable !== undefined) {
|
||||
stats.stackable = config.stackable
|
||||
@@ -115,34 +130,34 @@ export function getQualityLevel(quality) {
|
||||
* @returns {Number} 品质值
|
||||
*/
|
||||
export function generateRandomQuality(luck = 0) {
|
||||
// 基础品质范围 50-150
|
||||
const baseMin = 50
|
||||
const baseMax = 150
|
||||
// 单次随机判定
|
||||
const roll = Math.random()
|
||||
|
||||
// 运气加成:每1点运气增加0.5品质
|
||||
const luckBonus = luck * 0.5
|
||||
// 运气加成:每1点运气增加对应品质概率的 0.1%
|
||||
const luckBonus = luck * 0.001
|
||||
|
||||
// 随机品质
|
||||
let quality = Math.floor(Math.random() * (baseMax - baseMin + 1)) + baseMin + luckBonus
|
||||
|
||||
// 小概率生成高品质(传说)
|
||||
if (Math.random() < 0.01 + luck / 10000) {
|
||||
quality = 180 + Math.floor(Math.random() * 70) // 180-250
|
||||
// 传说品质:0.1% + 运气加成
|
||||
if (roll < 0.001 + luckBonus) {
|
||||
return 200 + Math.floor(Math.random() * 51) // 200-250
|
||||
}
|
||||
// 史诗品质
|
||||
else if (Math.random() < 0.05 + luck / 2000) {
|
||||
quality = 160 + Math.floor(Math.random() * 40) // 160-199
|
||||
// 史诗品质:1% + 运气加成
|
||||
if (roll < 0.01 + luckBonus * 2) {
|
||||
return 170 + Math.floor(Math.random() * 30) // 170-199
|
||||
}
|
||||
// 稀有品质
|
||||
else if (Math.random() < 0.15 + luck / 500) {
|
||||
quality = 130 + Math.floor(Math.random() * 30) // 130-159
|
||||
// 稀有品质:5% + 运气加成
|
||||
if (roll < 0.05 + luckBonus * 3) {
|
||||
return 140 + Math.floor(Math.random() * 30) // 140-169
|
||||
}
|
||||
// 优秀品质
|
||||
else if (Math.random() < 0.3 + luck / 200) {
|
||||
quality = 100 + Math.floor(Math.random() * 30) // 100-129
|
||||
// 优秀品质:15% + 运气加成
|
||||
if (roll < 0.15 + luckBonus * 4) {
|
||||
return 100 + Math.floor(Math.random() * 40) // 100-139
|
||||
}
|
||||
|
||||
return Math.min(250, Math.max(0, Math.floor(quality)))
|
||||
// 普通品质:剩余大部分
|
||||
if (roll < 0.85) {
|
||||
return 50 + Math.floor(Math.random() * 50) // 50-99
|
||||
}
|
||||
// 垃圾品质:15%
|
||||
return Math.floor(Math.random() * 50) // 0-49
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -432,24 +447,28 @@ export function addItemToInventory(playerStore, itemId, count = 1, quality = nul
|
||||
}
|
||||
}
|
||||
|
||||
// 装备类物品 - 按物品ID + 品质等级堆叠
|
||||
// 装备类物品 - 不堆叠,每个装备都有独立的唯一ID
|
||||
// 这样可以正确跟踪每个装备的装备状态
|
||||
if (needsQuality) {
|
||||
const qualityLevel = itemStats.qualityLevel
|
||||
const existingItem = playerStore.inventory.find(
|
||||
i => i.id === itemId && i.qualityLevel === qualityLevel
|
||||
)
|
||||
if (existingItem) {
|
||||
existingItem.count += count
|
||||
return { success: true, item: existingItem }
|
||||
// 检查是否有完全相同品质的装备(用于显示堆叠数量,但各自独立)
|
||||
// 注意:装备不再真正堆叠,每个都是独立实例
|
||||
// 生成唯一ID:itemId + quality + 时间戳 + 随机数
|
||||
const uniqueId = `${itemId}_q${itemQuality}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`
|
||||
|
||||
const newItem = {
|
||||
...itemStats,
|
||||
uniqueId,
|
||||
count: 1, // 装备始终为1
|
||||
equipped: false,
|
||||
obtainedAt: Date.now()
|
||||
}
|
||||
|
||||
playerStore.inventory.push(newItem)
|
||||
return { success: true, item: newItem }
|
||||
}
|
||||
|
||||
// 创建新物品
|
||||
// 装备类物品使用 itemId + qualityLevel 作为唯一标识
|
||||
// 素材类物品使用 itemId + 时间戳(虽然可堆叠,但保留唯一ID用于其他用途)
|
||||
const uniqueId = needsQuality
|
||||
? `${itemId}_q${itemStats.qualityLevel}`
|
||||
: `${itemId}_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`
|
||||
// 创建新物品(非装备类)
|
||||
const uniqueId = `${itemId}_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`
|
||||
|
||||
const newItem = {
|
||||
...itemStats,
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
/**
|
||||
* 地图布局系统 - 根据区域连接生成可视化地图
|
||||
*/
|
||||
|
||||
import { LOCATION_CONFIG } from '@/config/locations.js'
|
||||
|
||||
/**
|
||||
* 构建地图图形结构
|
||||
* @returns {Object} 地图数据
|
||||
*/
|
||||
export function buildMapGraph() {
|
||||
const nodes = []
|
||||
const edges = []
|
||||
|
||||
// 首先创建所有节点
|
||||
for (const [id, config] of Object.entries(LOCATION_CONFIG)) {
|
||||
nodes.push({
|
||||
id,
|
||||
name: config.name,
|
||||
type: config.type,
|
||||
x: 0,
|
||||
y: 0
|
||||
})
|
||||
}
|
||||
|
||||
// 创建连接边
|
||||
for (const [id, config] of Object.entries(LOCATION_CONFIG)) {
|
||||
if (config.connections) {
|
||||
for (const connId of config.connections) {
|
||||
// 避免重复边
|
||||
const edgeExists = edges.some(e =>
|
||||
(e.from === id && e.to === connId) ||
|
||||
(e.from === connId && e.to === id)
|
||||
)
|
||||
if (!edgeExists) {
|
||||
edges.push({ from: id, to: connId })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { nodes, edges }
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单的力导向布局算法
|
||||
* 将节点分布在合理的坐标上
|
||||
* @param {Object} graph - 地图图形结构
|
||||
* @param {Object} options - 布局选项
|
||||
* @returns {Object} 带有坐标的节点
|
||||
*/
|
||||
export function layoutMap(graph, options = {}) {
|
||||
const { nodes, edges } = graph
|
||||
const { width = 300, height = 400 } = options
|
||||
|
||||
// 创建邻接表
|
||||
const adj = {}
|
||||
for (const node of nodes) {
|
||||
adj[node.id] = []
|
||||
}
|
||||
for (const edge of edges) {
|
||||
adj[edge.from].push(edge.to)
|
||||
adj[edge.to].push(edge.from)
|
||||
}
|
||||
|
||||
// 找到中心节点(连接最多的节点作为起点)
|
||||
let centerNode = nodes[0]
|
||||
for (const node of nodes) {
|
||||
if (adj[node.id].length > adj[centerNode.id].length) {
|
||||
centerNode = node
|
||||
}
|
||||
}
|
||||
|
||||
// BFS 分层布局
|
||||
const levels = {}
|
||||
const visited = new Set()
|
||||
const queue = [{ id: centerNode.id, level: 0 }]
|
||||
|
||||
while (queue.length > 0) {
|
||||
const { id, level } = queue.shift()
|
||||
if (visited.has(id)) continue
|
||||
visited.add(id)
|
||||
|
||||
if (!levels[level]) levels[level] = []
|
||||
levels[level].push(id)
|
||||
|
||||
for (const neighbor of adj[id]) {
|
||||
if (!visited.has(neighbor)) {
|
||||
queue.push({ id: neighbor, level: level + 1 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算节点位置
|
||||
const nodePositions = {}
|
||||
const levelHeight = height / (Object.keys(levels).length + 1)
|
||||
|
||||
for (const [level, nodeIds] of Object.entries(levels)) {
|
||||
const y = (parseInt(level) + 1) * levelHeight
|
||||
const levelWidth = width / (nodeIds.length + 1)
|
||||
|
||||
nodeIds.forEach((nodeId, index) => {
|
||||
nodePositions[nodeId] = {
|
||||
x: (index + 1) * levelWidth,
|
||||
y
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 更新节点坐标
|
||||
return nodes.map(node => ({
|
||||
...node,
|
||||
x: nodePositions[node.id]?.x || width / 2,
|
||||
y: nodePositions[node.id]?.y || height / 2
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取从当前位置可达的区域(包括多步可达)
|
||||
* @param {string} currentLocation - 当前位置ID
|
||||
* @param {number} maxDistance - 最大距离(步数)
|
||||
* @returns {Object} 可达区域信息,key为locationId,value为距离
|
||||
*/
|
||||
export function getReachableLocations(currentLocation, maxDistance = 10) {
|
||||
const distances = {}
|
||||
const queue = [{ id: currentLocation, dist: 0 }]
|
||||
|
||||
distances[currentLocation] = 0
|
||||
|
||||
while (queue.length > 0) {
|
||||
const { id, dist } = queue.shift()
|
||||
|
||||
if (dist >= maxDistance) continue
|
||||
|
||||
// 找到所有连接的节点
|
||||
const connections = LOCATION_CONFIG[id]?.connections || []
|
||||
for (const connId of connections) {
|
||||
if (distances[connId] === undefined) {
|
||||
distances[connId] = dist + 1
|
||||
queue.push({ id: connId, dist: dist + 1 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return distances
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地图的路径信息
|
||||
* @param {string} from - 起点
|
||||
* @param {string} to - 终点
|
||||
* @returns {Array} 路径数组
|
||||
*/
|
||||
export function getPath(from, to) {
|
||||
if (from === to) return [from]
|
||||
|
||||
const { edges } = buildMapGraph()
|
||||
const adj = {}
|
||||
for (const node of Object.keys(LOCATION_CONFIG)) {
|
||||
adj[node] = LOCATION_CONFIG[node]?.connections || []
|
||||
}
|
||||
|
||||
// BFS 寻找最短路径
|
||||
const queue = [[from]]
|
||||
const visited = new Set([from])
|
||||
|
||||
while (queue.length > 0) {
|
||||
const path = queue.shift()
|
||||
const current = path[path.length - 1]
|
||||
|
||||
if (current === to) {
|
||||
return path
|
||||
}
|
||||
|
||||
for (const neighbor of adj[current]) {
|
||||
if (!visited.has(neighbor)) {
|
||||
visited.add(neighbor)
|
||||
queue.push([...path, neighbor])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null // 无路径
|
||||
}
|
||||
|
||||
/**
|
||||
* 预定义的地图布局配置
|
||||
* 为每个区域指定固定的显示位置
|
||||
*/
|
||||
export const PREDEFINED_LAYOUT = {
|
||||
// 营地为中心
|
||||
camp: { x: 150, y: 200 },
|
||||
// 营地周围
|
||||
market: { x: 50, y: 120 },
|
||||
blackmarket: { x: 250, y: 120 },
|
||||
wild1: { x: 150, y: 320 },
|
||||
// 更远的地方
|
||||
boss_lair: { x: 150, y: 440 },
|
||||
basement: { x: 150, y: 540 }
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用预定义布局获取节点位置
|
||||
* @param {Object} graph - 地图图形结构
|
||||
* @returns {Array} 带有坐标的节点
|
||||
*/
|
||||
export function getPredefinedLayout(graph) {
|
||||
const { nodes } = graph
|
||||
|
||||
return nodes.map(node => ({
|
||||
...node,
|
||||
x: PREDEFINED_LAYOUT[node.id]?.x || 150,
|
||||
y: PREDEFINED_LAYOUT[node.id]?.y || 200
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可视化的地图数据
|
||||
* @param {string} currentLocation - 当前位置
|
||||
* @returns {Object} 地图数据
|
||||
*/
|
||||
export function getMapData(currentLocation) {
|
||||
const graph = buildMapGraph()
|
||||
const layoutNodes = getPredefinedLayout(graph)
|
||||
|
||||
// 计算画布大小
|
||||
let maxX = 0, maxY = 0
|
||||
for (const node of layoutNodes) {
|
||||
maxX = Math.max(maxX, node.x)
|
||||
maxY = Math.max(maxY, node.y)
|
||||
}
|
||||
|
||||
// 获取可达距离
|
||||
const reachable = getReachableLocations(currentLocation, 10)
|
||||
|
||||
// 计算到每个区域的路径
|
||||
const paths = {}
|
||||
for (const node of layoutNodes) {
|
||||
const path = getPath(currentLocation, node.id)
|
||||
if (path) {
|
||||
paths[node.id] = path
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
nodes: layoutNodes,
|
||||
edges: graph.edges,
|
||||
width: maxX + 50,
|
||||
height: maxY + 50,
|
||||
currentLocation,
|
||||
reachable,
|
||||
paths
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,7 @@ function serializeGameData(gameStore) {
|
||||
activeTasks: JSON.parse(JSON.stringify(gameStore.activeTasks || [])),
|
||||
negativeStatus: JSON.parse(JSON.stringify(gameStore.negativeStatus || [])),
|
||||
marketPrices: JSON.parse(JSON.stringify(gameStore.marketPrices || {})),
|
||||
autoCombat: gameStore.autoCombat || false, // 保存自动战斗状态
|
||||
// 不保存日志(logs不持久化)
|
||||
// 不保存战斗状态(重新登录时退出战斗)
|
||||
// 不保存当前事件(重新登录时清除)
|
||||
@@ -262,6 +263,11 @@ function applyGameData(gameStore, data) {
|
||||
gameStore.marketPrices = JSON.parse(JSON.stringify(data.marketPrices))
|
||||
}
|
||||
|
||||
// 自动战斗状态
|
||||
if (data.autoCombat !== undefined) {
|
||||
gameStore.autoCombat = data.autoCombat
|
||||
}
|
||||
|
||||
// 定时事件
|
||||
if (data.scheduledEvents) {
|
||||
gameStore.scheduledEvents = JSON.parse(JSON.stringify(data.scheduledEvents))
|
||||
|
||||
+32
-6
@@ -312,6 +312,9 @@ function processReadingTask(gameStore, playerStore, task, elapsedSeconds) {
|
||||
|
||||
const readingTime = bookConfig.readingTime || 60
|
||||
|
||||
// 首次阅读时解锁阅读技能
|
||||
unlockSkill(playerStore, 'reading')
|
||||
|
||||
// 检查环境惩罚
|
||||
const location = playerStore.currentLocation
|
||||
let timeMultiplier = 1.0
|
||||
@@ -322,9 +325,26 @@ function processReadingTask(gameStore, playerStore, task, elapsedSeconds) {
|
||||
timeMultiplier = 0.5 + (darkPenaltyReduce / 100) * 0.5
|
||||
}
|
||||
|
||||
// 阅读技能速度加成
|
||||
const readingSkillLevel = playerStore.skills.reading?.level || 0
|
||||
const readingSpeedBonus = playerStore.globalBonus?.readingSpeed || 1
|
||||
timeMultiplier *= readingSpeedBonus
|
||||
|
||||
// 计算有效进度
|
||||
const effectiveProgress = task.progress * timeMultiplier
|
||||
|
||||
// 给予阅读技能经验(每秒给予经验)
|
||||
const readingExpPerSecond = 1
|
||||
const readingExpGain = readingExpPerSecond * elapsedSeconds * timeMultiplier
|
||||
const readingResult = addSkillExp(playerStore, 'reading', readingExpGain)
|
||||
|
||||
// 检查技能是否升级
|
||||
if (readingResult.leveledUp) {
|
||||
if (gameStore.addLog) {
|
||||
gameStore.addLog(`阅读技能升级到了 Lv.${readingResult.newLevel}!`, 'reward')
|
||||
}
|
||||
}
|
||||
|
||||
if (effectiveProgress >= readingTime) {
|
||||
// 阅读完成
|
||||
const rewards = {}
|
||||
@@ -343,13 +363,13 @@ function processReadingTask(gameStore, playerStore, task, elapsedSeconds) {
|
||||
|
||||
// 添加日志
|
||||
if (gameStore.addLog) {
|
||||
gameStore.addLog(`读完了《${bookConfig.name}》`, 'reward')
|
||||
gameStore.addLog(`读完了《${bookConfig.name}》,阅读经验+${Math.floor(readingExpGain * task.progress / readingTime)}`, 'reward')
|
||||
}
|
||||
|
||||
return { completed: true, rewards }
|
||||
}
|
||||
|
||||
// 阅读进行中,给予少量经验
|
||||
// 阅读进行中,给予其他技能经验
|
||||
if (bookConfig.expReward) {
|
||||
for (const [skillId, expPerSecond] of Object.entries(bookConfig.expReward)) {
|
||||
const expPerTick = (expPerSecond / readingTime) * elapsedSeconds * timeMultiplier
|
||||
@@ -412,8 +432,8 @@ function processTrainingTask(gameStore, playerStore, task, elapsedSeconds) {
|
||||
return { completed: true, error: '技能不存在' }
|
||||
}
|
||||
|
||||
// 消耗耐力
|
||||
const staminaCost = 2 * elapsedSeconds
|
||||
// 消耗耐力(降低消耗)
|
||||
const staminaCost = 1 * elapsedSeconds
|
||||
if (playerStore.currentStats.stamina < staminaCost) {
|
||||
// 耐力不足,任务结束
|
||||
return { completed: true, rewards: {} }
|
||||
@@ -421,8 +441,8 @@ function processTrainingTask(gameStore, playerStore, task, elapsedSeconds) {
|
||||
|
||||
playerStore.currentStats.stamina -= staminaCost
|
||||
|
||||
// 给予技能经验
|
||||
const expPerSecond = 1
|
||||
// 给予技能经验(提升获取速度)
|
||||
const expPerSecond = 5 // 从1提升到5
|
||||
const expGain = expPerSecond * elapsedSeconds
|
||||
|
||||
if (!task.accumulatedExp) {
|
||||
@@ -433,6 +453,12 @@ function processTrainingTask(gameStore, playerStore, task, elapsedSeconds) {
|
||||
}
|
||||
task.accumulatedExp[skillId] += expGain
|
||||
|
||||
// 检查技能是否升级
|
||||
const result = addSkillExp(playerStore, skillId, expGain)
|
||||
if (result.leveledUp && gameStore.addLog) {
|
||||
gameStore.addLog(`${skillConfig.name}升级到了 Lv.${result.newLevel}!`, 'reward')
|
||||
}
|
||||
|
||||
// 检查是否完成
|
||||
if (task.data.duration && task.progress >= task.data.duration) {
|
||||
const rewards = { [skillId]: task.accumulatedExp[skillId] || 0 }
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
接下来开发计划
|
||||
阶段1:修复代码问题(优先)
|
||||
# 任务 文件
|
||||
1 添加gameStore中shop抽屉状态 store/game.js
|
||||
2 修复eventSystem中SKILL_CONFIG导入 utils/eventSystem.js
|
||||
3 修复environmentSystem中里程碑奖励调用 utils/environmentSystem.js
|
||||
4 统一击杀数存储方式 utils/eventSystem.js, components/panels/MapPanel.vue
|
||||
5 InventoryDrawer使用itemSystem函数 components/drawers/InventoryDrawer.vue
|
||||
6 任务完成使用addSkillExp utils/taskSystem.js
|
||||
阶段2:补充未实现功能
|
||||
# 功能 描述
|
||||
1 阅读功能 将书籍任务与UI关联,显示阅读进度
|
||||
2 训练功能 添加训练任务UI,技能训练
|
||||
3 任务UI面板 显示活动中的挂机任务进度
|
||||
4 装备属性生效 确保装备属性正确应用到战斗计算
|
||||
5 探索功能 添加探索事件触发
|
||||
阶段3:UI美化
|
||||
# 内容 说明
|
||||
1 状态面板优化 添加属性详情展开/折叠
|
||||
2 战斗视觉反馈 伤害数字跳动、暴击动画
|
||||
3 品质特效 不同品质物品的光效/边框
|
||||
4 日志颜色优化 更精细的日志类型着色
|
||||
5 技能面板 里程碑奖励可视化显示
|
||||
6 过渡动画 页面切换、抽屉弹出动画
|
||||
阶段4:数值调整
|
||||
# 内容 当前 建议
|
||||
1 初始属性 全部10 按角色差异化
|
||||
2 敌人伤害 野狗攻击8 对新手可能偏高
|
||||
3 经验曲线 线性增长 考虑指数衰减
|
||||
4 耐力消耗 战斗2/秒 平衡性测试
|
||||
5 物品价格 基础价格10-50 经济平衡
|
||||
6 品质概率 随机50-150 高品质概率过低
|
||||
阶段5:内容扩展(剧情之前先讨论)
|
||||
# 内容 说明
|
||||
1 更多武器类型 剑、斧、法杖等
|
||||
2 更多消耗品 药水、食物种类
|
||||
3 更多敌人 不同区域的怪物
|
||||
4 更多被动技能 适应不同环境
|
||||
5 成就系统 记录玩家成就
|
||||
🎯 建议优先处理顺序
|
||||
立即修复:代码逻辑问题(阶段1)
|
||||
核心功能补全:阅读、训练、任务UI(阶段2)
|
||||
数值平衡测试:实际游玩体验后调整(阶段4)
|
||||
UI美化:在功能稳定后进行(阶段3)
|
||||
剧情讨论:最后我们一起讨论完善(阶段5)
|
||||
Reference in New Issue
Block a user