feat:merge health

This commit is contained in:
王性驊 2025-11-24 16:04:00 +08:00
parent 9b1d27186d
commit 9dcae956dc
5 changed files with 1378 additions and 1887 deletions

File diff suppressed because it is too large Load Diff

View File

@ -242,7 +242,8 @@
<h3>[PRAY] 神明系統</h3>
<div class="button-grid">
<button @click="handlePray" :disabled="!isReady">[PRAY] 祈福</button>
<button @click="handleDrawFortune" :disabled="!isReady">[DRAW] 抽籤</button>
<button @click="handleDrawLot" :disabled="!isReady">[LOT] 求籤</button>
<button @click="handleVerifyLot" :disabled="!isReady">[VERIFY] 驗證</button>
<button @click="handleThrowJiaobei" :disabled="!isReady">[JIAOBEI] 擲筊</button>
<button @click="handleListDeities" :disabled="!isReady">[LIST] 神明列表</button>
</div>
@ -849,25 +850,6 @@ async function pray() {
}
}
//
async function drawFortune() {
const result = await templeSystem.drawFortune()
if (result.success) {
console.log('\n[DRAW] 抽籤結果:')
console.log('='.repeat(50))
console.log(`等級: ${result.lot.grade}`)
console.log(`籤詩: ${result.lot.poem1}`)
console.log(` ${result.lot.poem2}`)
console.log(`解釋: ${result.lot.meaning}`)
if (result.buff) {
console.log(`\n* 獲得 Buff: ${result.buff.name}`)
}
console.log('='.repeat(50) + '\n')
} else {
console.log(`[ERR] ${result.message}`)
}
}
//
async function switchDeity(deityId) {
const result = await templeSystem.switchDeity(deityId)
@ -911,6 +893,82 @@ async function handleThrowJiaobei() {
showStatus()
}
//
let currentLotData = null
//
async function handleDrawLot() {
const result = await templeSystem.drawLot('guanyin_100')
if (!result.success) {
console.log(`[ERR] ${result.message}`)
return
}
if (result.needVerification) {
currentLotData = result
console.log('\n[LOT] 求籤結果:')
console.log('='.repeat(50))
console.log(`${result.lot.no} (${result.lot.grade})`)
console.log(`神明: ${result.deity}`)
console.log(`\n⚠ 需要三聖筊驗證才能解籤`)
console.log(`目前: ${result.verificationCount}/${result.requiredHoly} 聖筊`)
console.log('\n請使用 verify() 命令擲筊驗證')
console.log('='.repeat(50) + '\n')
}
}
//
async function handleVerifyLot() {
if (!currentLotData) {
console.log('[ERR] 請先求籤 (使用 [LOT] 求籤 按鈕)')
return
}
const verifyResult = await templeSystem.verifyLot(currentLotData)
console.log('\n[VERIFY] 擲筊驗證:')
console.log('='.repeat(50))
console.log(`結果: ${verifyResult.jiaobeiResult.result === 'holy' ? '⚪⚫ 聖筊' :
verifyResult.jiaobeiResult.result === 'laughing' ? '⚪⚪ 笑筊' : '⚫⚫ 陰筊'}`)
console.log(`訊息: ${verifyResult.message}`)
if (verifyResult.verified) {
//
const lot = currentLotData.lot
console.log('\n' + '🎉'.repeat(20))
console.log(`\n【${lot.no}${lot.grade}`)
console.log('\n【籤詩】')
console.log(lot.poem1)
console.log('\n【解曰】')
console.log(lot.meaning)
console.log('\n【解籤】')
console.log(lot.explanation)
console.log('\n【問神】')
console.log(lot.oracle)
if (lot.story) {
console.log('\n【典故】')
console.log(lot.story)
}
console.log('\n' + '='.repeat(50) + '\n')
//
currentLotData = null
} else if (verifyResult.needMore) {
//
currentLotData.verificationCount = verifyResult.verificationCount
console.log(`\n✓ 進度: ${verifyResult.verificationCount}/${verifyResult.requiredHoly} 聖筊`)
console.log('請繼續使用 verify() 擲筊驗證')
console.log('='.repeat(50) + '\n')
} else if (verifyResult.needRedraw) {
//
console.log('\n✗ 需要重新求籤')
console.log('='.repeat(50) + '\n')
currentLotData = null
}
}
//
function listDeities() {
const deities = templeSystem.getDeities()
@ -1059,9 +1117,6 @@ async function handlePray() {
updatePetState()
}
async function handleDrawFortune() {
await drawFortune()
}
function handleListDeities() {
listDeities()

View File

@ -130,26 +130,37 @@ export class TempleSystem {
}
// 抽籤
async drawFortune() {
// 求籤(需要三聖筊驗證)
async drawLot(lotType = 'guanyin_100') {
const state = this.petSystem.getState()
const deity = this.getCurrentDeity()
// 檢查神明是否支持此簽詩
if (!deity.lotTypes || !deity.lotTypes.includes(lotType)) {
return {
success: false,
message: `${deity.name}不提供${lotType}簽詩`
}
}
try {
const result = await this.api.drawFortune()
// 載入簽詩資料
const lots = await this.loadLots(lotType)
// 根據籤詩等級應用效果
const { FORTUNE_LOTS } = await import('../data/fortune-lots.js')
const lot = FORTUNE_LOTS.find(l => l.grade === result.lot.grade) || FORTUNE_LOTS[0]
// 隨機抽一支簽
const randomIndex = Math.floor(Math.random() * lots.length)
const lot = lots[randomIndex]
if (lot.effects?.addBuff) {
// 應用 Buff需要透過 eventSystem
// 返回需要擲筊驗證的狀態
return {
success: true,
lot: result.lot,
buff: lot.effects.addBuff
}
}
return {
success: true,
lot: result.lot
needVerification: true,
lot,
lotType,
deity: deity.name,
verificationCount: 0,
requiredHoly: 3 // 需要三個聖筊
}
} catch (error) {
console.error('[TempleSystem] 抽籤失敗:', error)
@ -157,6 +168,58 @@ export class TempleSystem {
}
}
// 驗證簽詩(擲筊確認)
async verifyLot(lotData) {
// 擲筊
const jiaobeiResult = await this.throwJiaobei(`求問第${lotData.lot.no}`)
if (jiaobeiResult.result === 'holy') {
// 聖筊
const newCount = (lotData.verificationCount || 0) + 1
if (newCount >= lotData.requiredHoly) {
// 三聖筊,可以解簽
return {
success: true,
verified: true,
lot: lotData.lot,
jiaobeiResult,
message: `三聖筊!${lotData.deity}允准解籤`
}
} else {
// 還需要更多聖筊
return {
success: true,
verified: false,
needMore: true,
verificationCount: newCount,
requiredHoly: lotData.requiredHoly,
lot: lotData.lot,
jiaobeiResult,
message: `${newCount}個聖筊,還需${lotData.requiredHoly - newCount}個聖筊`
}
}
} else {
// 笑筊或陰筊,需要重抽
return {
success: true,
verified: false,
needRedraw: true,
jiaobeiResult,
message: `${jiaobeiResult.result === 'laughing' ? '笑筊' : '陰筊'},請重新抽籤`
}
}
}
// 載入簽詩資料
async loadLots(lotType) {
if (lotType === 'guanyin_100') {
const data = await import('../data/guanyin_100_lots.json')
return data.default || data
}
throw new Error(`未知的簽詩類型: ${lotType}`)
}
// 擲筊
async throwJiaobei(question = '') {
const state = this.petSystem.getState()
@ -190,31 +253,6 @@ export class TempleSystem {
const messages = JIAOBEI_CONFIG.messages[result]
const message = messages[Math.floor(Math.random() * messages.length)]
// 聖筊獎勵:增加好感度
if (result === 'holy') {
const currentFavor = state.deityFavors[deity.id] || 0
const bonus = JIAOBEI_CONFIG.holyFavorBonus || 1
const newFavor = Math.min(100, currentFavor + bonus)
await this.petSystem.updateState({
deityFavors: {
...state.deityFavors,
[deity.id]: newFavor
}
})
// 重新計算屬性
this.petSystem.calculateCombatStats()
// 同步 effective 属性
await this.petSystem.updateState({
effectiveStr: this.petSystem.state.effectiveStr,
effectiveInt: this.petSystem.state.effectiveInt,
effectiveDex: this.petSystem.state.effectiveDex,
effectiveLuck: this.petSystem.state.effectiveLuck
})
}
return {
success: true,
result,

View File

@ -37,7 +37,10 @@ export const DEITIES = [
'要好好照顧寵物啊',
'心誠則靈,媽祖會守護你的'
],
icon: 'deity-mazu'
icon: 'deity-mazu',
// 可求的簽詩類型
lotTypes: ['guanyin_100'] // 觀音100籤
},
{
id: 'earthgod',
@ -72,7 +75,9 @@ export const DEITIES = [
'好好照顧寵物,會有福報的',
'心善之人,必有善報'
],
icon: 'deity-earthgod'
icon: 'deity-earthgod',
lotTypes: ['guanyin_100'] // 暫用觀音100籤
},
{
id: 'yuelao',
@ -103,11 +108,13 @@ export const DEITIES = [
},
dialogues: [
'有緣千里來相會',
'好好對待寵物,感情會更深厚',
'愛心滿滿,幸福滿滿'
'月老牽線,姻緣天定',
'好姻緣需要緣份',
'真心相待,自有佳偶'
],
icon: 'deity-yuelao'
icon: 'deity-yuelao',
lotTypes: ['guanyin_100'] // 暫用觀音100籤
},
{
id: 'wenchang',
@ -138,11 +145,13 @@ export const DEITIES = [
},
dialogues: [
'勤學不,智慧增長',
'勤學不,智慧增長',
'好好學習,寵物也會變聰明',
'知識就是力量'
],
icon: 'deity-wenchang'
icon: 'deity-wenchang',
lotTypes: ['guanyin_100'] // 暫用觀音100籤
},
{
id: 'guanyin',
@ -175,9 +184,10 @@ export const DEITIES = [
dialogues: [
'慈悲為懷,萬物皆靈',
'好好照顧,觀音會保佑',
'心善之人,處處有福'
'心存善念,受佛保佑'
],
icon: 'deity-guanyin'
icon: 'deity-guanyin',
lotTypes: ['guanyin_100'] // 觀音100籤
}
]

1202
data/guanyin_100_lots.json Normal file

File diff suppressed because it is too large Load Diff