Ajout des Oeuvres génériques

Ajout de la description au tchat, ajout de la référence/auteur
à tous les types d'oeuvres

Ajout de l'exotisme à la cuisine

Jet de chant (qui ne marchait pas)
This commit is contained in:
Vincent Vandemeulebrouck
2021-02-06 01:34:01 +01:00
parent a2ec26c4c0
commit 7c54597a20
24 changed files with 349 additions and 133 deletions

View File

@ -278,6 +278,9 @@ export class RdDActor extends Actor {
getMusique(id) {
return this.data.items.find(item => item.type == 'musique' && item._id == id);
}
getOeuvre(id, type = 'oeuvre') {
return this.data.items.find(item => item.type == type && item._id == id);
}
getJeu(id) {
return this.data.items.find(item => item.type == 'jeu' && item._id == id);
}
@ -2041,20 +2044,21 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
async _rollArt(artData, selectedCarac, competence, oeuvre) {
async _rollArt(artData, selectedCarac, oeuvre, callBackResult = r =>this._resultArt(r)) {
mergeObject(artData, {
oeuvre: oeuvre,
competence: duplicate(competence),
diffLibre: -oeuvre.data.niveau,
art: oeuvre.type,
competence: duplicate(this.getCompetence(oeuvre.data.competence ?? artData.art)),
diffLibre: - (oeuvre.data.niveau ??0),
diffConditions: 0,
use: { libre: false, conditions: true, },
use: { libre: false, conditions: true },
selectedCarac: duplicate(this.data.data.carac[selectedCarac]),
forceCarac: {}
});
artData.competence.data.defaut_carac = selectedCarac;
artData.forceCarac[selectedCarac] = duplicate(this.data.data.carac[selectedCarac]);
console.log("rollArtiste !!!", artData);
console.log("rollArt !!!", artData);
const dialog = await RdDRoll.create(this, artData, { html: `systems/foundryvtt-reve-de-dragon/templates/dialog-roll-${artData.art}.html` }, {
name: `jet-${artData.art}`,
@ -2077,85 +2081,66 @@ export class RdDActor extends Actor {
RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
}
/* -------------------------------------------- */
async rollChant(id) {
const artData = { art: 'chant', verbe: 'Chanter' };
const oeuvre = duplicate(this.getChant(id));
await this._rollArt(artData, "ouie", oeuvre);
}
/* -------------------------------------------- */
async rollDanse(id) {
const oeuvre = duplicate(this.getDanse(id));
const competence = this.getCompetence("danse");
const selectedCarac = this._getCaracDanse(oeuvre, competence);
const artData = { art: 'danse', verbe: 'Danser' };
await this._rollArt(artData, selectedCarac, competence, oeuvre);
const oeuvre = duplicate(this.getOeuvre(id, artData.art));
const selectedCarac = this._getCaracDanse(oeuvre,);
await this._rollArt(artData, selectedCarac, oeuvre);
}
_getCaracDanse(oeuvre, competence) {
_getCaracDanse(oeuvre) {
if (oeuvre.data.agilite) { return "agilite"; }
else if (oeuvre.data.apparence) { return "apparence"; }
const competence = this.getCompetence(oeuvre.data.competence);
return competence.data.defaut_carac;
}
/* -------------------------------------------- */
async rollMusique(id) {
const oeuvre = duplicate(this.getMusique(id));
const competence = this.getCompetence("musique");
const selectedCarac = "ouie";
const artData = { art: 'musique', verbe: 'Jouer' };
await this._rollArt(artData, selectedCarac, competence, oeuvre);
const oeuvre = duplicate(this.getOeuvre(id, artData.art));
await this._rollArt(artData, "ouie", oeuvre);
}
/* -------------------------------------------- */
async rollRecetteCuisine(id) {
const oeuvre = duplicate(this.getRecetteCuisine(id));
const competence = this.getCompetence("cuisine");
const selectedCarac = 'odoratgout';
const artData = { art: 'cuisine', verbe: 'Cuisiner' };
await this._rollArt(artData, selectedCarac, competence, oeuvre);
const oeuvre = duplicate(this.getRecetteCuisine(id));
await this._rollArt(artData, 'odoratgout', oeuvre, r => this._resultRecetteCuisine(r) );
}
/* -------------------------------------------- */
async _resultRecetteCuisine(artData) {
const baseQualite = (artData.rolled.isSuccess ? artData.oeuvre.data.niveau : artData.competence.data.niveau);
artData.qualiteFinale = Math.min(baseQualite, artData.oeuvre.data.niveau) + artData.rolled.ptQualite;
artData.exotismeFinal = Math.min(Math.min(artData.qualiteFinale, -Math.abs(artData.oeuvre.data.exotisme??0)), 0);
console.log("OEUVRE", artData.art, artData)
RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
}
/* -------------------------------------------- */
async rollJeu(id) {
const oeuvre = duplicate(this.getJeu(id));
const competence = this.getCompetence("jeu");
const selectedCarac = competence.data.defaut_carac;
const artData = {
art: 'jeu', verbe: 'Jeu',
use: { libre: true, conditions: true, },
};
await this._rollArt(artData, selectedCarac, competence, oeuvre);
const oeuvre = duplicate(this.getJeu(id));
await this._rollArt(artData, oeuvre.data?.caraccomp.toLowerCase() ?? 'chance', oeuvre);
}
/* -------------------------------------------- */
async rollJeu( id ) {
let jeu = duplicate(this.getJeu(id));
let competence = duplicate(this.getCompetence("jeu"));
let jeuData = {
competence: competence,
jeu: jeu,
diffLibre: 0,
diffConditions: 0,
use: { libre: true, conditions: true, },
carac: {}
};
console.log("rollJeu !!!", jeuData);
async rollOeuvre(id) {
const artData = { art: 'oeuvre', verbe: 'Interpréter' };
const oeuvre = duplicate(this.getOeuvre(id));
await this._rollArt(artData, oeuvre.data.default_carac, oeuvre);
}
const dialog = await RdDRoll.create(this, jeuData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-jeu.html' }, {
name: 'jet-jeu',
label: 'Jeu ' + jeu.name,
height: 600,
callbacks: [
this.createCallbackExperience(),
{ action: r => this._jeuResult(r) }
]
});
dialog.render(true);
}
/* -------------------------------------------- */
async _jeuResult(jeudData) {
console.log("JEU", jeudData)
RdDResolutionTable.displayRollData(jeudData, this.name, 'chat-resultat-jeu.html');
}
/* -------------------------------------------- */
async rollMeditation(id) {
let meditation = duplicate(this.getMeditation(id));