fixes some glitches in display logic and also enables rolling the regeneration dice, closes the dialog afterwards.
parent
9e0e85efe6
commit
c342d8d366
|
|
@ -20,7 +20,9 @@ export class RestingDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
closeOnSubmit: false,
|
||||
handler: RestingDialog.#onSubmitForm
|
||||
},
|
||||
actions: {}
|
||||
actions: {
|
||||
regenerate: RestingDialog.#regenerate
|
||||
}
|
||||
}
|
||||
|
||||
static PARTS = {
|
||||
|
|
@ -159,11 +161,47 @@ export class RestingDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
this.watch = false
|
||||
this.interrupted = false
|
||||
|
||||
this.lepModifier = this._actor.system.regeneration.lep.split("d6")[1]
|
||||
this.aspModifier = this._actor.system.regeneration.asp.split("d6")[1]
|
||||
|
||||
|
||||
this.regKoMod = this._actor.system.regeneration.ko
|
||||
this.regInMod = this._actor.system.regeneration.in
|
||||
|
||||
|
||||
}
|
||||
|
||||
static async #regenerate() {
|
||||
const context = this.#updateData()
|
||||
const rollData = this._actor.getRollData()
|
||||
|
||||
// regenerate LeP
|
||||
|
||||
const targetBonusLep = rollData.attribute.ko.aktuell + context.koRoll
|
||||
const targetBonusAsp = rollData.attribute.in.aktuell + context.inRoll
|
||||
|
||||
const regenerationRoll = await new Roll("1d20[Konstitution]+1d20[Intuition]+1d20[Konstitution] + 2d6").evaluate()
|
||||
|
||||
const [koRoll, _, inRoll, __, woundRoll, ___, lepAndAsp] = regenerationRoll.terms // the 3d20s
|
||||
const plusLep = koRoll.results[0].result <= targetBonusLep ? 1 : 0
|
||||
const plusAsp = inRoll.results[0].result <= targetBonusAsp ? 1 : 0
|
||||
const woundHealed = woundRoll.results[0].result <= rollData.attribute.ko.aktuell + (context.woundMod * -1)
|
||||
const [regLep, regAsp] = lepAndAsp.results // the 2d6s
|
||||
|
||||
await regenerationRoll.toMessage({
|
||||
speaker: ChatMessage.getSpeaker({actor: this.actor}),
|
||||
flavor:
|
||||
`Regeneration in der Nacht:<br/>
|
||||
LE: ${regLep.result} ${context.lepMod > 0 ? ("+" + context.lepMod) : ""} ${plusLep > 0 ? "+1" : ""}<br/>
|
||||
AE: ${regAsp.result} ${context.aspMod > 0 ? ("+" + context.aspMod) : ""} ${plusAsp > 0 ? "+1" : ""}<br/>
|
||||
Wunde: ${woundHealed ? "geheilt" : "nicht geheilt"}`,
|
||||
rollMode: game.settings.get('core', 'rollMode'),
|
||||
})
|
||||
this.close()
|
||||
}
|
||||
|
||||
static async #onSubmitForm(event, form, formData) {
|
||||
event.preventDefault()
|
||||
console.log(formData)
|
||||
this.restDuration = formData.object.length
|
||||
this.restingType = formData.object.type
|
||||
this.badWeather = formData.object.bad_weather
|
||||
|
|
@ -182,11 +220,11 @@ export class RestingDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
const elementWoundMod = this.element.querySelector('output[name="woundMod"]')
|
||||
|
||||
const context = this.#updateData()
|
||||
elementLepMod.value = context.lepMod
|
||||
elementKoMod.value = context.koRoll
|
||||
elementAspMod.value = context.aspMod
|
||||
elementInMod.value = context.inRoll
|
||||
elementWoundMod.value = context.woundMod
|
||||
elementLepMod.value = context.lepModDisplay
|
||||
elementKoMod.value = context.koRollDisplay
|
||||
elementAspMod.value = context.aspModDisplay
|
||||
elementInMod.value = context.inRollDisplay
|
||||
elementWoundMod.value = context.woundModDisplay
|
||||
}
|
||||
|
||||
#updateData(context = {}) {
|
||||
|
|
@ -225,10 +263,12 @@ export class RestingDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
}
|
||||
|
||||
if (this.woundTreated) {
|
||||
context.woundMod = `1w20-${this.woundRegenerationModifier ?? 0}`
|
||||
context.woundModDisplay = `1w20-${this.woundRegenerationModifier ?? 0}`
|
||||
context.woundMod = this.woundRegenerationModifier ?? 0
|
||||
} else {
|
||||
if (context.hasWounds) {
|
||||
context.woundMod = `1w20+${context.wounds * 3}`
|
||||
context.woundModDisplay = `1w20+${context.wounds * 3}`
|
||||
context.woundMod = context.wounds * 3
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -256,38 +296,41 @@ export class RestingDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
}
|
||||
}
|
||||
|
||||
const [lepDieAmount, lepModifier] = this._actor.system.regeneration.lep.split("d6")
|
||||
const [aspDieAmount, aspModifier] = this._actor.system.regeneration.asp.split("d6")
|
||||
const lepMod = (Number(this.lepModifier) + (lepRestModifier)) ?? 0
|
||||
const aspMod = (Number(this.aspModifier) + (aspRestModifier)) ?? 0
|
||||
|
||||
const lepMod = (Number(lepModifier) + (lepRestModifier ?? ""))
|
||||
const aspMod = (Number(aspModifier) + (aspRestModifier ?? ""))
|
||||
context.lepMod = lepMod
|
||||
|
||||
if (lepMod == 0) {
|
||||
context.lepMod = lepDieAmount + "d6"
|
||||
context.lepModDisplay = "1w6"
|
||||
} else if (lepMod > 0) {
|
||||
context.lepMod = lepDieAmount + "d6+" + lepMod
|
||||
context.lepModDisplay = "1w6+" + lepMod
|
||||
} else {
|
||||
context.lepMod = lepDieAmount + "d6" + lepMod
|
||||
context.lepModDisplay = "1w6" + lepMod
|
||||
}
|
||||
|
||||
context.aspMod = aspMod
|
||||
if (aspMod == 0) {
|
||||
context.aspMod = aspDieAmount + "d6"
|
||||
context.aspModDisplay = "1w6"
|
||||
} else if (lepMod > 0) {
|
||||
context.aspMod = aspDieAmount + "d6+" + aspMod
|
||||
context.aspModDisplay = "1w6+" + aspMod
|
||||
} else {
|
||||
context.aspMod = aspDieAmount + "d6" + aspMod
|
||||
context.aspModDisplay = "1w6" + aspMod
|
||||
|
||||
}
|
||||
|
||||
if (this._actor.system.regeneration.ko < 0) {
|
||||
context.koRoll = `1w20${this._actor.system.regeneration.ko}`
|
||||
context.koRoll = this.regKoMod
|
||||
if (this.regKoMod < 0) {
|
||||
context.koRollDisplay = `1w20${this.regKoMod}`
|
||||
} else {
|
||||
context.koRoll = `1w20+${this._actor.system.regeneration.ko}`
|
||||
context.koRollDisplay = `1w20+${this.regKoMod}`
|
||||
}
|
||||
|
||||
if (this._actor.system.regeneration.in < 0) {
|
||||
context.inRoll = `1w20${this._actor.system.regeneration.in}`
|
||||
context.inRoll = this.regInMod
|
||||
if (this.regInMod < 0) {
|
||||
context.inRollDisplay = `1w20${this.regInMod}`
|
||||
} else {
|
||||
context.inRoll = `1w20+${this._actor.system.regeneration.in}`
|
||||
context.inRollDisplay = `1w20+${this.regInMod}`
|
||||
}
|
||||
|
||||
console.log(this, context)
|
||||
|
|
|
|||
|
|
@ -53,23 +53,23 @@
|
|||
<legend>Modifikatoren</legend>
|
||||
<div class="results">
|
||||
<span data-tooltip="{{fieldTooltip 'regeneration.lep' actorId}}">LeP-Regeneration</span>
|
||||
<output name="lepMod">{{lepMod}}</output>
|
||||
<output name="lepMod">{{lepModDisplay}}</output>
|
||||
<span data-tooltip="{{fieldTooltip 'regeneration.ko' actorId}}">KO Wurf</span>
|
||||
<output name="koMod">{{koRoll}}</output>
|
||||
<output name="koMod">{{koRollDisplay}}</output>
|
||||
|
||||
{{#if hasAsP}}
|
||||
<span data-tooltip="{{fieldTooltip 'regeneration.asp' actorId}}">AsP-Regeneration</span>
|
||||
<output name="aspMod">{{aspMod}}</output>
|
||||
<output name="aspMod">{{aspModDisplay}}</output>
|
||||
<span data-tooltip="{{fieldTooltip 'regeneration.in' actorId}}">IN Wurf</span>
|
||||
<output name="inMod">{{inRoll}}</output>
|
||||
<output name="inMod">{{inRollDisplay}}</output>
|
||||
|
||||
{{/if}}
|
||||
{{#if hasWounds}}
|
||||
<span>Wunden-Heilung</span>
|
||||
<output name="woundMod">{{woundMod}}</output>
|
||||
<output name="woundMod">{{woundModDisplay}}</output>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
<button class="actions"><i class="fa-solid fa-bed"></i> Regenerieren</button>
|
||||
<button class="actions" data-action="regenerate"><i class="fa-solid fa-bed"></i> Regenerieren</button>
|
||||
</section>
|
||||
Loading…
Reference in New Issue