Amélioration messages de stress
This commit is contained in:
parent
861e8de590
commit
a12f9bbf01
@ -459,7 +459,7 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
this.actor.setEthylisme(parseInt(event.target.value));
|
this.actor.setEthylisme(parseInt(event.target.value));
|
||||||
});
|
});
|
||||||
html.find('#stress-test').click((event) => {
|
html.find('#stress-test').click((event) => {
|
||||||
this.actor.stressTest();
|
this.actor.transformerStress();
|
||||||
this.render(true);
|
this.render(true);
|
||||||
});
|
});
|
||||||
html.find('#moral-malheureux').click((event) => {
|
html.find('#moral-malheureux').click((event) => {
|
||||||
|
@ -321,7 +321,7 @@ export class RdDActor extends Actor {
|
|||||||
await this._recupererVie(message);
|
await this._recupererVie(message);
|
||||||
await this.jetDeMoral('neutre');
|
await this.jetDeMoral('neutre');
|
||||||
await this.chanceActuelleIncDec(1);
|
await this.chanceActuelleIncDec(1);
|
||||||
await this.transformerStress(message);
|
this.transformerStress();
|
||||||
await this.retourSeuilDeReve(message);
|
await this.retourSeuilDeReve(message);
|
||||||
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
||||||
ChatMessage.create(message);
|
ChatMessage.create(message);
|
||||||
@ -1417,69 +1417,72 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async stressTest() {
|
async transformerStress() {
|
||||||
const message = {
|
const stress = Misc.toInt(this.data.data.compteurs.stress.value);
|
||||||
content: "",
|
|
||||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name)
|
|
||||||
};
|
|
||||||
await this.transformerStress(message);
|
|
||||||
ChatMessage.create(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async transformerStress(message) {
|
|
||||||
let compteurs = duplicate(this.data.data.compteurs);
|
|
||||||
const stress = Misc.toInt(compteurs.stress.value);
|
|
||||||
|
|
||||||
if (stress <= 0) {
|
if (stress <= 0) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let stressRoll = await this._stressRoll();
|
const stressRoll = await this._stressRoll(this.getReveActuel());
|
||||||
let convertis = Math.floor(stress * stressRoll.factor);
|
|
||||||
compteurs.stress.value = Math.max(stress - convertis - 1, 0);
|
|
||||||
|
|
||||||
let dissolution = Math.max(0, Misc.toInt(compteurs.dissolution.value));
|
const conversion = Math.floor(stress * stressRoll.factor / 100);
|
||||||
let exaltation = Math.max(0, Misc.toInt(compteurs.exaltation.value));
|
let dissolution = Math.max(0, Misc.toInt(this.data.data.compteurs.dissolution.value));
|
||||||
|
let exaltation = Math.max(0, Misc.toInt(this.data.data.compteurs.exaltation.value));
|
||||||
const annule = Math.min(dissolution, exaltation);
|
const annule = Math.min(dissolution, exaltation);
|
||||||
dissolution -= annule;
|
dissolution -= annule;
|
||||||
exaltation -= annule;
|
exaltation -= annule;
|
||||||
if (dissolution > 0) {
|
const perteDissolution = Math.max(0, Math.min(dissolution, conversion));
|
||||||
const perdus = Math.min(dissolution, convertis);
|
|
||||||
convertis -= perdus;
|
let stressRollData = {
|
||||||
dissolution -= perdus;
|
alias: this.name,
|
||||||
}
|
selectedCarac: this.data.data.carac.reve,
|
||||||
compteurs.experience.value += convertis + exaltation;
|
rolled: stressRoll,
|
||||||
compteurs.dissolution.value = dissolution;
|
stress: stress,
|
||||||
|
perte: Math.min(conversion, stress),
|
||||||
|
convertis: conversion - perteDissolution,
|
||||||
|
xp: conversion - perteDissolution + exaltation,
|
||||||
|
dissolution: dissolution,
|
||||||
|
exaltation: exaltation
|
||||||
|
};
|
||||||
|
|
||||||
|
ChatMessage.create({
|
||||||
|
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||||
|
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-resultat-transformer-stress.html`, stressRollData)
|
||||||
|
});
|
||||||
|
|
||||||
|
let compteurs = duplicate(this.data.data.compteurs);
|
||||||
|
compteurs.stress.value = Math.max(stress - stressRollData.perte - 1, 0);
|
||||||
|
compteurs.experience.value += stressRollData.xp;
|
||||||
|
compteurs.dissolution.value = dissolution - perteDissolution;
|
||||||
compteurs.exaltation.value = 0;
|
compteurs.exaltation.value = 0;
|
||||||
message.content += "<br>Vous transformez " + convertis + " points de Stress en Expérience" + stressRoll.comment;
|
|
||||||
await this.update({ "data.compteurs": compteurs });
|
await this.update({ "data.compteurs": compteurs });
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _stressRoll() {
|
async _stressRoll(reveActuel) {
|
||||||
let reveActuel = this.getReveActuel();
|
|
||||||
let result = await RdDResolutionTable.roll(reveActuel, 0);
|
let result = await RdDResolutionTable.roll(reveActuel, 0);
|
||||||
console.log("_stressRoll", result);
|
if (result.isPart) {
|
||||||
switch (result.code) {
|
result.second = await RdDResolutionTable.roll(reveActuel, 0);
|
||||||
case "sign": return { factor: 0.75, comment: " (75%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
}
|
||||||
case "norm": return { factor: 0.5, comment: " (50%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
result.factor = this._getFacteurStress(result);
|
||||||
case "echec": return { factor: 0.2, comment: " (20%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
return result;
|
||||||
case "epart": return { factor: 0.1, comment: " (10%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
}
|
||||||
case "etotal": return { factor: 0, comment: " (0%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
|
||||||
|
_getFacteurStress(stressRoll) {
|
||||||
|
switch (stressRoll.code) {
|
||||||
|
case "sign": return 75;
|
||||||
|
case "norm": return 50;
|
||||||
|
case "echec": return 20;
|
||||||
|
case "epart": return 10;
|
||||||
|
case "etotal": return 0;
|
||||||
case "part":
|
case "part":
|
||||||
{
|
if (stressRoll.second.isSign) {
|
||||||
let second = await RdDResolutionTable.roll(reveActuel, 0);
|
stressRoll.quality = "Double Particulière";
|
||||||
console.log("_stressRoll", second);
|
return 150;
|
||||||
switch (second.code) {
|
|
||||||
case "part": case "sign":
|
|
||||||
return { factor: 1.5, comment: " (150%): Double Particulière - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
|
|
||||||
default:
|
|
||||||
return { factor: 1, comment: " (100%): " + result.quality + " - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return 100;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -249,7 +249,7 @@ export class RdDCommands {
|
|||||||
getCoutXpCarac(msg, params) {
|
getCoutXpCarac(msg, params) {
|
||||||
if (params && params.length == 1) {
|
if (params && params.length == 1) {
|
||||||
let to = Number(params[0]);
|
let to = Number(params[0]);
|
||||||
RdDCommands._chatAnswer(msg, `Coût pour passer une caractéristique de ${to - 1} à ${to}: ${RdDUtility.getCaractXp(to)}`);
|
RdDCommands._chatAnswer(msg, `Coût pour passer une caractéristique de ${to - 1} à ${to}: ${RdDUtility.getCaracXp(to)}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -412,11 +412,11 @@ export class RdDUtility {
|
|||||||
static getCaracNextXp(value) {
|
static getCaracNextXp(value) {
|
||||||
const nextValue = Number(value) + 1;
|
const nextValue = Number(value) + 1;
|
||||||
// xp est le coût pour atteindre cette valeur, on regarde donc le coût de la valeur+1
|
// xp est le coût pour atteindre cette valeur, on regarde donc le coût de la valeur+1
|
||||||
return RdDUtility.getCaractXp(nextValue);
|
return RdDUtility.getCaracXp(nextValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getCaractXp(targetValue) {
|
static getCaracXp(targetValue) {
|
||||||
return tableCaracDerivee[targetValue].xp;
|
return tableCaracDerivee[targetValue]?.xp ?? 200 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
18
templates/chat-resultat-transformer-stress.html
Normal file
18
templates/chat-resultat-transformer-stress.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<h4>
|
||||||
|
{{alias}} transforme {{rolled.factor}}% de son stress
|
||||||
|
</h4>
|
||||||
|
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}}
|
||||||
|
{{#if rolled.isPart}}
|
||||||
|
<div>
|
||||||
|
<span>
|
||||||
|
Deuxième jet: {{rolled.second.roll}} <span class="rdd-roll-{{rolled.second.code}} strong-text">{{rolled.second.quality}}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
<hr>
|
||||||
|
<span>
|
||||||
|
Transformation de {{perte}} points de stress sur {{stress}}
|
||||||
|
{{~#if (gt dissolution 0)}}; {{dissolution}} points perdus par la dissolution{{/if~}}
|
||||||
|
{{~#if (gt exaltation 0)}}; {{exaltation}} points gagnés par l'exaltation{{/if~}}
|
||||||
|
, gain de {{xp}} points d'expérience
|
||||||
|
</span>
|
Loading…
Reference in New Issue
Block a user