#150 : Gestion du cas Thanatos

This commit is contained in:
sladecraven 2021-02-06 23:51:04 +01:00
parent 5cd60ca76a
commit 4b88efa999
5 changed files with 24 additions and 2 deletions

View File

@ -706,6 +706,7 @@ export class RdDActor extends Actor {
} else { } else {
console.log("Competence not found", compName); console.log("Competence not found", compName);
} }
RdDUtility.checkThanatosXP( compName );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -59,10 +59,12 @@ export class RdDItemCompetence extends Item {
static computeCompetenceXPCost(competence) { static computeCompetenceXPCost(competence) {
let xp = RdDItemCompetence.getDeltaXp(competence.data.base, competence.data.niveau ?? competence.data.base); let xp = RdDItemCompetence.getDeltaXp(competence.data.base, competence.data.niveau ?? competence.data.base);
xp += competence.data.xp ?? 0; xp += competence.data.xp ?? 0;
if ( competence.name.includes('Thanatos') ) xp *= 2; /// Thanatos compte double !
xp += competence.data.xp_sort ?? 0; xp += competence.data.xp_sort ?? 0;
return xp; return xp;
} }
/* -------------------------------------------- */
static computeEconomieCompetenceTroncXP(competences) { static computeEconomieCompetenceTroncXP(competences) {
let economie = 0; let economie = 0;
for (let troncList of competenceTroncs) { for (let troncList of competenceTroncs) {
@ -87,17 +89,20 @@ export class RdDItemCompetence extends Item {
return RdDItemCompetence.getCompetenceXp(niveau + 1); return RdDItemCompetence.getCompetenceXp(niveau + 1);
} }
/* -------------------------------------------- */
static getCompetenceXp(niveau) { static getCompetenceXp(niveau) {
RdDItemCompetence._valideNiveau(niveau); RdDItemCompetence._valideNiveau(niveau);
return niveau < -10 ? 0 : competence_xp_par_niveau[niveau + 10]; return niveau < -10 ? 0 : competence_xp_par_niveau[niveau + 10];
} }
/* -------------------------------------------- */
static getDeltaXp(from, to) { static getDeltaXp(from, to) {
RdDItemCompetence._valideNiveau(from); RdDItemCompetence._valideNiveau(from);
RdDItemCompetence._valideNiveau(to); RdDItemCompetence._valideNiveau(to);
return competence_xp_cumul[to] - competence_xp_cumul[from]; return competence_xp_cumul[to] - competence_xp_cumul[from];
} }
/* -------------------------------------------- */
static _valideNiveau(niveau){ static _valideNiveau(niveau){
if (niveau < -11 || niveau > competence_niveau_max) { if (niveau < -11 || niveau > competence_niveau_max) {
console.warn("Niveau en dehors des niveaux de compétences: [-11, " + competence_niveau_max + "]", niveau) console.warn("Niveau en dehors des niveaux de compétences: [-11, " + competence_niveau_max + "]", niveau)

View File

@ -80,6 +80,12 @@ export class RdDItemSheet extends ItemSheet {
// Select competence categorie // Select competence categorie
html.find("#categorie").on("click", this._onClickSelectCategorie.bind(this) ); html.find("#categorie").on("click", this._onClickSelectCategorie.bind(this) );
html.find('#sheet-competence-xp').change((event) => {
if ( this.object.data.type == 'competence') {
RdDUtility.checkThanatosXP( this.object.data.name );
}
} );
html.find('#creer-tache-livre').click((event) => { html.find('#creer-tache-livre').click((event) => {
let actorId = event.currentTarget.attributes['data-actor-id'].value; let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get( actorId ); let actor = game.actors.get( actorId );

View File

@ -1022,4 +1022,14 @@ export class RdDUtility {
} }
} }
/* -------------------------------------------- */
static checkThanatosXP(compName) {
if ( compName.includes('Thanatos') ) {
let message = "Vous avez mis des points d'Expérience dans la Voie de Thanatos !<br>Vous devez réduire manuellement d'un même montant d'XP une autre compétence Draconique.";
ChatMessage.create({
whisper: ChatMessage.getWhisperRecipients(game.user.name),
content: message
});
}
}
} }

View File

@ -28,7 +28,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="xp">XP </label> <label for="xp">XP </label>
<input class="attribute-value" type="text" name="data.xp" value="{{data.xp}}" data-dtype="Number"/> <input class="attribute-value" id="sheet-competence-xp" type="text" name="data.xp" value="{{data.xp}}" data-dtype="Number"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="base">Niveau de base </label> <label for="base">Niveau de base </label>