Draft: Mineurs v1.3 #356

Closed
vincent.vandeme wants to merge 2 commits from mineurs-v1.3 into v1.3

View File

@ -175,12 +175,24 @@ export class RdDActor extends Actor {
isCreature() { isCreature() {
return this.data.type == 'creature' || this.data.type == 'entite'; return this.data.type == 'creature' || this.data.type == 'entite';
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
isPersonnage() { isPersonnage() {
return this.data.type == 'personnage'; return this.data.type == 'personnage';
} }
/* -------------------------------------------- */
getFatigueActuelle() {
if (!this.isPersonnage()) {
return 0;
}
return Misc.toInt(this.data.data.sante.fatigue?.value);
}
/* -------------------------------------------- */
getFatigueMax() {
if (!this.isPersonnage()) {
return 1;
}
return Misc.toInt(this.data.data.sante.fatigue?.max);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getReveActuel() { getReveActuel() {
return Misc.toInt(this.data.data.reve?.reve?.value ?? this.data.data.carac.reve.value); return Misc.toInt(this.data.data.reve?.reve?.value ?? this.data.data.carac.reve.value);
@ -1295,14 +1307,17 @@ export class RdDActor extends Actor {
if (sante.fatigue && fatigue > 0) { if (sante.fatigue && fatigue > 0) {
sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this._computeFatigueMin()); sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this._computeFatigueMin());
} }
if (!this.isEntiteCauchemar() && sante.vie.value<-this.getSConst()) { await this.update({ "data.sante": sante });
if (this.isDead()) {
await this.addStatusEffectById('dead'); await this.addStatusEffectById('dead');
} }
await this.update({ "data.sante": sante });
return result; return result;
} }
isDead() {
return !this.isEntiteCauchemar() && this.data.data.sante.vie.value<-this.getSConst()
}
/* -------------------------------------------- */ /* -------------------------------------------- */
_computeFatigueMin() { _computeFatigueMin() {
return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value; return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value;
@ -2003,6 +2018,7 @@ export class RdDActor extends Actor {
let competence = duplicate(this.getCompetence("chant")); let competence = duplicate(this.getCompetence("chant"));
competence.data.defaut_carac = "ouie"; competence.data.defaut_carac = "ouie";
let chantData = { let chantData = {
art: 'chant',
competence: competence, competence: competence,
chant: chant, chant: chant,
diffLibre: -chant.data.niveau, diffLibre: -chant.data.niveau,
@ -2028,171 +2044,95 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _chantResult(chantData) { async _chantResult(chantData) {
if (chantData.rolled.isSuccess) { if (chantData.rolled.isSuccess) {
chantData.qualiteFinale = chantData.danse.data.niveau + chantData.rolled.ptQualite; chantData.qualiteFinale = chantData.competence.data.niveau + chantData.rolled.ptQualite;
} else { } else {
chantData.qualiteFinale = chantData.competence.data.niveau + chantData.rolled.ptQualite; chantData.qualiteFinale = chantData.competence.data.niveau + chantData.rolled.ptQualite;
} }
console.log("CHAN", chantData) console.log("CHANT", chantData)
RdDResolutionTable.displayRollData(chantData, this.name, 'chat-resultat-chant.html'); RdDResolutionTable.displayRollData(chantData, this.name, 'chat-resultat-chant.html');
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollDanse( id ) { async _rollArt(artData, selectedCarac, competence, oeuvre) {
let danse = duplicate(this.getDanse(id)); mergeObject(artData, {
let competence = duplicate(this.getCompetence("danse")); oeuvre: oeuvre,
let danseData = { competence: duplicate(competence),
competence: competence, diffLibre: -oeuvre.data.niveau,
danse: danse,
diffLibre: -danse.data.niveau,
diffConditions: 0, diffConditions: 0,
use: { libre: false, conditions: true, }, use: { libre: false, conditions: true, },
selectedCarac: duplicate(this.data.data.carac[selectedCarac]),
forceCarac: {} forceCarac: {}
}; });
if ( danse.data.agilite) { artData.competence.data.defaut_carac = selectedCarac;
competence.data.defaut_carac = "agilite"; artData.forceCarac[selectedCarac] = duplicate(this.data.data.carac[selectedCarac]);
danseData.selectedCarac = duplicate(this.data.data.carac["agilite"]);
danseData.forceCarac["agilite"] = duplicate(this.data.data.carac["agilite"]);
}
if ( danse.data.apparence) {
competence.data.defaut_carac = "apparence";
danseData.selectedCarac = duplicate(this.data.data.carac["apparence"]);
danseData.forceCarac["apparence"] = duplicate(this.data.data.carac["apparence"]);
}
console.log("rollDanse !!!", danseData); console.log("rollArtiste !!!", artData);
const dialog = await RdDRoll.create(this, danseData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-danse.html' }, { const dialog = await RdDRoll.create(this, artData, { html: `systems/foundryvtt-reve-de-dragon/templates/dialog-roll-${artData.art}.html` }, {
name: 'jet-danse', name: `jet-${artData.art}`,
label: 'Danser ' + danse.name, label: `${artData.verbe} ${oeuvre.name}`,
height: 600, height: 600,
callbacks: [ callbacks: [
this.createCallbackExperience(), this.createCallbackExperience(),
{ action: r => this._danseResult(r) } { action: r => this._resultArt(r) }
] ]
}); });
dialog.render(true); dialog.render(true);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _danseResult(danseData) { async _resultArt(artData) {
if ( danseData.rolled.isSuccess) { const baseQualite = (artData.rolled.isSuccess ? artData.oeuvre.data.niveau : artData.competence.data.niveau);
danseData.qualiteFinale = danseData.danse.data.niveau + danseData.rolled.ptQualite; artData.qualiteFinale = Math.min(baseQualite, artData.oeuvre.data.niveau) + artData.rolled.ptQualite;
} else {
danseData.qualiteFinale = danseData.competence.data.niveau + danseData.rolled.ptQualite; console.log("OEUVRE", artData.art, artData)
RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
} }
console.log("CHAN", danseData)
RdDResolutionTable.displayRollData(danseData, this.name, 'chat-resultat-danse.html'); 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);
}
_getCaracDanse(oeuvre, competence) {
if (oeuvre.data.agilite) {
return "agilite";
}
else if (oeuvre.data.apparence) {
return "apparence";
}
return competence.data.defaut_carac;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollMusique(id) { async rollMusique(id) {
let musique = duplicate(this.getMusique(id)); const oeuvre = duplicate(this.getMusique(id));
let competence = duplicate(this.getCompetence("musique")); const competence = this.getCompetence("musique");
competence.data.defaut_carac = "ouie"; const selectedCarac = "ouie";
let musiqueData = { const artData = { art: 'musique', verbe: 'Jouer' };
competence: competence, await this._rollArt(artData, selectedCarac, competence, oeuvre);
musique: musique,
diffLibre: -musique.data.niveau,
diffConditions: 0,
use: { libre: false, conditions: true, },
carac: {}
};
musiqueData.carac["ouie"] = duplicate(this.data.data.carac["ouie"]);
console.log("rollMusique !!!", musiqueData);
const dialog = await RdDRoll.create(this, musiqueData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-musique.html' }, {
name: 'jet-musique',
label: 'Jouer ' + musique.name,
height: 600,
callbacks: [
this.createCallbackExperience(),
{ action: r => this._musiqueResult(r) }
]
});
dialog.render(true);
}
/* -------------------------------------------- */
async _musiqueResult(musiqueData) {
if ( musiqueData.rolled.isSuccess) {
musiqueData.qualiteFinale = musiqueData.musique.data.niveau + musiqueData.rolled.ptQualite;
} else {
musiqueData.qualiteFinale = musiqueData.competence.data.niveau + musiqueData.rolled.ptQualite;
}
console.log("MUSIQUE", musiqueData)
RdDResolutionTable.displayRollData(musiqueData, this.name, 'chat-resultat-musique.html');
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollJeu(id) { async rollJeu(id) {
let jeu = duplicate(this.getJeu(id)); const oeuvre = duplicate(this.getJeu(id));
let competence = duplicate(this.getCompetence("jeu")); const competence = this.getCompetence("jeu");
let jeuData = { const selectedCarac = competence.data.defaut_carac;
competence: competence, const artData = { art: 'jeu', verbe: 'Jeu' };
jeu: jeu, await this._rollArt(artData, selectedCarac, competence, oeuvre);
diffLibre: 0,
diffConditions: 0,
use: { libre: true, conditions: true, },
carac: {}
};
console.log("rollJeu !!!", jeuData);
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 rollRecetteCuisine(id) { async rollRecetteCuisine(id) {
let cuisine = duplicate(this.getRecetteCuisine(id)); const oeuvre = duplicate(this.getRecetteCuisine(id));
let competence = duplicate(this.getCompetence("cuisine")); const competence = this.getCompetence("cuisine");
competence.data.defaut_carac = "odoratgout"; const selectedCarac = 'odoratgout';
let cuisineData = { const artData = { art: 'cuisine', verbe: 'Cuisiner' };
competence: competence, await this._rollArt(artData, selectedCarac, competence, oeuvre);
cuisine: cuisine,
diffLibre: -cuisine.data.niveau,
diffConditions: 0,
use: { libre: true, conditions: true, },
carac: {}
};
cuisineData.carac["odoratgout"] = duplicate(this.data.data.carac["odoratgout"]);
console.log("rollRecetteCuisine !!!", cuisineData);
const dialog = await RdDRoll.create(this, cuisineData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-cuisine.html' }, {
name: 'jet-jeu',
label: 'Cuisiner ' + cuisine.name,
height: 600,
callbacks: [
this.createCallbackExperience(),
{ action: r => this._recetteCuisineResult(r) }
]
});
dialog.render(true);
} }
/* -------------------------------------------- */
async _recetteCuisineResult(cuisineData) {
if ( cuisineData.rolled.isSuccess) {
cuisineData.qualiteFinale = cuisineData.cuisine.data.niveau + cuisineData.rolled.ptQualite;
} else {
cuisineData.qualiteFinale = cuisineData.competence.data.niveau + cuisineData.rolled.ptQualite;
}
console.log("Cuisine", cuisineData)
RdDResolutionTable.displayRollData(cuisineData, this.name, 'chat-resultat-cuisine.html');
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollMeditation(id) { async rollMeditation(id) {