Méthode de fenêtre de jet partagée
This commit is contained in:
parent
ffccc819f1
commit
e470d76ea0
200
module/actor.js
200
module/actor.js
@ -332,34 +332,42 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async roll() {
|
async roll() {
|
||||||
const carac = mergeObject(
|
const carac = mergeObject(duplicate(this.system.carac),
|
||||||
duplicate(this.system.carac),
|
|
||||||
{
|
{
|
||||||
'reve-actuel': this.getCaracReveActuel(),
|
'reve-actuel': this.getCaracReveActuel(),
|
||||||
'chance-actuelle': this.getCaracChanceActuelle()
|
'chance-actuelle': this.getCaracChanceActuelle()
|
||||||
});
|
});
|
||||||
let rollData = {
|
|
||||||
|
await this._openRollDialog({
|
||||||
|
name: `jet-${this.id}`,
|
||||||
|
label: `Jet de ${this.name}`,
|
||||||
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll.html',
|
||||||
|
rollData: {
|
||||||
carac: carac,
|
carac: carac,
|
||||||
selectedCarac: carac.apparence,
|
selectedCarac: carac.apparence,
|
||||||
selectedCaracName: 'apparence',
|
selectedCaracName: 'apparence',
|
||||||
competences: this.itemTypes['competence']
|
competences: this.itemTypes['competence']
|
||||||
};
|
},
|
||||||
|
callbackAction: r => this.$onRollCaracResult(r)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async _openRollDialog({ name, label, template, rollData, callbackAction }) {
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
const dialog = await RdDRoll.create(this, rollData,
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll.html' },
|
{ html: template },
|
||||||
{
|
{
|
||||||
name: `jet-${this.id}`,
|
name: name,
|
||||||
label: `Jet de ${this.name}`,
|
label: label,
|
||||||
callbacks: [
|
callbacks: [
|
||||||
this.createCallbackExperience(),
|
this.createCallbackExperience(),
|
||||||
this.createCallbackAppelAuMoral(),
|
this.createCallbackAppelAuMoral(),
|
||||||
{ action: r => this._onRollCaracResult(r) }
|
{ action: callbackAction }
|
||||||
]
|
]
|
||||||
}
|
});
|
||||||
);
|
|
||||||
dialog.render(true);
|
dialog.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async prepareChateauDormant(consigne) {
|
async prepareChateauDormant(consigne) {
|
||||||
if (consigne.ignorer) {
|
if (consigne.ignorer) {
|
||||||
return;
|
return;
|
||||||
@ -2089,22 +2097,21 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
filterSortList(sortList, coord) {
|
$filterSortList(sortList, coord) {
|
||||||
let tmr = TMRUtility.getTMR(coord);
|
let tmr = TMRUtility.getTMR(coord);
|
||||||
let letfilteredList = []
|
let filtered = []
|
||||||
for (let sort of sortList) {
|
for (let sort of sortList) {
|
||||||
if (sort.system.caseTMR.toLowerCase().includes('variable')) {
|
if (sort.system.caseTMR.toLowerCase().includes('variable')) {
|
||||||
letfilteredList.push(sort);
|
filtered.push(sort);
|
||||||
} else if (sort.system.caseTMRspeciale.toLowerCase().includes('variable')) {
|
} else if (sort.system.caseTMRspeciale.toLowerCase().includes('variable')) {
|
||||||
letfilteredList.push(sort);
|
filtered.push(sort);
|
||||||
} else if (sort.system.caseTMR.toLowerCase() == tmr.type) {
|
} else if (sort.system.caseTMR.toLowerCase() == tmr.type) {
|
||||||
letfilteredList.push(sort);
|
filtered.push(sort);
|
||||||
} else if (sort.system.caseTMR.toLowerCase().includes('special') && sort.system.caseTMRspeciale.toLowerCase().includes(coord.toLowerCase())) {
|
} else if (sort.system.caseTMR.toLowerCase().includes('special') && sort.system.caseTMRspeciale.toLowerCase().includes(coord.toLowerCase())) {
|
||||||
letfilteredList.push(sort);
|
filtered.push(sort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return filtered;
|
||||||
return letfilteredList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -2136,52 +2143,39 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollUnSort(coord) {
|
async rollUnSort(coord) {
|
||||||
let sortList = duplicate(this.getSortList()); // Duplication car les pts de reve sont modifiés dans le sort
|
|
||||||
if (!sortList || sortList.length == 0) {
|
|
||||||
ui.notifications.info("Aucun sort disponible!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sortList = this.filterSortList(sortList, coord);
|
|
||||||
if (!sortList || sortList.length == 0) {
|
|
||||||
ui.notifications.info("Aucun sort disponible pour cette case !");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (EffetsDraconiques.isSortImpossible(this)) {
|
if (EffetsDraconiques.isSortImpossible(this)) {
|
||||||
ui.notifications.error("Une queue ou un souffle vous empèche de lancer de sort!");
|
ui.notifications.error("Une queue ou un souffle vous empèche de lancer de sort!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Duplication car les pts de reve sont modifiés dans le sort
|
||||||
|
let sorts = duplicate(this.$filterSortList(this.getSortList(), coord));
|
||||||
|
if (sorts.length == 0) {
|
||||||
|
ui.notifications.info(`Aucun sort disponible en ${TMRUtility.getTMR(coord).label} !`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.currentTMR) this.currentTMR.minimize(); // Hide
|
if (this.currentTMR) this.currentTMR.minimize(); // Hide
|
||||||
|
|
||||||
let draconicList = this.computeDraconicAndSortIndex(sortList);
|
const draconicList = this.computeDraconicAndSortIndex(sorts);
|
||||||
const reve = duplicate(this.system.carac.reve);
|
const reve = duplicate(this.system.carac.reve);
|
||||||
let rollData = {
|
|
||||||
|
await this._openRollDialog({
|
||||||
|
name: 'lancer-un-sort',
|
||||||
|
label: 'Lancer un sort',
|
||||||
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
|
||||||
|
rollData: {
|
||||||
carac: { 'reve': reve },
|
carac: { 'reve': reve },
|
||||||
forceCarac: { 'reve': reve },
|
forceCarac: { 'reve': reve },
|
||||||
selectedCarac: reve,
|
selectedCarac: reve,
|
||||||
draconicList: draconicList,
|
draconicList: draconicList,
|
||||||
competence: draconicList[0],
|
competence: draconicList[0],
|
||||||
sortList: sortList,
|
sortList: sorts,
|
||||||
selectedSort: sortList[0],
|
selectedSort: sorts[0],
|
||||||
tmr: TMRUtility.getTMR(coord),
|
tmr: TMRUtility.getTMR(coord),
|
||||||
diffLibre: RdDItemSort.getDifficulte(sortList[0], -7), // Per default at startup
|
diffLibre: RdDItemSort.getDifficulte(sorts[0], -7), // Per default at startup
|
||||||
coutreve: Array(30).fill().map((item, index) => 1 + index),
|
coutreve: Array(30).fill().map((item, index) => 1 + index),
|
||||||
}
|
|
||||||
|
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
|
||||||
{
|
|
||||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
|
|
||||||
close: html => { this.currentTMR.maximize() } // Re-display TMR
|
|
||||||
},
|
},
|
||||||
{
|
callbackAction: r => this._rollUnSortResult(r)
|
||||||
name: 'lancer-un-sort',
|
});
|
||||||
label: 'Lancer un sort',
|
|
||||||
callbacks: [
|
|
||||||
this.createCallbackExperience(),
|
|
||||||
{ action: r => this._rollUnSortResult(r) }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
);
|
|
||||||
dialog.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -2288,29 +2282,21 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCarac(caracName, jetResistance = undefined) {
|
async rollCarac(caracName, jetResistance = undefined) {
|
||||||
let rollData = {
|
await this._openRollDialog({
|
||||||
|
name: 'jet-' + caracName,
|
||||||
|
label: 'Jet ' + Grammar.apostrophe('de', rollData.selectedCarac.label),
|
||||||
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||||
|
rollData: {
|
||||||
selectedCarac: this.getCaracByName(caracName),
|
selectedCarac: this.getCaracByName(caracName),
|
||||||
competences: this.itemTypes['competence'],
|
competences: this.itemTypes['competence'],
|
||||||
jetResistance: jetResistance ? caracName : undefined
|
jetResistance: jetResistance ? caracName : undefined
|
||||||
};
|
},
|
||||||
|
callbackAction: r => this.$onRollCaracResult(r)
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
});
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
|
|
||||||
{
|
|
||||||
name: 'jet-' + caracName,
|
|
||||||
label: 'Jet ' + Grammar.apostrophe('de', rollData.selectedCarac.label),
|
|
||||||
callbacks: [
|
|
||||||
this.createCallbackExperience(),
|
|
||||||
this.createCallbackAppelAuMoral(),
|
|
||||||
{ action: r => this._onRollCaracResult(r) }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
);
|
|
||||||
dialog.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onRollCaracResult(rollData) {
|
async $onRollCaracResult(rollData) {
|
||||||
// Final chat message
|
// Final chat message
|
||||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html');
|
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html');
|
||||||
}
|
}
|
||||||
@ -2374,19 +2360,14 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
// Transformer la competence de créature
|
// Transformer la competence de créature
|
||||||
RdDItemCompetenceCreature.setRollDataCreature(rollData)
|
RdDItemCompetenceCreature.setRollDataCreature(rollData)
|
||||||
}
|
}
|
||||||
console.log("rollCompetence !!!", rollData);
|
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
await this._openRollDialog({
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html' },
|
|
||||||
{
|
|
||||||
name: 'jet-competence',
|
name: 'jet-competence',
|
||||||
label: 'Jet ' + Grammar.apostrophe('de', rollData.competence.name),
|
label: 'Jet ' + Grammar.apostrophe('de', rollData.competence.name),
|
||||||
callbacks: [
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
|
||||||
this.createCallbackExperience(),
|
rollData: rollData,
|
||||||
this.createCallbackAppelAuMoral(),
|
callbackAction: r => this.$onRollCompetence(r)
|
||||||
{ action: r => this.$onRollCompetence(r) }
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
dialog.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -2427,39 +2408,31 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollTache(id) {
|
async rollTache(id, options = {}) {
|
||||||
const tacheData = this.getTache(id)
|
const tacheData = this.getTache(id)
|
||||||
const compData = this.getCompetence(tacheData.system.competence)
|
const compData = this.getCompetence(tacheData.system.competence)
|
||||||
compData.system.defaut_carac = tacheData.system.carac; // Patch !
|
compData.system.defaut_carac = tacheData.system.carac; // Patch !
|
||||||
|
|
||||||
let rollData = {
|
await this._openRollDialog({
|
||||||
|
name: 'jet-competence',
|
||||||
|
label: 'Jet de Tâche ' + tacheData.name,
|
||||||
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
|
||||||
|
rollData: {
|
||||||
competence: compData,
|
competence: compData,
|
||||||
tache: tacheData,
|
tache: tacheData,
|
||||||
diffLibre: tacheData.system.difficulte,
|
diffLibre: tacheData.system.difficulte,
|
||||||
diffConditions: 0,
|
diffConditions: 0,
|
||||||
use: { libre: false, conditions: true },
|
use: { libre: false, conditions: true },
|
||||||
carac: {}
|
carac: {
|
||||||
};
|
[tacheData.system.carac]: duplicate(this.system.carac[tacheData.system.carac])
|
||||||
rollData.carac[tacheData.system.carac] = duplicate(this.system.carac[tacheData.system.carac]); // Single carac
|
}
|
||||||
|
},
|
||||||
console.log("rollTache !!!", rollData);
|
callbackAction: r => this._tacheResult(r, options)
|
||||||
|
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html' },
|
|
||||||
{
|
|
||||||
name: 'jet-competence',
|
|
||||||
label: 'Jet de Tâche ' + tacheData.name,
|
|
||||||
callbacks: [
|
|
||||||
this.createCallbackExperience(),
|
|
||||||
this.createCallbackAppelAuMoral(),
|
|
||||||
{ action: r => this._tacheResult(r) }
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
dialog.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _tacheResult(rollData) {
|
async _tacheResult(rollData, options) {
|
||||||
// Mise à jour de la tache
|
// Mise à jour de la tache
|
||||||
rollData.appliquerFatigue = ReglesOptionelles.isUsing("appliquer-fatigue");
|
rollData.appliquerFatigue = ReglesOptionelles.isUsing("appliquer-fatigue");
|
||||||
rollData.tache = duplicate(rollData.tache);
|
rollData.tache = duplicate(rollData.tache);
|
||||||
@ -2481,7 +2454,7 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _rollArt(artData, selected, oeuvre, callBackResult = r => this._resultArt(r)) {
|
async _rollArt(artData, selected, oeuvre, callbackAction = r => this._resultArt(r)) {
|
||||||
oeuvre.system.niveau = oeuvre.system.niveau ?? 0;
|
oeuvre.system.niveau = oeuvre.system.niveau ?? 0;
|
||||||
mergeObject(artData,
|
mergeObject(artData,
|
||||||
{
|
{
|
||||||
@ -2499,18 +2472,14 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
artData.forceCarac = {};
|
artData.forceCarac = {};
|
||||||
artData.forceCarac[selected] = duplicate(this.system.carac[selected]);
|
artData.forceCarac[selected] = duplicate(this.system.carac[selected]);
|
||||||
}
|
}
|
||||||
const dialog = await RdDRoll.create(this, artData,
|
|
||||||
{ html: `systems/foundryvtt-reve-de-dragon/templates/dialog-roll-${oeuvre.type}.html` },
|
await this._openRollDialog({
|
||||||
{
|
|
||||||
name: `jet-${artData.art}`,
|
name: `jet-${artData.art}`,
|
||||||
label: `${artData.verbe} ${oeuvre.name}`,
|
label: `${artData.verbe} ${oeuvre.name}`,
|
||||||
callbacks: [
|
template: `systems/foundryvtt-reve-de-dragon/templates/dialog-roll-${oeuvre.type}.html`,
|
||||||
this.createCallbackExperience(),
|
rollData: artData,
|
||||||
this.createCallbackAppelAuMoral(),
|
callbackAction: callbackAction
|
||||||
{ action: r => callBackResult(r) }
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
dialog.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -2779,24 +2748,17 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollAppelChance(onSuccess = () => {}, onEchec = () => {}) {
|
async rollAppelChance(onSuccess = () => {}, onEchec = () => {}) {
|
||||||
// Stocke si utilisation de la chance
|
await this._openRollDialog({
|
||||||
let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
|
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
|
|
||||||
{
|
|
||||||
name: 'appelChance',
|
name: 'appelChance',
|
||||||
label: 'Appel à la chance',
|
label: 'Appel à la chance',
|
||||||
callbacks: [
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||||
this.createCallbackExperience(),
|
rollData: { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' },
|
||||||
{ action: r => this._appelChanceResult(r, onSuccess, onEchec) },
|
callbackAction: r => this._appelChanceResult(r, onSuccess, onEchec)
|
||||||
]
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
dialog.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _appelChanceResult(rollData, onSuccess = () => { }, onEchec = () => { }) {
|
async _appelChanceResult(rollData, onSuccess, onEchec) {
|
||||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
||||||
if (rollData.rolled.isSuccess) {
|
if (rollData.rolled.isSuccess) {
|
||||||
await this.setFlag(SYSTEM_RDD, 'utilisationChance', true);
|
await this.setFlag(SYSTEM_RDD, 'utilisationChance', true);
|
||||||
|
Loading…
Reference in New Issue
Block a user