Skip to content

Commit

Permalink
Merge pull request #1024 from ben/truths-output
Browse files Browse the repository at this point in the history
Fix truths dialog
  • Loading branch information
ben authored Aug 30, 2024
2 parents c55e95b + cdcc3c4 commit 3c07fd6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Avoided doing a full load of moves when showing the move sheet, resulting in better performance ([#1023](https://github.com/ben/foundry-ironsworn/pull/1023))
- Brought back support for the "Custom Moves" folder (also [#1023](https://github.com/ben/foundry-ironsworn/pull/1023))
- First-start dialog: prevent a situation where an expansion is enabled but not the ruleset it builds on (you shouldn't be able to enable Delve without Ironsworn)
- Truths dialog: fix some bugs around randomization, journal output, and closing it when done ([#1024](https://github.com/ben/foundry-ironsworn/pull/1024))

## 1.24.0

Expand Down
1 change: 1 addition & 0 deletions src/module/journal/journal-entry-page-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface ClockDataProperties {
/// ///////// SETTING TRUTH OPTION
export interface TruthOptionDataSourceData extends DFISettingTruthOption {
dfid: string
dsid?: string
Summary: string
Quest: string
}
Expand Down
6 changes: 3 additions & 3 deletions src/module/vue/components/truth/truth-category.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
:key="`truthPage${i}`"
ref="selectables"
:page="page"
:radio-group="dfid"
:radio-group="dsid"
@change="valueChange"
/>

<CustomTruth
ref="customTruth"
:radio-group="dfid"
:radio-group="dsid"
@change="customValueChange"
/>

Expand Down Expand Up @@ -51,7 +51,7 @@ const nonTruthPages = props
.je()
?.pages.filter((p) => p.type !== 'truth') as NonTruthPage[]
const dfid = props.je().getFlag('foundry-ironsworn', 'dfid') as string
const dsid = props.je().getFlag('foundry-ironsworn', 'dsid') as string
const state = reactive<{
title?: string
Expand Down
26 changes: 14 additions & 12 deletions src/module/vue/components/truth/truth-selectable.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<label class="nogrow flexrow">
<input
ref="topRadio"
:checked="selected"
type="radio"
class="nogrow"
:name="radioGroup"
Expand All @@ -28,7 +28,7 @@
ref="suboptions"
type="radio"
class="nogrow"
:name="pageSystem.dfid"
:name="pageSystem.dsid"
@change="subtableSelect(entry)"
/>
<p v-html="entry.text" />
Expand All @@ -48,7 +48,7 @@
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue'
import { ref } from 'vue'
import type { IronswornJournalPage } from '../../../journal/journal-entry-page'
import type { TruthOptionDataPropertiesData } from '../../../journal/journal-entry-page-types'
import { OracleTableResult } from '../../../roll-table/oracle-table-result'
Expand All @@ -60,25 +60,27 @@ const props = defineProps<{
}>()
const pageSystem = props.page.system as TruthOptionDataPropertiesData
const topRadio = ref<HTMLElement>()
const state = reactive({ suboption: undefined as string | undefined })
const selected = ref(false)
const suboption = ref<string | undefined>()
function subtableSelect(entry: OracleTableResult) {
state.suboption = entry.text
topRadio.value?.click()
suboption.value = entry.text
selected.value = true
emitValue()
}
const $emit = defineEmits<{
change: [string, string] // title, text
}>()
function emitValue() {
let text = `${pageSystem.Description} ${state.suboption ?? ''}\n\n_${
let text = `${pageSystem.Description} ${suboption ?? ''}\n\n_${
pageSystem.Quest
}_`
const template = pageSystem['Roll template']
if (state.suboption && template?.Description) {
if (suboption.value && template?.Description) {
text =
template.Description.replace(/\${{.*?}}/, state.suboption) +
template.Description.replace(/{{table>.*?}}/, `> ${suboption.value}`) +
`\n\n_${pageSystem.Quest}_`
}
$emit('change', props.page.name ?? '???', text.trim())
Expand All @@ -87,11 +89,11 @@ function emitValue() {
const suboptions = ref<HTMLElement[]>([])
async function selectAndRandomize() {
topRadio.value?.click()
selected.value = true
if (
props.page.subtable &&
((props.page.subtable?.results as any)?.length ?? 0) > 0
((props.page.subtable?.results as any)?.size ?? 0) > 0
) {
const { roll } = await props.page.subtable.draw()
Expand Down
3 changes: 2 additions & 1 deletion src/module/vue/vueapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function VueAppMixin<TBase extends Constructor<Application>>(
)
}

setupVueApp(app: App): void {
setupVueApp(_app: App): void {
// Implement in descendants if needed
}

Expand All @@ -47,6 +47,7 @@ export function VueAppMixin<TBase extends Constructor<Application>>(
// Create the Vue App instance
if (this.vueApp == null || this.vueRoot == null) {
const provides = pickBy(data, (v, k) => k.startsWith('$'))
this.localEmitter.on('closeApp', () => this.close())

this.vueRoot = undefined
this.vueApp = createApp({
Expand Down

0 comments on commit 3c07fd6

Please sign in to comment.