feat:merge health
This commit is contained in:
parent
9b1d27186d
commit
9dcae956dc
File diff suppressed because it is too large
Load Diff
101
app/app.vue
101
app/app.vue
|
|
@ -242,7 +242,8 @@
|
||||||
<h3>[PRAY] 神明系統</h3>
|
<h3>[PRAY] 神明系統</h3>
|
||||||
<div class="button-grid">
|
<div class="button-grid">
|
||||||
<button @click="handlePray" :disabled="!isReady">[PRAY] 祈福</button>
|
<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="handleThrowJiaobei" :disabled="!isReady">[JIAOBEI] 擲筊</button>
|
||||||
<button @click="handleListDeities" :disabled="!isReady">[LIST] 神明列表</button>
|
<button @click="handleListDeities" :disabled="!isReady">[LIST] 神明列表</button>
|
||||||
</div>
|
</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) {
|
async function switchDeity(deityId) {
|
||||||
const result = await templeSystem.switchDeity(deityId)
|
const result = await templeSystem.switchDeity(deityId)
|
||||||
|
|
@ -911,6 +893,82 @@ async function handleThrowJiaobei() {
|
||||||
showStatus()
|
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() {
|
function listDeities() {
|
||||||
const deities = templeSystem.getDeities()
|
const deities = templeSystem.getDeities()
|
||||||
|
|
@ -1059,9 +1117,6 @@ async function handlePray() {
|
||||||
updatePetState()
|
updatePetState()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDrawFortune() {
|
|
||||||
await drawFortune()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleListDeities() {
|
function handleListDeities() {
|
||||||
listDeities()
|
listDeities()
|
||||||
|
|
|
||||||
|
|
@ -130,26 +130,37 @@ export class TempleSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 抽籤
|
// 抽籤
|
||||||
async drawFortune() {
|
|
||||||
try {
|
|
||||||
const result = await this.api.drawFortune()
|
|
||||||
|
|
||||||
// 根據籤詩等級應用效果
|
// 求籤(需要三聖筊驗證)
|
||||||
const { FORTUNE_LOTS } = await import('../data/fortune-lots.js')
|
async drawLot(lotType = 'guanyin_100') {
|
||||||
const lot = FORTUNE_LOTS.find(l => l.grade === result.lot.grade) || FORTUNE_LOTS[0]
|
const state = this.petSystem.getState()
|
||||||
|
const deity = this.getCurrentDeity()
|
||||||
|
|
||||||
if (lot.effects?.addBuff) {
|
// 檢查神明是否支持此簽詩
|
||||||
// 應用 Buff(需要透過 eventSystem)
|
if (!deity.lotTypes || !deity.lotTypes.includes(lotType)) {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: false,
|
||||||
lot: result.lot,
|
message: `${deity.name}不提供${lotType}簽詩`
|
||||||
buff: lot.effects.addBuff
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 載入簽詩資料
|
||||||
|
const lots = await this.loadLots(lotType)
|
||||||
|
|
||||||
|
// 隨機抽一支簽
|
||||||
|
const randomIndex = Math.floor(Math.random() * lots.length)
|
||||||
|
const lot = lots[randomIndex]
|
||||||
|
|
||||||
|
// 返回需要擲筊驗證的狀態
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
lot: result.lot
|
needVerification: true,
|
||||||
|
lot,
|
||||||
|
lotType,
|
||||||
|
deity: deity.name,
|
||||||
|
verificationCount: 0,
|
||||||
|
requiredHoly: 3 // 需要三個聖筊
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[TempleSystem] 抽籤失敗:', 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 = '') {
|
async throwJiaobei(question = '') {
|
||||||
const state = this.petSystem.getState()
|
const state = this.petSystem.getState()
|
||||||
|
|
@ -190,31 +253,6 @@ export class TempleSystem {
|
||||||
const messages = JIAOBEI_CONFIG.messages[result]
|
const messages = JIAOBEI_CONFIG.messages[result]
|
||||||
const message = messages[Math.floor(Math.random() * messages.length)]
|
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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
result,
|
result,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,10 @@ export const DEITIES = [
|
||||||
'要好好照顧寵物啊',
|
'要好好照顧寵物啊',
|
||||||
'心誠則靈,媽祖會守護你的'
|
'心誠則靈,媽祖會守護你的'
|
||||||
],
|
],
|
||||||
icon: 'deity-mazu'
|
icon: 'deity-mazu',
|
||||||
|
|
||||||
|
// 可求的簽詩類型
|
||||||
|
lotTypes: ['guanyin_100'] // 觀音100籤
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'earthgod',
|
id: 'earthgod',
|
||||||
|
|
@ -72,7 +75,9 @@ export const DEITIES = [
|
||||||
'好好照顧寵物,會有福報的',
|
'好好照顧寵物,會有福報的',
|
||||||
'心善之人,必有善報'
|
'心善之人,必有善報'
|
||||||
],
|
],
|
||||||
icon: 'deity-earthgod'
|
icon: 'deity-earthgod',
|
||||||
|
|
||||||
|
lotTypes: ['guanyin_100'] // 暫用觀音100籤
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'yuelao',
|
id: 'yuelao',
|
||||||
|
|
@ -103,11 +108,13 @@ export const DEITIES = [
|
||||||
},
|
},
|
||||||
|
|
||||||
dialogues: [
|
dialogues: [
|
||||||
'有緣千里來相會',
|
'月老牽線,姻緣天定',
|
||||||
'好好對待寵物,感情會更深厚',
|
'好姻緣需要緣份',
|
||||||
'愛心滿滿,幸福滿滿'
|
'真心相待,自有佳偶'
|
||||||
],
|
],
|
||||||
icon: 'deity-yuelao'
|
icon: 'deity-yuelao',
|
||||||
|
|
||||||
|
lotTypes: ['guanyin_100'] // 暫用觀音100籤
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'wenchang',
|
id: 'wenchang',
|
||||||
|
|
@ -138,11 +145,13 @@ export const DEITIES = [
|
||||||
},
|
},
|
||||||
|
|
||||||
dialogues: [
|
dialogues: [
|
||||||
'勤學不輟,智慧增長',
|
'勤學不辟,智慧增長',
|
||||||
'好好學習,寵物也會變聰明',
|
'好好學習,寵物也會變聰明',
|
||||||
'知識就是力量'
|
'知識就是力量'
|
||||||
],
|
],
|
||||||
icon: 'deity-wenchang'
|
icon: 'deity-wenchang',
|
||||||
|
|
||||||
|
lotTypes: ['guanyin_100'] // 暫用觀音100籤
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'guanyin',
|
id: 'guanyin',
|
||||||
|
|
@ -175,9 +184,10 @@ export const DEITIES = [
|
||||||
dialogues: [
|
dialogues: [
|
||||||
'慈悲為懷,萬物皆靈',
|
'慈悲為懷,萬物皆靈',
|
||||||
'好好照顧,觀音會保佑',
|
'好好照顧,觀音會保佑',
|
||||||
'心善之人,處處有福'
|
'心存善念,受佛保佑'
|
||||||
],
|
],
|
||||||
icon: 'deity-guanyin'
|
icon: 'deity-guanyin',
|
||||||
|
|
||||||
|
lotTypes: ['guanyin_100'] // 觀音100籤
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue