|
@@ -13,7 +13,13 @@
|
|
|
<template v-if="index === history.length - 1 && item.choices.length">
|
|
<template v-if="index === history.length - 1 && item.choices.length">
|
|
|
<br /><br />
|
|
<br /><br />
|
|
|
<el-radio-group v-model="choice" class="ml-4">
|
|
<el-radio-group v-model="choice" class="ml-4">
|
|
|
- <el-radio v-for="c in item.choices" :key="c" :label="c" class="w-full"> </el-radio>
|
|
|
|
|
|
|
+ <el-radio
|
|
|
|
|
+ v-for="c in item.choices"
|
|
|
|
|
+ :key="c"
|
|
|
|
|
+ :label="c"
|
|
|
|
|
+ class="w-full !h-auto !whitespace-normal mb-4"
|
|
|
|
|
+ >
|
|
|
|
|
+ </el-radio>
|
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-if="index === history.length - 1">
|
|
<template v-if="index === history.length - 1">
|
|
@@ -25,8 +31,9 @@
|
|
|
<div class="text-center">
|
|
<div class="text-center">
|
|
|
<ElButtonGroup v-if="game.status === 'PLAYING'">
|
|
<ElButtonGroup v-if="game.status === 'PLAYING'">
|
|
|
<ElButton :loading="loading" @click="continueGame(false)">继续</ElButton>
|
|
<ElButton :loading="loading" @click="continueGame(false)">继续</ElButton>
|
|
|
|
|
+ <ElButton :loading="loading" @click="onAddCharactor(false)">加入角色继续</ElButton>
|
|
|
<ElButton :loading="loading" @click="continueGame(true)">生成选择</ElButton>
|
|
<ElButton :loading="loading" @click="continueGame(true)">生成选择</ElButton>
|
|
|
- <ElButton :loading="loading" @click="onAddCharactor">加入角色</ElButton>
|
|
|
|
|
|
|
+ <ElButton :loading="loading" @click="onAddCharactor(true)">加入角色生成选择</ElButton>
|
|
|
<ElButton :loading="loading" @click="revert">回退</ElButton>
|
|
<ElButton :loading="loading" @click="revert">回退</ElButton>
|
|
|
</ElButtonGroup>
|
|
</ElButtonGroup>
|
|
|
<ElButton v-else @click="start" :loading="loading">开始</ElButton>
|
|
<ElButton v-else @click="start" :loading="loading">开始</ElButton>
|
|
@@ -76,14 +83,18 @@ async function start() {
|
|
|
getData()
|
|
getData()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function continueGame(genChoice = false) {
|
|
|
|
|
|
|
+async function continueGame(genChoice = false, addCharactor = null) {
|
|
|
if (needChoice.value && !choice.value) {
|
|
if (needChoice.value && !choice.value) {
|
|
|
ElMessage.info('请选择一个选项')
|
|
ElMessage.info('请选择一个选项')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
try {
|
|
try {
|
|
|
- await http.post(`/game/${route.params.id}/continue`, { genChoice: genChoice, choice: choice.value })
|
|
|
|
|
|
|
+ await http.post(`/game/${route.params.id}/continue`, {
|
|
|
|
|
+ genChoice: genChoice,
|
|
|
|
|
+ choice: choice.value,
|
|
|
|
|
+ addCharactor
|
|
|
|
|
+ })
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
getData()
|
|
getData()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -99,18 +110,12 @@ async function revert() {
|
|
|
getData()
|
|
getData()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function onAddCharactor() {
|
|
|
|
|
|
|
+async function onAddCharactor(genChoice = false) {
|
|
|
const { value } = await ElMessageBox.prompt('基本信息:', '添加角色', {
|
|
const { value } = await ElMessageBox.prompt('基本信息:', '添加角色', {
|
|
|
inputPattern: /^.+$/,
|
|
inputPattern: /^.+$/,
|
|
|
inputErrorMessage: '请输入基本信息'
|
|
inputErrorMessage: '请输入基本信息'
|
|
|
})
|
|
})
|
|
|
- try {
|
|
|
|
|
- await http.post(`/game/${route.params.id}/addCharactor`, {
|
|
|
|
|
- base: value
|
|
|
|
|
- })
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- ElMessage.error(error.message)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ continueGame(genChoice, value)
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
<style lang="less" scoped></style>
|
|
<style lang="less" scoped></style>
|