forked from public/foundryvtt-reve-de-dragon
Roll V2: cuisine
This commit is contained in:
@@ -43,6 +43,7 @@ import { renderTemplate } from "../constants.js";
|
||||
import { RollTypeCuisine } from "./roll-type-cuisine.mjs";
|
||||
import { RollPartCuisine } from "./roll-part-cuisine.mjs";
|
||||
import { OptionsAvancees, ROLL_DIALOG_V2_TEST } from "../settings/options-avancees.js";
|
||||
import { ActorImpacts } from "../technical/actor-impacts.mjs";
|
||||
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
|
||||
@@ -292,7 +293,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
return rollData
|
||||
}
|
||||
|
||||
static saveParts(rollData) {
|
||||
static saveParts(rollData, impacts) {
|
||||
const target = RollBasicParts.initFrom(rollData)
|
||||
ROLL_PARTS.filter(p => p.isActive(rollData))
|
||||
.forEach(p => p.storeClean(rollData, target))
|
||||
@@ -301,6 +302,12 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
target.result = rollData.result
|
||||
target.done = rollData.done ?? {}
|
||||
target.dmg = rollData.dmg
|
||||
if (impacts) {
|
||||
target.reverse = {
|
||||
active: impacts.active?.reverseImpacts(),
|
||||
opponent: impacts.opponent?.reverseImpacts()
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
@@ -442,18 +449,29 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
roll.current.resultat = this.rollData.current[PART_TRICHER]?.resultat ?? -1
|
||||
roll.choix = {}
|
||||
roll.rolled = await RollDialogAdapter.rollDice(roll, this.rollTitle(roll))
|
||||
roll.result = selectedRollType.getResult(roll)
|
||||
|
||||
|
||||
const impacts = {
|
||||
active: new ActorImpacts(roll.active),
|
||||
opponent: roll.opponent ? new ActorImpacts(roll.opponent) : undefined
|
||||
}
|
||||
|
||||
roll.result = selectedRollType.getResult(roll, impacts)
|
||||
|
||||
console.info('RollDialog.roll:', roll)
|
||||
const callbacks = [
|
||||
...this.rollOptions.callbacks,
|
||||
...selectedRollType.callbacks(this.rollOptions),
|
||||
]
|
||||
|
||||
await Promise.all(callbacks.map(async callback => await callback(roll)))
|
||||
await this.chatRollResult.display(roll)
|
||||
|
||||
await impacts.active?.applyImpacts()
|
||||
await impacts.opponent?.applyImpacts()
|
||||
selectedRollType.onApplyImpacts(roll, impacts)
|
||||
await this.chatRollResult.display(roll, impacts)
|
||||
this.rollOptions.onRollDone(this)
|
||||
}
|
||||
|
||||
|
||||
loadRollData(roll) {
|
||||
RollDialog.$prepareRollData(roll)
|
||||
RollDialog.calculAjustements(roll)
|
||||
|
Reference in New Issue
Block a user