Gestion des compteur et du Stress
This commit is contained in:
parent
1fd3c9d22f
commit
ca8bf7f6d5
@ -94,6 +94,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
data.data.nbLegeres = this.actor.GetNumberBlessures(data.data.blessures.legeres.liste );
|
||||
data.data.nbGraves = this.actor.GetNumberBlessures(data.data.blessures.graves.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.
|
||||
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) );
|
||||
} );
|
||||
|
||||
// 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) => {
|
||||
this.actor.santeIncDec("vie", 1);
|
||||
this.render(true);
|
||||
|
@ -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( )
|
||||
{
|
||||
@ -426,6 +436,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
return nbB;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async santeIncDec(name, inc ) {
|
||||
const sante = duplicate(this.data.data.sante);
|
||||
@ -467,6 +478,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
await this.update( {"data.sante": sante } );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async manageBlessureFromSheet( bType, index, active ) {
|
||||
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 ) {
|
||||
let draconicList = this.getDraconicList();
|
||||
@ -675,9 +740,7 @@ export class RdDActor extends Actor {
|
||||
for (const item of this.data.items) {
|
||||
if (item.type == "armure" && item.data.equipe) {
|
||||
let update = duplicate(item);
|
||||
let myroll = new Roll(update.data.protection.toString());
|
||||
myroll.roll();
|
||||
protection += myroll.total;
|
||||
protection += new Roll(update.data.protection.toString()).roll().total;
|
||||
update.data.deterioration += domArmePlusDom;
|
||||
domArmePlusDom = 0; // Reset it
|
||||
if ( update.data.deterioration >= 10) {
|
||||
|
@ -329,7 +329,7 @@ export class RdDUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// 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 )
|
||||
{
|
||||
max = (max < 16) ? 16 : max;
|
||||
@ -443,7 +443,6 @@ export class RdDUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
static findCompetence(compList, compName)
|
||||
{
|
||||
for (const item of compList) {
|
||||
|
@ -125,7 +125,6 @@
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
padding: 5px;
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
.flex-group-left {
|
||||
@ -375,6 +374,12 @@ button {
|
||||
margin-right: 4px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.stress-style {
|
||||
flex-grow: 0;
|
||||
flex-basis: 64px;
|
||||
margin-right: 4px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
/* ======================================== */
|
||||
.item-checkbox {
|
||||
|
@ -2,10 +2,10 @@
|
||||
"name": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"description": "L'implémentation de Rêve de Dragon pour FoundryVTT",
|
||||
"version": "0.8.5",
|
||||
"version": "0.8.9",
|
||||
"minimumCoreVersion": "0.6.0",
|
||||
"compatibleCoreVersion": "0.6.2",
|
||||
"templateVersion": 23,
|
||||
"templateVersion": 28,
|
||||
"author": "LeRatierBretonnien",
|
||||
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
|
||||
"styles": ["styles/simple.css"],
|
||||
|
@ -253,36 +253,39 @@
|
||||
"compteurs": {
|
||||
"sust": {
|
||||
"value": 0,
|
||||
"label": "Sust."
|
||||
"label": "Sust.",
|
||||
"isInput": true
|
||||
},
|
||||
"eau": {
|
||||
"value": 0,
|
||||
"label": "Eau"
|
||||
"label": "Eau",
|
||||
"isInput": true
|
||||
},
|
||||
"moral": {
|
||||
"value": 0,
|
||||
"label": "Moral"
|
||||
"label": "Moral",
|
||||
"isInput": true
|
||||
},
|
||||
"exaltation": {
|
||||
"value": 0,
|
||||
"label": "Exaltation"
|
||||
"label": "Exaltation",
|
||||
"isInput": true
|
||||
},
|
||||
"dissolution": {
|
||||
"value": 0,
|
||||
"label": "Dissolution"
|
||||
"label": "Dissolution",
|
||||
"isInput": true
|
||||
},
|
||||
"chance": {
|
||||
"value": 0,
|
||||
"max": 0,
|
||||
"label": "Chance"
|
||||
"label": "Chance",
|
||||
"isInput": true
|
||||
},
|
||||
"destinee": {
|
||||
"value": 0,
|
||||
"label": "Destinée"
|
||||
},
|
||||
"stress": {
|
||||
"value": 0,
|
||||
"label": "Stress"
|
||||
"label": "Destinée",
|
||||
"isInput": true
|
||||
},
|
||||
"etat": {
|
||||
"value": 0,
|
||||
@ -290,7 +293,19 @@
|
||||
},
|
||||
"ethylisme": {
|
||||
"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": {
|
||||
|
@ -280,10 +280,20 @@
|
||||
{{#each data.compteurs as |compteur key|}}
|
||||
<li class="item flexrow"">
|
||||
<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>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</div>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
{{!-- blessures Tab --}}
|
||||
@ -434,9 +444,10 @@
|
||||
|
||||
{{!-- Biography Tab --}}
|
||||
<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}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user