RollV2, tchat et appel chance
gestion des appels à la chance pour tout jet V2 correction de soucis forçage du jet continuation des messages de défense
This commit is contained in:
@@ -25,7 +25,7 @@ import { RollPartMeditation } from "./roll-part-meditation.mjs";
|
||||
import { RollPartMoral } from "./roll-part-moral.mjs";
|
||||
import { RollPartOpponent } from "./roll-part-opponent.mjs";
|
||||
import { RollPartSurEnc } from "./roll-part-surenc.mjs";
|
||||
import { RollPartTricher } from "./roll-part-tricher.mjs";
|
||||
import { PART_TRICHER, RollPartTricher } from "./roll-part-tricher.mjs";
|
||||
import { RollPartTache } from "./roll-part-tache.mjs";
|
||||
import { RollPartOeuvre } from "./roll-part-oeuvre.mjs";
|
||||
import { RollPartSort } from "./roll-part-sort.mjs";
|
||||
@@ -38,7 +38,7 @@ import { RollPartDefense } from "./roll-part-defense.mjs";
|
||||
import { RollDialogAdapter } from "./roll-dialog-adapter.mjs";
|
||||
import { ROLLDIALOG_SECTION } from "./roll-part.mjs";
|
||||
import { ROLL_TYPE_COMP } from "./roll-constants.mjs";
|
||||
import { ChatRollResult } from "./chat-roll-result.mjs";
|
||||
import ChatRollResult from "./chat-roll-result.mjs";
|
||||
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
|
||||
@@ -286,6 +286,8 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
ROLL_PARTS.filter(p => p.isActive(rollData))
|
||||
.forEach(p => p.storeClean(rollData, target))
|
||||
target.attackerRoll = rollData.attackerRoll
|
||||
target.rolled = rollData.rolled
|
||||
target.result = rollData.result
|
||||
return target
|
||||
}
|
||||
|
||||
@@ -317,8 +319,8 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
}
|
||||
|
||||
|
||||
getActiveParts() {
|
||||
return ROLL_PARTS.filter(p => p.isActive(this.rollData))
|
||||
static getActiveParts(rollData) {
|
||||
return ROLL_PARTS.filter(p => p.isActive(rollData))
|
||||
}
|
||||
|
||||
// get title() {
|
||||
@@ -353,12 +355,12 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
))
|
||||
|
||||
Promise.all(
|
||||
this.getActiveParts().map(async p => await p._onRender(this, context, options))
|
||||
RollDialog.getActiveParts(this.rollData).map(async p => await p._onRender(this, context, options))
|
||||
)
|
||||
}
|
||||
|
||||
getAjustements(rollData = this.rollData) {
|
||||
return this.getActiveParts()
|
||||
static getAjustements(rollData) {
|
||||
return RollDialog.getActiveParts(rollData)
|
||||
.map(p => p.getAjustements(rollData))
|
||||
.reduce((a, b) => a.concat(b))
|
||||
.sort((a, b) => a.diff == undefined ? 1 : b.diff == undefined ? -1 : 0)
|
||||
@@ -373,19 +375,19 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
|
||||
const types = ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData))
|
||||
.map(m => m.toTypeData(rollData))
|
||||
BASIC_PARTS.loadSurprises(this.rollData, this.getSelectedType().code)
|
||||
this.rollData.type.label = this.getSelectedType()?.title(this.rollData)
|
||||
BASIC_PARTS.loadSurprises(rollData, this.getSelectedType().code)
|
||||
rollData.type.label = this.getSelectedType()?.title(rollData)
|
||||
//TOCHECK: set type.label ?
|
||||
const visibleRollParts = this.getActiveParts()
|
||||
const visibleRollParts = RollDialog.getActiveParts(rollData)
|
||||
visibleRollParts.forEach(p => p.applyExternalImpacts(visibleRollParts, rollData))
|
||||
|
||||
this.setSpecialComp(visibleRollParts);
|
||||
|
||||
visibleRollParts.forEach(p => p.prepareContext(rollData))
|
||||
|
||||
this.calculAjustements()
|
||||
RollDialog.calculAjustements(rollData)
|
||||
|
||||
const templates = this.getActiveParts().map(p => p.toTemplateData())
|
||||
const templates = RollDialog.getActiveParts(rollData).map(p => p.toTemplateData())
|
||||
const context = await super._prepareContext()
|
||||
return foundry.utils.mergeObject(
|
||||
{
|
||||
@@ -399,14 +401,14 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
const specialComp = visibleRollParts.map(p => p.getSpecialComp(this.rollData))
|
||||
.reduce((a, b) => a.concat(b))
|
||||
if (specialComp.length > 0) {
|
||||
const rollPartComp = this.getActiveParts()
|
||||
const rollPartComp = RollDialog.getActiveParts(this.rollData)
|
||||
.find(it => it.code == PART_COMP);
|
||||
rollPartComp?.setSpecialComp(this.rollData, specialComp)
|
||||
}
|
||||
}
|
||||
|
||||
calculAjustements(rollData = this.rollData) {
|
||||
rollData.ajustements = this.getAjustements(rollData)
|
||||
static calculAjustements(rollData) {
|
||||
rollData.ajustements = RollDialog.getAjustements(rollData)
|
||||
rollData.ajustements.forEach(it => it.isDiff = it.diff != undefined)
|
||||
rollData.current.totaldiff = rollData.ajustements
|
||||
.map(adj => adj.diff)
|
||||
@@ -419,12 +421,12 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
}
|
||||
|
||||
async roll() {
|
||||
// ROLL_PARTS.filter(p => p.isActive(this.rollData))
|
||||
// .forEach(p => p.validate(this.rollData))
|
||||
|
||||
const roll = RollDialog.saveParts(this.rollData)
|
||||
RollDialog.$prepareRollData(roll)
|
||||
this.calculAjustements(roll)
|
||||
roll.current.resultat = this.rollData.current.resultat
|
||||
roll.v2 = true
|
||||
RollDialog.loadRollData(roll)
|
||||
roll.current.resultat = this.rollData.current[PART_TRICHER]?.resultat ?? -1
|
||||
roll.rolled = await this.$rollDice(roll)
|
||||
roll.result = this.getSelectedType(roll).getResult(roll)
|
||||
console.info('RollDialog.roll:', roll)
|
||||
@@ -434,12 +436,18 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
this.rollOptions.onRollDone(this)
|
||||
}
|
||||
|
||||
static loadRollData(roll) {
|
||||
RollDialog.$prepareRollData(roll)
|
||||
RollDialog.calculAjustements(roll)
|
||||
roll.v2 = true
|
||||
}
|
||||
|
||||
async defaultCallback(rollData, rolled) {
|
||||
await rollData.active.actor.appliquerAjoutExperience(rollData)
|
||||
await rollData.active.actor.appliquerAppelMoral(rollData)
|
||||
}
|
||||
|
||||
async $rollDice(rollData) {
|
||||
return await RollDialogAdapter.rollDice(rollData, this.rollTitle(rollData));
|
||||
return await RollDialogAdapter.rollDice(rollData, this.rollTitle(rollData))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user