Méthode de fenêtre de jet partagée
This commit is contained in:
parent
ffccc819f1
commit
e470d76ea0
256
module/actor.js
256
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 = {
|
|
||||||
carac: carac,
|
|
||||||
selectedCarac: carac.apparence,
|
|
||||||
selectedCaracName: 'apparence',
|
|
||||||
competences: this.itemTypes['competence']
|
|
||||||
};
|
|
||||||
|
|
||||||
|
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,
|
||||||
|
selectedCarac: carac.apparence,
|
||||||
|
selectedCaracName: 'apparence',
|
||||||
|
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 = {
|
|
||||||
carac: { 'reve': reve },
|
|
||||||
forceCarac: { 'reve': reve },
|
|
||||||
selectedCarac: reve,
|
|
||||||
draconicList: draconicList,
|
|
||||||
competence: draconicList[0],
|
|
||||||
sortList: sortList,
|
|
||||||
selectedSort: sortList[0],
|
|
||||||
tmr: TMRUtility.getTMR(coord),
|
|
||||||
diffLibre: RdDItemSort.getDifficulte(sortList[0], -7), // Per default at startup
|
|
||||||
coutreve: Array(30).fill().map((item, index) => 1 + index),
|
|
||||||
}
|
|
||||||
|
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
await this._openRollDialog({
|
||||||
{
|
name: 'lancer-un-sort',
|
||||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
|
label: 'Lancer un sort',
|
||||||
close: html => { this.currentTMR.maximize() } // Re-display TMR
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
|
||||||
|
rollData: {
|
||||||
|
carac: { 'reve': reve },
|
||||||
|
forceCarac: { 'reve': reve },
|
||||||
|
selectedCarac: reve,
|
||||||
|
draconicList: draconicList,
|
||||||
|
competence: draconicList[0],
|
||||||
|
sortList: sorts,
|
||||||
|
selectedSort: sorts[0],
|
||||||
|
tmr: TMRUtility.getTMR(coord),
|
||||||
|
diffLibre: RdDItemSort.getDifficulte(sorts[0], -7), // Per default at startup
|
||||||
|
coutreve: Array(30).fill().map((item, index) => 1 + index),
|
||||||
},
|
},
|
||||||
{
|
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({
|
||||||
selectedCarac: this.getCaracByName(caracName),
|
name: 'jet-' + caracName,
|
||||||
competences: this.itemTypes['competence'],
|
label: 'Jet ' + Grammar.apostrophe('de', rollData.selectedCarac.label),
|
||||||
jetResistance: jetResistance ? caracName : undefined
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||||
};
|
rollData: {
|
||||||
|
selectedCarac: this.getCaracByName(caracName),
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
competences: this.itemTypes['competence'],
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
|
jetResistance: jetResistance ? caracName : undefined
|
||||||
{
|
},
|
||||||
name: 'jet-' + caracName,
|
callbackAction: r => this.$onRollCaracResult(r)
|
||||||
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',
|
||||||
{
|
label: 'Jet ' + Grammar.apostrophe('de', rollData.competence.name),
|
||||||
name: 'jet-competence',
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
|
||||||
label: 'Jet ' + Grammar.apostrophe('de', rollData.competence.name),
|
rollData: rollData,
|
||||||
callbacks: [
|
callbackAction: r => this.$onRollCompetence(r)
|
||||||
this.createCallbackExperience(),
|
});
|
||||||
this.createCallbackAppelAuMoral(),
|
|
||||||
{ 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({
|
||||||
competence: compData,
|
name: 'jet-competence',
|
||||||
tache: tacheData,
|
label: 'Jet de Tâche ' + tacheData.name,
|
||||||
diffLibre: tacheData.system.difficulte,
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
|
||||||
diffConditions: 0,
|
rollData: {
|
||||||
use: { libre: false, conditions: true },
|
competence: compData,
|
||||||
carac: {}
|
tache: tacheData,
|
||||||
};
|
diffLibre: tacheData.system.difficulte,
|
||||||
rollData.carac[tacheData.system.carac] = duplicate(this.system.carac[tacheData.system.carac]); // Single carac
|
diffConditions: 0,
|
||||||
|
use: { libre: false, conditions: true },
|
||||||
console.log("rollTache !!!", rollData);
|
carac: {
|
||||||
|
[tacheData.system.carac]: duplicate(this.system.carac[tacheData.system.carac])
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
}
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html' },
|
},
|
||||||
{
|
callbackAction: r => this._tacheResult(r, options)
|
||||||
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}`,
|
template: `systems/foundryvtt-reve-de-dragon/templates/dialog-roll-${oeuvre.type}.html`,
|
||||||
callbacks: [
|
rollData: artData,
|
||||||
this.createCallbackExperience(),
|
callbackAction: callbackAction
|
||||||
this.createCallbackAppelAuMoral(),
|
});
|
||||||
{ action: r => callBackResult(r) }
|
|
||||||
]
|
|
||||||
});
|
|
||||||
dialog.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -2778,25 +2747,18 @@ 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: '' };
|
name: 'appelChance',
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
label: 'Appel à la chance',
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
|
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||||
{
|
rollData: { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' },
|
||||||
name: 'appelChance',
|
callbackAction: r => this._appelChanceResult(r, onSuccess, onEchec)
|
||||||
label: 'Appel à la chance',
|
});
|
||||||
callbacks: [
|
|
||||||
this.createCallbackExperience(),
|
|
||||||
{ action: 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