Gestion des compteur et du Stress

This commit is contained in:
sladecraven 2020-08-29 22:52:41 +02:00
parent 1fd3c9d22f
commit ca8bf7f6d5
7 changed files with 130 additions and 25 deletions

View File

@ -94,6 +94,7 @@ export class RdDActorSheet extends ActorSheet {
data.data.nbLegeres = this.actor.GetNumberBlessures(data.data.blessures.legeres.liste ); data.data.nbLegeres = this.actor.GetNumberBlessures(data.data.blessures.legeres.liste );
data.data.nbGraves = this.actor.GetNumberBlessures(data.data.blessures.graves.liste ); data.data.nbGraves = this.actor.GetNumberBlessures(data.data.blessures.graves.liste );
data.data.nbCritiques = this.actor.GetNumberBlessures(data.data.blessures.critiques.liste ); data.data.nbCritiques = this.actor.GetNumberBlessures(data.data.blessures.critiques.liste );
console.log( data.data.compteurs );
// low is normal, this the base used to compute the grid. // low is normal, this the base used to compute the grid.
data.data.fatigueHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "</table>"; data.data.fatigueHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "</table>";
@ -235,6 +236,17 @@ export class RdDActorSheet extends ActorSheet {
this.actor.updateCompetenceXP( compName, parseInt(event.target.value) ); this.actor.updateCompetenceXP( compName, parseInt(event.target.value) );
} ); } );
// On stress change
html.find('.compteur-edit').change((event) => {
let fieldName = event.currentTarget.attributes.name.value;
this.actor.updateCompteurValue( fieldName, parseInt(event.target.value) );
} );
html.find('#stress-test').click((event) => {
this.actor.stressTest();
this.render(true);
});
html.find('#vie-plus').click((event) => { html.find('#vie-plus').click((event) => {
this.actor.santeIncDec("vie", 1); this.actor.santeIncDec("vie", 1);
this.render(true); this.render(true);

View File

@ -333,6 +333,16 @@ export class RdDActor extends Actor {
} }
} }
/* -------------------------------------------- */
async updateCompteurValue( fieldName, fieldValue )
{
//console.log("Update", fieldName, fieldValue);
let content;
let compteurs = duplicate(this.data.data.compteurs);
compteurs[fieldName].value = fieldValue;
await this.update( {"data.compteurs": compteurs } );
}
/* -------------------------------------------- */ /* -------------------------------------------- */
computeEtatGeneral( ) computeEtatGeneral( )
{ {
@ -426,6 +436,7 @@ export class RdDActor extends Actor {
} }
return nbB; return nbB;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async santeIncDec(name, inc ) { async santeIncDec(name, inc ) {
const sante = duplicate(this.data.data.sante); const sante = duplicate(this.data.data.sante);
@ -467,6 +478,7 @@ export class RdDActor extends Actor {
await this.update( {"data.sante": sante } ); await this.update( {"data.sante": sante } );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async manageBlessureFromSheet( bType, index, active ) { async manageBlessureFromSheet( bType, index, active ) {
let bList = duplicate(this.data.data.blessures); let bList = duplicate(this.data.data.blessures);
@ -545,6 +557,59 @@ export class RdDActor extends Actor {
} }
} }
/* -------------------------------------------- */
async stressTest( ) {
let compteurs = duplicate(this.data.data.compteurs);
let stress = compteurs.stress;
let xp = compteurs.experience;
let scoreTarget = RdDUtility.getResolutionField( this.data.data.carac.reve.value, 0 );
scoreTarget.sig = Math.floor(scoreTarget.score / 2);
let scoreValue = new Roll("d100").roll().total;
let newXP = xp.value;
let factor = 0;
let comment = "Echec Total (0%)"
if (scoreValue <= scoreTarget.part ) {
scoreValue = new Roll("d100").roll().total;
if (scoreValue <= scoreTarget.sig) {
factor = 1.5;
comment = "Double Particulière (150%)"
} else {
factor = 1;
comment = "Particulière (100%)"
}
} else {
if ( scoreValue <= scoreTarget.sig ) {
factor = 0.75;
comment = "Significative (75%)"
} else {
if ( scoreValue <= scoreTarget.score ) {
factor = 0.5;
comment = "Normale (50%)"
} else if (scoreValue <= scoreTarget.epart) {
factor = 0.2;
comment = "Echec (20%)"
} else if (scoreValue <= scoreTarget.etotal) {
factor = 0.1;
comment = "Echec (10%)"
}
}
}
let xpValue = Math.floor(stress.value * factor);
stress.value -= xpValue;
stress.value -= 1;
if (stress.value < 0 ) stress.value = 0;
ChatMessage.create( { title: "Jet de Stress", content: "Vous avez transformé "+ xpValue + " points de Stress en Expérience avec une réussite " + comment ,
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
xp.value += xpValue;
await this.update( { "data.compteurs": compteurs } );
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollUnSort( coord ) { async rollUnSort( coord ) {
let draconicList = this.getDraconicList(); let draconicList = this.getDraconicList();
@ -675,9 +740,7 @@ export class RdDActor extends Actor {
for (const item of this.data.items) { for (const item of this.data.items) {
if (item.type == "armure" && item.data.equipe) { if (item.type == "armure" && item.data.equipe) {
let update = duplicate(item); let update = duplicate(item);
let myroll = new Roll(update.data.protection.toString()); protection += new Roll(update.data.protection.toString()).roll().total;
myroll.roll();
protection += myroll.total;
update.data.deterioration += domArmePlusDom; update.data.deterioration += domArmePlusDom;
domArmePlusDom = 0; // Reset it domArmePlusDom = 0; // Reset it
if ( update.data.deterioration >= 10) { if ( update.data.deterioration >= 10) {

View File

@ -329,7 +329,7 @@ export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
// Build the nice (?) html table used to manage fatigue. // Build the nice (?) html table used to manage fatigue.
// max should be the endurance max value // max should Mbe the endurance max value
static makeHTMLfatigueMatrix( value, max ) static makeHTMLfatigueMatrix( value, max )
{ {
max = (max < 16) ? 16 : max; max = (max < 16) ? 16 : max;
@ -443,7 +443,6 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static findCompetence(compList, compName) static findCompetence(compList, compName)
{ {
for (const item of compList) { for (const item of compList) {

View File

@ -125,7 +125,6 @@
align-items: center; align-items: center;
text-align: center; text-align: center;
padding: 5px; padding: 5px;
border: 1px solid #999;
} }
.flex-group-left { .flex-group-left {
@ -375,6 +374,12 @@ button {
margin-right: 4px; margin-right: 4px;
margin-left: 4px; margin-left: 4px;
} }
.stress-style {
flex-grow: 0;
flex-basis: 64px;
margin-right: 4px;
margin-left: 4px;
}
/* ======================================== */ /* ======================================== */
.item-checkbox { .item-checkbox {

View File

@ -2,10 +2,10 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "L'implémentation de Rêve de Dragon pour FoundryVTT", "description": "L'implémentation de Rêve de Dragon pour FoundryVTT",
"version": "0.8.5", "version": "0.8.9",
"minimumCoreVersion": "0.6.0", "minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "0.6.2", "compatibleCoreVersion": "0.6.2",
"templateVersion": 23, "templateVersion": 28,
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ], "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"], "styles": ["styles/simple.css"],

View File

@ -253,36 +253,39 @@
"compteurs": { "compteurs": {
"sust": { "sust": {
"value": 0, "value": 0,
"label": "Sust." "label": "Sust.",
"isInput": true
}, },
"eau": { "eau": {
"value": 0, "value": 0,
"label": "Eau" "label": "Eau",
"isInput": true
}, },
"moral": { "moral": {
"value": 0, "value": 0,
"label": "Moral" "label": "Moral",
"isInput": true
}, },
"exaltation": { "exaltation": {
"value": 0, "value": 0,
"label": "Exaltation" "label": "Exaltation",
"isInput": true
}, },
"dissolution": { "dissolution": {
"value": 0, "value": 0,
"label": "Dissolution" "label": "Dissolution",
"isInput": true
}, },
"chance": { "chance": {
"value": 0, "value": 0,
"max": 0, "max": 0,
"label": "Chance" "label": "Chance",
"isInput": true
}, },
"destinee": { "destinee": {
"value": 0, "value": 0,
"label": "Destinée" "label": "Destinée",
}, "isInput": true
"stress": {
"value": 0,
"label": "Stress"
}, },
"etat": { "etat": {
"value": 0, "value": 0,
@ -290,7 +293,19 @@
}, },
"ethylisme": { "ethylisme": {
"value": 0, "value": 0,
"label": "Ethylisme" "label": "Ethylisme",
"isInput": true
},
"stress": {
"value": 0,
"label": "Stress",
"isStress": true,
"isInput": true
},
"experience": {
"value": 0,
"label": "Experience",
"isInput": true
} }
}, },
"argent": { "argent": {

View File

@ -280,10 +280,20 @@
{{#each data.compteurs as |compteur key|}} {{#each data.compteurs as |compteur key|}}
<li class="item flexrow""> <li class="item flexrow"">
<span class="arme-label">{{compteur.label}}</span> <span class="arme-label">{{compteur.label}}</span>
{{#if compteur.isInput}}
<input class="stress-value stress-style compteur-edit" id="{{key}}-edit" type="text" name="{{key}}" value="{{compteur.value}}" data-dtype="number"/>
{{#if compteur.isStress}}
<a class="item-control stress-test" id="stress-test" title="Faire un jet de Stress">Faire un jet de Stress</a>
{{else}}
<label></label>
{{/if}}
<label></label>
{{else}}
<span class="competence-label">{{compteur.value}}</span> <span class="competence-label">{{compteur.value}}</span>
{{/if}}
</li> </li>
{{/each}} {{/each}}
</div> </ol>
</div> </div>
{{!-- blessures Tab --}} {{!-- blessures Tab --}}
@ -434,9 +444,10 @@
{{!-- Biography Tab --}} {{!-- Biography Tab --}}
<div class="tab biography" data-group="primary" data-tab="description" style="height:200px"> <div class="tab biography" data-group="primary" data-tab="description" style="height:200px">
<div class="flexcol">
{{editor content=data.biographie target="data.biographie" button=true owner=owner editable=editable}} {{editor content=data.biographie target="data.biographie" button=true owner=owner editable=editable}}
</div> </div>
</div>
</section> </section>
</form> </form>