attribute fix

This commit is contained in:
François-Xavier Guillois
2023-08-29 18:36:03 +02:00
parent ef111392c2
commit 18bce98162
3 changed files with 24 additions and 16 deletions
+22 -15
View File
@@ -53,25 +53,17 @@
formData[item.name] = item.value; formData[item.name] = item.value;
}); });
// console.log("roll form data", formData); // console.log("roll form data", formData);
let NoD = parseInt(formData.ability,10); let NoD = parseInt(formData.abilityScore,10);
let Reroll = 0; let Reroll = 0;
// difficulty // difficulty
data.difficulty = (formData.difficulty != undefined) ? formData.difficulty : 7; data.difficulty = (formData.difficulty != undefined) ? formData.difficulty : 7;
// maîtrise bonus // maîtrise bonus
// TODO : utiliser la configuration des niveaux de compétences plutôt if (formData.rollType == 'skill'){
if (formData.skill > 0 && formData.skill < 3){ NoD += CONFIG.VERMINE.SkillLevels[formData.skillScore].dicePool || 0;
NoD += 1; Reroll += CONFIG.VERMINE.SkillLevels[formData.skillScore].reroll || 0;
} else if (formData.skill > 2 && formData.skill < 5){
NoD += 2;
} else if (formData.skill > 4){
NoD += 3;
}
// maîtrise relance
if (formData.skill > 1 && formData.skill < 4){
Reroll += 1;
} else if (formData.skill > 3){
Reroll += 2;
} }
console.log('reroll', Reroll);
// réserves // réserves
if (formData.self_control > 0){ if (formData.self_control > 0){
NoD += parseInt(formData.self_control,10); NoD += parseInt(formData.self_control,10);
@@ -89,7 +81,9 @@
if (formData.helped !== undefined && formData.helped == 1){ if (formData.helped !== undefined && formData.helped == 1){
NoD += 1; NoD += 1;
} }
return game.vermine2047.VermineRoll.roll(data.actorId, data.label, NoD, Reroll, data); if (formData.abilityScore == 0){
alert('veuillez saisir une caractéristique');
} else return game.vermine2047.VermineRoll.roll(data.actorId, data.label, NoD, Reroll, data);
} }
}, },
close: { close: {
@@ -98,6 +92,19 @@
} }
}, },
render: function (h) { render: function (h) {
if( h.find('input[name="abilityScore"]').val()== 0 && data.rollType == 'ability'){
h.find('input[name="abilityScore"]').val(data.abilities[data.label].value);
}
h.find('select[name="ability"]').change((event) => {
if (event.target.value != undefined){
const abilityScore = data.abilities[event.target.value].value;
console.log('ability', abilityScore);
// on enregistre la valeur de la caractéristique
h.find('input[name="abilityScore"]').val(abilityScore);
}
});
h.find('select[name="skill"]').change((event) => { h.find('select[name="skill"]').change((event) => {
if (data.rollType == 'skill' && event.target.value != undefined){ if (data.rollType == 'skill' && event.target.value != undefined){
const skillScore = data.skills[event.target.value].value; const skillScore = data.skills[event.target.value].value;
+1 -1
View File
@@ -4,7 +4,7 @@ export class VermineRoll {
const actor = game.actors.get(actorId); const actor = game.actors.get(actorId);
let formula = '' + (parseInt(NoD,10) + parseInt(Reroll,10)) + "d10"; let formula = '' + (parseInt(NoD,10) + parseInt(Reroll,10)) + "d10";
if (Reroll > 0 && params.difficulty != undefined){ if (Reroll > 0 && params.difficulty != undefined){
formula += 'kh' + (parseInt(NoD,10) -1); formula += 'kh' + NoD;
} }
formula += (params.difficulty != undefined) ? "cs>" + params.difficulty : "cs>7"; formula += (params.difficulty != undefined) ? "cs>" + params.difficulty : "cs>7";
let roll = new Roll(formula, actor.getRollData()); let roll = new Roll(formula, actor.getRollData());
+1
View File
@@ -27,6 +27,7 @@
<div class="flexrow row mdb"> <div class="flexrow row mdb">
<label class="label" style="flex: 60%;">{{localize 'VERMINE.ability'}}</label> <label class="label" style="flex: 60%;">{{localize 'VERMINE.ability'}}</label>
<select class="info-value" style="max-width: 40%;" data-dtype="String" type="number" name="ability" id="ability" min="1" max="5"> <select class="info-value" style="max-width: 40%;" data-dtype="String" type="number" name="ability" id="ability" min="1" max="5">
{{#if (eq rollType 'skill')}}<option>-- Choisissez une caractéristique --</option>{{/if}}
{{#each abilities as |ability key| }} {{#each abilities as |ability key| }}
<option value="{{ key }}" {{#if (eq key @root.label)}}selected{{/if}}> {{ smarttl "ABILITIES" key }} - {{ ability.value }}</option> <option value="{{ key }}" {{#if (eq key @root.label)}}selected{{/if}}> {{ smarttl "ABILITIES" key }} - {{ ability.value }}</option>
{{/each}} {{/each}}