Merge branch 'v1.4-report-master' into 'v1.4'

Demi-surprise: Réussite normale => échec #181

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!191
This commit is contained in:
Leratier Bretonnien 2021-04-04 06:50:26 +00:00
commit 4538472fc0
7 changed files with 55 additions and 46 deletions

View File

@ -146,6 +146,10 @@ export class RdDActorSheet extends ActorSheet {
montures: this.actor.listeMontures(), montures: this.actor.listeMontures(),
suivants: this.actor.listeSuivants() suivants: this.actor.listeSuivants()
} }
if (this.actor.getBestDraconic().data.niveau > -11 && !this.actor.isHautRevant()) {
ui.notifications.error(`${this.actor.name} a des compétences draconiques, mais pas le don de Haut-Rêve!
<br>Ajoutez-lui la tête "Don de Haut-Rêve" pour lui permettre d'utiliser ses compétences et d'accéder aux terres médianes du rêve`);
}
return formData; return formData;
} }

View File

@ -163,6 +163,10 @@ export class RdDActor extends Actor {
return this.data.type == 'personnage'; return this.data.type == 'personnage';
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
isHautRevant() {
return Misc.templateData(this).attributs.hautrevant.value != ""
}
/* -------------------------------------------- */
getFatigueActuelle() { getFatigueActuelle() {
if (!this.isPersonnage()) { if (!this.isPersonnage()) {
return 0; return 0;
@ -1044,7 +1048,6 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
computeEtatGeneral() { computeEtatGeneral() {
const actorData = Misc.data(this); const actorData = Misc.data(this);
console.info("computeEtatGeneral", actorData)
// Pas d'état général pour les entités forçage à 0 // Pas d'état général pour les entités forçage à 0
if (this.data.type == 'entite') { if (this.data.type == 'entite') {

View File

@ -160,7 +160,7 @@ export class RdDCombatManager extends Combat {
arme2main.data.mainInfo = "(2m)"; arme2main.data.mainInfo = "(2m)";
arme2main.data.dommages = arme2main.data.dommages.split("/")[1]; // Existence temporaire uniquement dans la liste des armes, donc OK arme2main.data.dommages = arme2main.data.dommages.split("/")[1]; // Existence temporaire uniquement dans la liste des armes, donc OK
arme2main.data.competence = arme2main.data.competence.replace(" 1 main", " 2 mains"); // Replace ! arme2main.data.competence = arme2main.data.competence.replace(" 1 main", " 2 mains"); // Replace !
let comp = competences.find(c => c.name == arme2main.data.competence); let comp = Misc.data(competences.find(c => c.name == arme2main.data.competence));
arme2main.data.niveau = comp.data.niveau; arme2main.data.niveau = comp.data.niveau;
arme2main.data.initiative = RdDCombatManager.calculInitiative(arme2main.data.niveau, carac[comp.data.defaut_carac].value); arme2main.data.initiative = RdDCombatManager.calculInitiative(arme2main.data.niveau, carac[comp.data.defaut_carac].value);
armesEquipe.push(arme2main); armesEquipe.push(arme2main);
@ -661,7 +661,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isEchecTotal(rollData) { static isEchecTotal(rollData) {
if (!rollData.attackerRoll && rollData.ajustements.surprise.used) { if (!rollData.attackerRoll && rollData.ajustements.surprise.used) {
return rollData.rolled.isEchec; return rollData.rolled.isEchec && rollData.rolled.code != 'notSign';
} }
return rollData.rolled.isETotal; return rollData.rolled.isETotal;
} }
@ -726,7 +726,6 @@ export class RdDCombat {
surpriseDefenseur: this.defender.getSurprise(true), surpriseDefenseur: this.defender.getSurprise(true),
essais: {} essais: {}
}; };
rollData.diviseurSignificative = this._getDiviseurSignificative(rollData);
if (this.attacker.isCreature()) { if (this.attacker.isCreature()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData); RdDItemCompetenceCreature.setRollDataCreature(rollData);
@ -969,7 +968,6 @@ export class RdDCombat {
carac: Misc.templateData(this.defender).carac, carac: Misc.templateData(this.defender).carac,
show: {} show: {}
}; };
defenderRoll.diviseurSignificative = this._getDiviseurSignificative(defenderRoll);
if (this.defender.isCreature()) { if (this.defender.isCreature()) {
RdDItemCompetenceCreature.setRollDataCreature(defenderRoll); RdDItemCompetenceCreature.setRollDataCreature(defenderRoll);
@ -978,24 +976,6 @@ export class RdDCombat {
return defenderRoll; return defenderRoll;
} }
/* -------------------------------------------- */
_getDiviseurSignificative(defenderRoll) {
let facteurSign = 1;
if (defenderRoll.surprise == 'demi') {
facteurSign *= 2;
}
if (defenderRoll.needParadeSignificative) {
facteurSign *= 2;
}
if (RdDBonus.isDefenseAttaqueFinesse(defenderRoll)) {
facteurSign *= 2;
}
if (!ReglesOptionelles.isUsing('tripleSignificative')) {
facteurSign = Math.min(facteurSign, 4);
}
return facteurSign;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
_onParadeParticuliere(defenderRoll) { _onParadeParticuliere(defenderRoll) {
console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll); console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
@ -1068,7 +1048,6 @@ export class RdDCombat {
carac: Misc.templateData(this.defender).carac, carac: Misc.templateData(this.defender).carac,
show: {} show: {}
}; };
rollData.diviseurSignificative = this._getDiviseurSignificative(rollData);
if (this.defender.isCreature()) { if (this.defender.isCreature()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData); RdDItemCompetenceCreature.setRollDataCreature(rollData);

View File

@ -51,10 +51,8 @@ const reussites = [
{ code: "error", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: true, ptTache: 0, ptQualite: 0, quality: "Jet de dés invalide", condition: (target, roll) => (roll <= 0 || roll > 100) } { code: "error", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: true, ptTache: 0, ptQualite: 0, quality: "Jet de dés invalide", condition: (target, roll) => (roll <= 0 || roll > 100) }
]; ];
const reussiteInsuffisante = { code: "notSign", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: false, isETotal: false, ptTache: 0, ptQualite: -2, quality: "Réussite insuffisante", condition: (target, roll) => false }
/* -------------------------------------------- */ /* -------------------------------------------- */
const reussiteSignificative = reussites.find(r => r.code == "sign");
const reussiteNormale = reussites.find(r => r.code == "norm");
const echecNormal = reussites.find(r => r.code == "echec");
const caracMaximumResolution = 60; const caracMaximumResolution = 60;
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDResolutionTable { export class RdDResolutionTable {
@ -115,7 +113,7 @@ export class RdDResolutionTable {
this._updateChancesFactor(chances, diviseur); this._updateChancesFactor(chances, diviseur);
chances.showDice = showDice; chances.showDice = showDice;
let rolled = await this.rollChances(chances); let rolled = await this.rollChances(chances, diviseur);
rolled.caracValue = caracValue; rolled.caracValue = caracValue;
rolled.finalLevel = finalLevel; rolled.finalLevel = finalLevel;
rolled.bonus = bonus; rolled.bonus = bonus;
@ -150,12 +148,12 @@ export class RdDResolutionTable {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async rollChances(chances) { static async rollChances(chances, diviseur) {
let myRoll = new Roll("1d100").evaluate( {async: false} ); let myRoll = new Roll("1d100").evaluate( {async: false} );
myRoll.showDice = chances.showDice; myRoll.showDice = chances.showDice;
await RdDDice.show(myRoll); await RdDDice.show(myRoll);
chances.roll = myRoll.total; chances.roll = myRoll.total;
mergeObject(chances, this.computeReussite(chances, chances.roll), { overwrite: true }); mergeObject(chances, this.computeReussite(chances, chances.roll, diviseur), { overwrite: true });
return chances; return chances;
} }
@ -216,8 +214,12 @@ export class RdDResolutionTable {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeReussite(chances, roll) { static computeReussite(chances, roll, diviseur) {
return reussites.find(x => x.condition(chances, roll)); const reussite = reussites.find(x => x.condition(chances, roll));
if (diviseur > 1 && reussite.code == 'norm') {
return reussiteInsuffisante;
}
return reussite;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -269,23 +271,23 @@ export class RdDResolutionTable {
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildHTMLResults(caracValue, levelValue) { static buildHTMLResults(caracValue, levelValue) {
if ( caracValue == undefined || isNaN(caracValue )) caracValue = 10; if (caracValue == undefined || isNaN(caracValue)) caracValue = 10;
if ( levelValue == undefined || isNaN(levelValue )) levelValue = 0; if (levelValue == undefined || isNaN(levelValue)) levelValue = 0;
let cell = this.computeChances(caracValue, levelValue); let cell = this.computeChances(caracValue, levelValue);
cell.epart = cell.epart > 99 ? 'N/A' : cell.epart; cell.epart = cell.epart > 99 ? 'N/A' : cell.epart;
cell.etotal = cell.etotal > 100 ? 'N/A' : cell.etotal; cell.etotal = cell.etotal > 100 ? 'N/A' : cell.etotal;
cell.score = Math.min(cell.score, 99); cell.score = Math.min(cell.score, 99);
return ` return `
<span class="table-proba-reussite competence-label"> <span class="table-proba-reussite competence-label">
Particulière: <span class="rdd-roll-part">${cell.part}</span> Particulière: <span class="rdd-roll-part">${cell.part}</span>
- Significative: <span class="rdd-roll-sign">${cell.sign}</span> - Significative: <span class="rdd-roll-sign">${cell.sign}</span>
- Réussite: <span class="rdd-roll-norm">${cell.score}</span> - Réussite: <span class="rdd-roll-norm">${cell.score}</span>
- Echec Particulier: <span class="rdd-roll-epart">${cell.epart}</span> - Echec Particulier: <span class="rdd-roll-epart">${cell.epart}</span>
- Echec Total: <span class="rdd-roll-etotal">${cell.etotal}</span> - Echec Total: <span class="rdd-roll-etotal">${cell.etotal}</span>
</span> </span>
` `
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -7,6 +7,7 @@ import { Misc } from "./misc.js";
import { RdDBonus } from "./rdd-bonus.js"; import { RdDBonus } from "./rdd-bonus.js";
import { RdDCarac } from "./rdd-carac.js"; import { RdDCarac } from "./rdd-carac.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { ReglesOptionelles } from "./regles-optionelles.js";
/** /**
* Extend the base Dialog entity to select roll parameters * Extend the base Dialog entity to select roll parameters
@ -63,14 +64,33 @@ export class RdDRoll extends Dialog {
surprise: actor.getSurprise(false), surprise: actor.getSurprise(false),
canClose: true canClose: true
}; };
mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false }); mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false });
if (rollData.forceCarac) { if (rollData.forceCarac) {
rollData.carac = rollData.forceCarac; rollData.carac = rollData.forceCarac;
} }
rollData.diviseurSignificative = RdDRoll.getDiviseurSignificative(rollData);
RollDataAjustements.calcul(rollData, actor); RollDataAjustements.calcul(rollData, actor);
} }
/* -------------------------------------------- */
static getDiviseurSignificative(rollData) {
let facteurSign = 1;
if (rollData.surprise == 'demi') {
facteurSign *= 2;
}
if (rollData.needParadeSignificative) {
facteurSign *= 2;
}
if (RdDBonus.isDefenseAttaqueFinesse(rollData)) {
facteurSign *= 2;
}
if (!ReglesOptionelles.isUsing('tripleSignificative')) {
facteurSign = Math.min(facteurSign, 4);
}
return facteurSign;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static _ensureCorrectActions(actions) { static _ensureCorrectActions(actions) {
@ -122,7 +142,6 @@ export class RdDRoll extends Dialog {
await RdDResolutionTable.rollData(this.rollData); await RdDResolutionTable.rollData(this.rollData);
console.log("RdDRoll -=>", this.rollData, this.rollData.rolled); console.log("RdDRoll -=>", this.rollData, this.rollData.rolled);
this.actor.setRollWindowsOpened(false); this.actor.setRollWindowsOpened(false);
if (action.callbacks) if (action.callbacks)
for (let callback of action.callbacks) { for (let callback of action.callbacks) {
if (callback.condition == undefined || callback.condition(this.rollData)) { if (callback.condition == undefined || callback.condition(this.rollData)) {

View File

@ -406,7 +406,7 @@ table {border: 1px solid #7a7971;}
border-radius: 6px; padding: 3px; border-radius: 6px; padding: 3px;
background:linear-gradient(30deg, rgba(7, 76, 0, 0.3), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.1), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.3)); background:linear-gradient(30deg, rgba(7, 76, 0, 0.3), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.1), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.3));
} }
.rdd-roll-echec{ .rdd-roll-notSign, .rdd-roll-echec{
border-radius: 6px; padding: 3px; border-radius: 6px; padding: 3px;
background-image: linear-gradient(150deg, rgba(255, 0, 0, 0.3), rgba(255, 200, 128, 0.05),rgba(255, 200, 128, 0.1), rgba(255,10,0,0.3)); background-image: linear-gradient(150deg, rgba(255, 0, 0, 0.3), rgba(255, 200, 128, 0.05),rgba(255, 200, 128, 0.1), rgba(255,10,0,0.3));
} }

View File

@ -557,6 +557,8 @@
<div> <div>
{{#if data.attributs.hautrevant.value}} {{#if data.attributs.hautrevant.value}}
<h3>Haut rêvant</h3> <h3>Haut rêvant</h3>
{{else}}
<h3>Vous n'avez pas le don de haut-rêve!</h3>
{{/if}} {{/if}}
<ul class="item-list"> <ul class="item-list">
{{#if data.attributs.hautrevant.value}} {{#if data.attributs.hautrevant.value}}