210 lines
4.8 KiB
Markdown
210 lines
4.8 KiB
Markdown
# 進化系統設計文檔
|
||
|
||
## 現有實現
|
||
|
||
### 基礎進化機制
|
||
目前系統已支援基於**時間 + 屬性條件**的進化:
|
||
|
||
```javascript
|
||
{
|
||
stage: 'child',
|
||
durationSeconds: 600, // 時間條件:需要 600 秒
|
||
conditions: { // 屬性條件:同時滿足
|
||
str: 20,
|
||
int: 20
|
||
}
|
||
}
|
||
```
|
||
|
||
### 進化條件檢查
|
||
- **時間條件**:寵物年齡 >= durationSeconds
|
||
- **屬性條件**:所有指定屬性都要達標
|
||
- **邏輯**:時間 AND 屬性 都滿足才進化
|
||
|
||
## 進化分支系統設計
|
||
|
||
### 方案 1:多分支進化(推薦)
|
||
|
||
```javascript
|
||
lifecycle: [
|
||
{ stage: 'egg', durationSeconds: 0 },
|
||
{ stage: 'baby', durationSeconds: 300 },
|
||
{
|
||
stage: 'child',
|
||
durationSeconds: 600,
|
||
conditions: { str: 20, int: 20 }
|
||
},
|
||
// 成年體可以有多種進化路線
|
||
{
|
||
stage: 'adult_warrior', // 戰士型
|
||
durationSeconds: 1200,
|
||
conditions: { str: 60, dex: 40 },
|
||
priority: 1
|
||
},
|
||
{
|
||
stage: 'adult_mage', // 法師型
|
||
durationSeconds: 1200,
|
||
conditions: { int: 60, str: 30 },
|
||
priority: 2
|
||
},
|
||
{
|
||
stage: 'adult_balanced', // 平衡型
|
||
durationSeconds: 1200,
|
||
conditions: { str: 50, int: 50, dex: 50 },
|
||
priority: 3
|
||
},
|
||
{
|
||
stage: 'adult', // 普通成年(保底)
|
||
durationSeconds: 1200,
|
||
conditions: {},
|
||
priority: 999
|
||
}
|
||
]
|
||
```
|
||
|
||
**檢查邏輯**:
|
||
1. 時間到達後,檢查所有同階段的進化選項
|
||
2. 按 priority 從小到大檢查
|
||
3. 第一個滿足條件的就進化成該階段
|
||
|
||
### 方案 2:樹狀進化圖
|
||
|
||
```javascript
|
||
export const EVOLUTION_TREE = {
|
||
tinyTigerCat: {
|
||
baby: {
|
||
next: ['child'], // 固定進化
|
||
conditions: { ageSeconds: 300 }
|
||
},
|
||
child: {
|
||
next: ['warrior', 'mage', 'balanced', 'adult'], // 多選一
|
||
conditions: { ageSeconds: 600 },
|
||
branches: {
|
||
warrior: { str: 60, dex: 40 },
|
||
mage: { int: 60, str: 30 },
|
||
balanced: { str: 50, int: 50, dex: 50 },
|
||
adult: {} // 保底
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
### 方案 3:觸發式進化
|
||
|
||
```javascript
|
||
{
|
||
stage: 'adult_legendary', // 傳說型
|
||
trigger: 'special', // 不走正常流程
|
||
conditions: {
|
||
str: 100,
|
||
int: 100,
|
||
dex: 100,
|
||
destiny: 'lucky_star', // 需要特定命格
|
||
deityFavor: 100 // 神明好感滿
|
||
}
|
||
}
|
||
```
|
||
|
||
## 建議實現
|
||
|
||
### 第一階段(基礎)
|
||
使用**方案 1**,在 `pet-species.js` 中定義多條進化路線:
|
||
|
||
```javascript
|
||
lifecycle: [
|
||
{ stage: 'baby', ... },
|
||
{ stage: 'child', ... },
|
||
{
|
||
stage: 'warrior',
|
||
branch: 'combat', // 標記分支類型
|
||
durationSeconds: 1200,
|
||
conditions: { str: 60, dex: 40 },
|
||
priority: 1,
|
||
description: '力量與速度的化身'
|
||
},
|
||
{
|
||
stage: 'mage',
|
||
branch: 'magic',
|
||
durationSeconds: 1200,
|
||
conditions: { int: 60 },
|
||
priority: 2,
|
||
description: '智慧的追求者'
|
||
},
|
||
{
|
||
stage: 'adult',
|
||
branch: 'normal',
|
||
durationSeconds: 1200,
|
||
conditions: {},
|
||
priority: 999,
|
||
description: '普通的成年體'
|
||
}
|
||
]
|
||
```
|
||
|
||
### 第二階段(進階)
|
||
- 添加**超進化**:需要特殊道具或事件觸發
|
||
- 添加**退化機制**:照顧不當可能退化
|
||
- 添加**命格影響**:特定命格解鎖特殊進化路線
|
||
|
||
## 實現細節
|
||
|
||
### 修改 checkStageTransition()
|
||
|
||
```javascript
|
||
checkStageTransition() {
|
||
const ageSeconds = this.state.ageSeconds
|
||
const currentStage = this.state.stage
|
||
|
||
// 找出當前階段的所有可能進化
|
||
const candidates = this.speciesConfig.lifecycle
|
||
.filter(stage =>
|
||
stage.durationSeconds > 0 &&
|
||
ageSeconds >= stage.durationSeconds &&
|
||
stage.stage !== currentStage
|
||
)
|
||
.sort((a, b) => (a.priority || 999) - (b.priority || 999))
|
||
|
||
// 檢查第一個滿足條件的
|
||
for (const candidate of candidates) {
|
||
if (this.checkEvolutionConditions(candidate)) {
|
||
this.evolve(candidate.stage)
|
||
break
|
||
}
|
||
}
|
||
}
|
||
|
||
checkEvolutionConditions(stageConfig) {
|
||
if (!stageConfig.conditions) return true
|
||
|
||
const { str, int, dex, ...others } = stageConfig.conditions
|
||
|
||
if (str && this.state.str < str) return false
|
||
if (int && this.state.int < int) return false
|
||
if (dex && this.state.dex < dex) return false
|
||
|
||
// 可擴展:檢查其他條件
|
||
return true
|
||
}
|
||
```
|
||
|
||
## 數值平衡建議
|
||
|
||
### 進化時間規劃
|
||
- **Egg → Baby**: 5 分鐘(300秒)
|
||
- **Baby → Child**: 6 小時(21,900秒)
|
||
- **Child → Adult**: 3 天(281,100秒)
|
||
|
||
### 屬性要求
|
||
- **Baby → Child**:
|
||
- STR 8, INT 8
|
||
- 設計目標:6小時內約需餵食 30-40 次,玩耍 60-70 次
|
||
- **Child → Adult**:
|
||
- STR 50, INT 50, DEX 50
|
||
- 設計目標:3天內累積,需要持續照顧
|
||
|
||
### 命格影響
|
||
- **武曲星**(力量成長+30%)→ 更容易進化成戰士
|
||
- **文曲星**(智力成長+40%)→ 更容易進化成法師
|
||
- **天乙貴人**(運勢高)→ 可能觸發特殊進化
|