Merge branch 'combat-extract' into 'dev_1.1'

Fixes suite aux test de combat

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!72
This commit is contained in:
Leratier Bretonnien 2020-12-15 07:33:59 +00:00
commit d1c9bfe4b0
10 changed files with 184 additions and 120 deletions

View File

@ -17,7 +17,6 @@ import { RdDRollTables } from "./rdd-rolltables.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { RdDItemSort } from "./item-sort.js"; import { RdDItemSort } from "./item-sort.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { RdDCalendrier } from "./rdd-calendrier.js";
import { RdDItemArme } from "./item-arme.js"; import { RdDItemArme } from "./item-arme.js";
import { RdDCombat } from "./rdd-combat.js"; import { RdDCombat } from "./rdd-combat.js";
@ -120,10 +119,16 @@ export class RdDActor extends Actor {
return this.data.data.compteurs.chance.value; return this.data.data.compteurs.chance.value;
} }
/* -------------------------------------------- */
getForceValue() { getForceValue() {
return this.data.data.carac.force ? this.data.data.carac.force.value : this.data.data.carac.reve.value; return this.data.data.carac.force ? this.data.data.carac.force.value : this.data.data.carac.reve.value;
} }
/* -------------------------------------------- */
getBonusDegat() {
return parseInt(this.data.data.attributs.plusdom.value);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getCompetence(compName) { getCompetence(compName) {
return RdDUtility.findCompetence(this.data.items, compName); return RdDUtility.findCompetence(this.data.items, compName);
@ -156,7 +161,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async performRoll(rollData, attacker = undefined) { async performRoll(rollData, attacker = undefined) {
rollData.demiSurprise = this.isDemiSurprise(); rollData.surprise = this.getSurprise();
// Manage weapon categories when parrying (cf. page 115 ) // Manage weapon categories when parrying (cf. page 115 )
if (rollData.arme && rollData.attackerRoll) { // Manage parade depending on weapon type, and change roll results if (rollData.arme && rollData.attackerRoll) { // Manage parade depending on weapon type, and change roll results
@ -240,13 +245,13 @@ export class RdDActor extends Actor {
let recul = await RdDResolutionTable.roll( 10, reculNiveau ); let recul = await RdDResolutionTable.roll( 10, reculNiveau );
let msg = ""; let msg = "";
if (recul.isSuccess) { if (recul.isSuccess) {
msg = "Jet de Recul réussi, aucun effet !"; msg = this.data.name + " - Jet de Recul réussi, aucun effet !";
} else { } else {
let chute = await RdDResolutionTable.roll( this.data.data.carac.agilite.value, reculNiveau ); let chute = await RdDResolutionTable.roll( this.data.data.carac.agilite.value, reculNiveau );
if ( !chute.isSuccess || recul.isETotal ) { if ( !chute.isSuccess || recul.isETotal ) {
msg = "Jet de Recul : Vous subissez le recul du coup, et vous chutez au sol ! Vous ne pouvez plus attaquer ce round."; msg = this.data.name + " - Jet de Recul : Vous subissez le recul du coup, et vous chutez au sol ! Vous ne pouvez plus attaquer ce round.";
} else { } else {
msg = "Jet de Recul : Vous subissez le recul du coup, et vous reculez de quelques mètres ! Vous ne pouvez plus attaquer ce round."; msg = this.data.name + " - Jet de Recul : Vous subissez le recul du coup, et vous reculez de quelques mètres ! Vous ne pouvez plus attaquer ce round.";
} }
} }
ChatMessage.create( {content: msg, ChatMessage.create( {content: msg,
@ -262,7 +267,7 @@ export class RdDActor extends Actor {
let quality = rolled.quality let quality = rolled.quality
console.log(">>> ROLL", rollData, rolled); console.log(">>> ROLL", rollData, rolled);
let xpmsg = RdDResolutionTable.buildXpMessage(rolled, rollData.finalLevel); this._appliquerAjoutExperience(rollData)
let resumeCompetence = (rollData.competence) ? rollData.competence.name : (rollData.diffLibre + rollData.diffConditions); let resumeCompetence = (rollData.competence) ? rollData.competence.name : (rollData.diffLibre + rollData.diffConditions);
let explications = "<br>Points de taches : " + rolled.ptTache + ", ajustement qualité: " + rolled.ptQualite; let explications = "<br>Points de taches : " + rolled.ptTache + ", ajustement qualité: " + rolled.ptQualite;
@ -296,9 +301,8 @@ export class RdDActor extends Actor {
ChatMessage.create( { content: "Vous avez attaqué en Rapidité. Ce cas n'est pas géré autmatiquement, donc suivez les directives de votre MJ pour gérer ce cas.", ChatMessage.create( { content: "Vous avez attaqué en Rapidité. Ce cas n'est pas géré autmatiquement, donc suivez les directives de votre MJ pour gérer ce cas.",
whisper: ChatMessage.getWhisperRecipients( this.name ) } ); whisper: ChatMessage.getWhisperRecipients( this.name ) } );
} }
rollData.domArmePlusDom = this._calculBonusDegats(rollData);
rollData.degats = new Roll("2d10").roll().total + rollData.domArmePlusDom; // Dégats totaux rollData.dmg = RdDCombat.calculBonusDegats(rollData, this);
rollData.loc = RdDUtility.getLocalisation();
if (target) if (target)
{ {
@ -306,7 +310,7 @@ export class RdDActor extends Actor {
defenseMsg = RdDUtility.buildDefenseChatCard(this, target, rollData); defenseMsg = RdDUtility.buildDefenseChatCard(this, target, rollData);
explications += "<br><strong>Cible</strong> : " + target.actor.data.name; explications += "<br><strong>Cible</strong> : " + target.actor.data.name;
} }
explications += "<br>Encaissement : " + rollData.degats + "<br>Localisation : " + rollData.loc.label; explications += "<br>Encaissement : " + rollData.degats + "<br>Localisation : " + rollData.dmg.loc.label;
} else { } else {
explications = "<br>Echec ! Pas de dégâts"; explications = "<br>Echec ! Pas de dégâts";
} }
@ -321,8 +325,7 @@ export class RdDActor extends Actor {
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + resumeCompetence + "</strong>" content: "<strong>Test : " + rollData.selectedCarac.label + " / " + resumeCompetence + "</strong>"
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat + "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
+ RdDResolutionTable.explain(rolled) + RdDResolutionTable.explain(rolled)
+ "<br><strong>" + quality + "</strong>" + explications
+ explications + xpmsg
} }
ChatUtility.chatWithRollMode(chatOptions, this.name) ChatUtility.chatWithRollMode(chatOptions, this.name)
@ -355,7 +358,6 @@ export class RdDActor extends Actor {
if (this.isEntiteCauchemar()) { if (this.isEntiteCauchemar()) {
return ''; return '';
} }
// TODO: gestion des conditions de demi-surprise
if ( this.data.data.sante.sonne.value) { if ( this.data.data.sante.sonne.value) {
return 'demi'; return 'demi';
} }
@ -379,26 +381,6 @@ export class RdDActor extends Actor {
return mortalite; return mortalite;
} }
/* -------------------------------------------- */
_calculBonusDegats(rollData) {
if ( rollData.arme.name.toLowerCase() == "esquive") return 0; // Specific case management
const dmgConditions = rollData.isCharge ? 2 : 0;
const dmgParticuliere = rollData.particuliereAttaque == 'force' ? 5 : 0;
const dmgArme = parseInt(rollData.arme.data.dommages);
const dmgPerso = this._calculBonusDegatsActor(rollData.selectedCarac.label, dmgArme);
return dmgArme + dmgPerso + dmgConditions + dmgParticuliere;
}
_calculBonusDegatsActor(caracName, dmgArme) {
const dmgPerso = parseInt(this.data.data.attributs.plusdom.value);
switch (caracName) {
case "Tir": return 0;
case "Lancer": return Math.max(0, Math.min(dmgArme, dmgPerso));
}
return dmgPerso;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async dormirChateauDormant() { async dormirChateauDormant() {
let message = { let message = {
@ -455,7 +437,7 @@ export class RdDActor extends Actor {
if (!retrograde) { if (!retrograde) {
return false; return false;
} }
mergeObject(retrograde, { "active": true, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": blessure.localisation }); mergeObject(retrograde, { "active": true, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "loc": blessure.loc });
} }
this._supprimerBlessure(blessure); this._supprimerBlessure(blessure);
return true; return true;
@ -463,7 +445,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
_supprimerBlessure(blessure) { _supprimerBlessure(blessure) {
mergeObject(blessure, { "active": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" }); mergeObject(blessure, { "active": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "loc": "" });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -509,18 +491,22 @@ export class RdDActor extends Actor {
whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ), whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ),
content : "Remise à neuf de " + this.name content : "Remise à neuf de " + this.name
}; };
const blessures = duplicate(this.data.data.blessures); if (this.data.data.blessures){
for (let listeBlessures of [blessures.legeres.liste, blessures.graves.liste, blessures.critiques.liste]) { const blessures = duplicate(this.data.data.blessures);
for (let blessure of listeBlessures) { for (let listeBlessures of [blessures.legeres.liste, blessures.graves.liste, blessures.critiques.liste]) {
this._supprimerBlessure(blessure); for (let blessure of listeBlessures) {
this._supprimerBlessure(blessure);
}
} }
await this.update( {"data.blessures": blessures } );
} }
await this.update( {"data.blessures": blessures } );
await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value); await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value);
await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value); await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value);
let fatigue = duplicate(this.data.data.sante.fatigue) if (this.data.data.sante.fatigue){
fatigue.value = 0; let fatigue = duplicate(this.data.data.sante.fatigue)
await this.update( {"data.sante.fatigue": fatigue } ); fatigue.value = 0;
await this.update( {"data.sante.fatigue": fatigue } );
}
ChatMessage.create( message ); ChatMessage.create( message );
} }
@ -1121,7 +1107,7 @@ export class RdDActor extends Actor {
blessure.premiers_soins = 0; blessure.premiers_soins = 0;
blessure.soins_complets = 0; blessure.soins_complets = 0;
blessure.jours = 0; blessure.jours = 0;
blessure.localisation = ""; blessure.loc = "";
} }
//console.log("Blessure update", bType, index, blessure, bList ); //console.log("Blessure update", bType, index, blessure, bList );
await this.update( { 'data.blessures': bList } ); await this.update( { 'data.blessures': bList } );
@ -1134,12 +1120,12 @@ export class RdDActor extends Actor {
blessure.premiers_soins = psoins; blessure.premiers_soins = psoins;
blessure.soins_complets = pcomplets; blessure.soins_complets = pcomplets;
blessure.jours = jours; blessure.jours = jours;
blessure.localisation = loc; blessure.loc = loc;
await this.update( { 'data.blessures': bList } ); await this.update( { 'data.blessures': bList } );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
manageBlessures( blessuresData ) manageBlessures( blessuresData )
{ {
// Fast exit // Fast exit
if ( this.data.type == 'entite') return; // Une entité n'a pas de blessures if ( this.data.type == 'entite') return; // Une entité n'a pas de blessures
@ -1555,6 +1541,9 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
ajustementAstrologique() { ajustementAstrologique() {
if (this.isCreature()) {
return 0;
}
// selon l'heure de naissance... // selon l'heure de naissance...
return game.system.rdd.calendrier.getAjustementAstrologique(this.data.data.heure); return game.system.rdd.calendrier.getAjustementAstrologique(this.data.data.heure);
} }
@ -1580,8 +1569,15 @@ export class RdDActor extends Actor {
let xp = Math.abs(rolled.finalLevel); let xp = Math.abs(rolled.finalLevel);
let xpCarac = Math.floor(xp / 2); // impair: arrondi inférieur en carac let xpCarac = Math.floor(xp / 2); // impair: arrondi inférieur en carac
xpCarac = Math.max(xpCarac, 1);
let xpComp = xp - xpCarac; let xpComp;
if (competenceName) {
xpComp = xp - xpCarac;
}
else {
xpComp = 0;
xpCarac = Math.max(xpCarac, 1);
}
if ( competenceName ) { if ( competenceName ) {
let competence = duplicate( RdDUtility.findCompetence( this.data.items, competenceName ) ); let competence = duplicate( RdDUtility.findCompetence( this.data.items, competenceName ) );
@ -1810,8 +1806,8 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
computeArmure( locData, domArmePlusDom ) computeArmure( locData, domArmePlusDom, arme = undefined ) {
{ // TODO: arc ignore armure
let protection = 0; let protection = 0;
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) {
@ -1839,28 +1835,32 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async encaisserDommages( attackerRoll, attacker = undefined ) { async encaisserDommages( attackerRoll, attacker = undefined ) {
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) { if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
return; return;
} }
console.log("encaisserDommages", attackerRoll ) console.log("encaisserDommages", attackerRoll )
const armure = this.computeArmure( attackerRoll.loc, attackerRoll.domArmePlusDom); const armure = this.computeArmure( attackerRoll.loc, attackerRoll.domArmePlusDom, attackerRoll.arme);
let degatsReel = attackerRoll.degats - armure;
let result = RdDUtility.computeBlessuresSante(degatsReel, attackerRoll.mortalite); const rollEncaissement = new Roll("2d10 + @dmg - @armure",{
dmg: attackerRoll.dmg.total,
armure: armure
}).roll();
RdDDice.show(rollEncaissement, )
let result = RdDUtility.computeBlessuresSante(rollEncaissement.total, attackerRoll.mortalite, attackerRoll.dmg.loc);
result.endurance = Math.max(result.endurance, -Number(this.data.data.sante.endurance.value)); result.endurance = Math.max(result.endurance, -Number(this.data.data.sante.endurance.value));
await this.santeIncDec("vie", result.vie); await this.santeIncDec("vie", result.vie);
await this.santeIncDec("endurance", result.endurance, (result.critiques > 0)); await this.santeIncDec("endurance", result.endurance, (result.critiques > 0));
result.locName = (attackerRoll.loc) ? attackerRoll.loc.label : "Corps";
this.manageBlessures(result); // Will upate the result table this.manageBlessures(result); // Will upate the result table
const blessureLegere = (result.legeres > 0 ? "une blessure légère" : ""); const blessureLegere = (result.legeres > 0 ? "une blessure légère" : "");
const blessureGrave = (result.graves > 0 ? "une blessure grave" : ""); const blessureGrave = (result.graves > 0 ? "une blessure grave" : "");
const blessureCritique = (result.critiques > 0 ? "une blessure critique" : ""); const blessureCritique = (result.critiques > 0 ? "une blessure critique" : "");
let commonMsg = { title: "Blessures !", content: this.data.name + " a encaissé : " + let commonMsg = {
"<br>Encaissement final : " + degatsReel + title: "Blessures !",
"<br>" + blessureLegere + blessureGrave + blessureCritique } roll: rollEncaissement ,
content: this.data.name + " a encaissé " + blessureLegere + blessureGrave + blessureCritique
}
let addonMsg = "<br>Et a perdu : <br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie"; let addonMsg = "<br>Et a perdu : <br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie";
if ( this.hasPlayerOwner ) { if ( this.hasPlayerOwner ) {
commonMsg.content += addonMsg; // Message pour tout le monde commonMsg.content += addonMsg; // Message pour tout le monde

View File

@ -46,7 +46,8 @@ export class RdDItemArme extends Item {
static armeUneOuDeuxMains(arme, aUneMain) { static armeUneOuDeuxMains(arme, aUneMain) {
arme.data.unemain = arme.data.unemain || !arme.data.deuxmains; arme.data.unemain = arme.data.unemain || !arme.data.deuxmains;
const uneOuDeuxMains = arme.data.unemain && arme.data.deuxmains; const uneOuDeuxMains = arme.data.unemain && arme.data.deuxmains;
if (arme.data.dommages.includes("/")) { // Sanity check const containsSlash = !Number.isInteger(arme.data.dommages) && arme.data.dommages.includes("/");
if (containsSlash) { // Sanity check
arme = duplicate(arme); arme = duplicate(arme);
const tableauDegats = arme.data.dommages.split("/"); const tableauDegats = arme.data.dommages.split("/");
@ -59,10 +60,7 @@ export class RdDItemArme extends Item {
arme.data.dommagesReels = Number(arme.data.dommages); arme.data.dommagesReels = Number(arme.data.dommages);
} }
if ( if (uneOuDeuxMains != containsSlash) {
(uneOuDeuxMains && !arme.data.dommages.includes("/")) ||
(!uneOuDeuxMains && arme.data.dommages.includes("/")))
{
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)"); ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)");
} }
return arme; return arme;

View File

@ -17,7 +17,7 @@ export class RdDCombat {
static createUsingTarget(attacker) { static createUsingTarget(attacker) {
const target = RdDCombat.getTarget(); const target = RdDCombat.getTarget();
if (target == undefined) { if (target == undefined) {
ui.notifications.warn("Vous devriez choisir une cible à attaquer!"); ui.notifications.warn("Vous devez choisir une seule cible à attaquer!");
} }
return this.create(attacker, target ? target.actor : undefined, target) return this.create(attacker, target ? target.actor : undefined, target)
} }
@ -112,11 +112,11 @@ export class RdDCombat {
let rollData = { let rollData = {
coupsNonMortels: false, coupsNonMortels: false,
competence: competence, competence: competence,
demiSurprise: this.attacker.isDemiSurprise() surprise: this.attacker.getSurprise()
}; };
if (this.attacker.isCreature()) { if (this.attacker.isCreature()) {
this._prepareRollDataCreature(rollData, competence); this._modifieRollDataCreature(rollData, competence);
} }
else { else {
// Usual competence // Usual competence
@ -125,11 +125,11 @@ export class RdDCombat {
return rollData; return rollData;
} }
_prepareRollDataCreature(rollData, competence) { _modifieRollDataCreature(rollData, competence) {
competence = duplicate(competence); competence = duplicate(competence);
competence.data.defaut_carac = "carac_creature"; competence.data.defaut_carac = "carac_creature";
competence.data.categorie = "creature"; competence.data.categorie = "creature";
rollData.competence = competence; rollData.competence = competence;
rollData.carac = { "carac_creature": { label: competence.name, value: competence.data.carac_value } }; rollData.carac = { "carac_creature": { label: competence.name, value: competence.data.carac_value } };
rollData.arme = { rollData.arme = {
@ -171,16 +171,13 @@ export class RdDCombat {
whisper: ChatMessage.getWhisperRecipients(this.attacker.name) whisper: ChatMessage.getWhisperRecipients(this.attacker.name)
}); });
} }
rollData.dmg = RdDCombat.calculBonusDegats(rollData, this.attacker);
rollData.domArmePlusDom = this.attacker._calculBonusDegats(rollData);
rollData.degats = new Roll("2d10").roll().total + rollData.domArmePlusDom; // Dégats totaux
rollData.loc = RdDUtility.getLocalisation();
if (this.target) { if (this.target) {
rollData.mortalite = this._calculMortaliteEncaissement(rollData); rollData.mortalite = this._calculMortaliteEncaissement(rollData);
explications += "<br><strong>Cible</strong> : " + this.defender.data.name; explications += "<br><strong>Cible</strong> : " + this.defender.data.name;
} }
explications += "<br>Encaissement : " + rollData.degats + "<br>Localisation : " + rollData.loc.label; explications += "<br>Encaissement à "+ Misc.toSignedString(rollData.dmg.total)+ " (" + rollData.dmg.loc.label+")";
// Save rollData for defender // Save rollData for defender
game.system.rdd.rollDataHandler[this.attackerId] = duplicate(rollData); game.system.rdd.rollDataHandler[this.attackerId] = duplicate(rollData);
@ -202,7 +199,7 @@ export class RdDCombat {
_messageDefenseur(rollData) { _messageDefenseur(rollData) {
console.log("RdDCombat._messageDefenseur", rollData, " / ", this.attacker, this.target, this.target.actor.isToken, this.attacker.data._id, rollData.competence.data.categorie); console.log("RdDCombat._messageDefenseur", rollData, " / ", this.attacker, this.target, this.target.actor.isToken, this.attacker.data._id, rollData.competence.data.categorie);
let content = "<strong>" + this.defender.name + "</strong> doit se défendre : <br><span class='chat-card-button-area'>"; let content = "<strong>" + this.defender.name + "</strong> doit se défendre :<span class='chat-card-button-area'>";
// parades // parades
let filterArmesParade = this._getFilterArmesParade(rollData.competence.data.categorie); let filterArmesParade = this._getFilterArmesParade(rollData.competence.data.categorie);
@ -216,8 +213,7 @@ export class RdDCombat {
} }
// encaisser // encaisser
content += "<br><a class='chat-card-button' id='encaisser-button' data-attackerId='" + this.attackerId + "' data-defenderTokenId='" + this.defenderTokenId + "'>Encaisser !</a>"; content += "<br><a class='chat-card-button' id='encaisser-button' data-attackerId='" + this.attackerId + "' data-defenderTokenId='" + this.defenderTokenId + "'>Encaisser à " + Misc.toSignedString(rollData.dmg.total) + " !</a>";
content += "</span>" content += "</span>"
let defense = { let defense = {
@ -271,12 +267,11 @@ export class RdDCombat {
_onAttaqueEchec(rollData) { _onAttaqueEchec(rollData) {
console.log("RdDCombat.onAttaqueEchec >>>", rollData); console.log("RdDCombat.onAttaqueEchec >>>", rollData);
let target = this._getTarget();
let chatOptions = { let chatOptions = {
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "</strong>" content: "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "</strong>"
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) + " / état : " + rollData.etat + "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) + " / état : " + rollData.etat
+ RdDResolutionTable.explain(rolled) + RdDResolutionTable.explain(rollData.rolled)
+ (target ? "<br><strong>Cible</strong> : " + this.defender.data.name : "") + (this.target ? "<br><strong>Cible</strong> : " + this.defender.data.name : "")
} }
ChatUtility.chatWithRollMode(chatOptions, this.attacker.name) ChatUtility.chatWithRollMode(chatOptions, this.attacker.name)
} }
@ -329,22 +324,22 @@ export class RdDCombat {
attackerRoll: attackerRoll, attackerRoll: attackerRoll,
competence: competence, competence: competence,
arme: arme.data, arme: arme.data,
demiSurprise: this.defender.isDemiSurprise(), surprise: this.defender.getSurprise(),
needSignificative: this._needSignificative(attackerRoll) || RdDItemArme.needParadeSignificative(armeAttaque, armeParade), needSignificative: this._needSignificative(attackerRoll) || RdDItemArme.needParadeSignificative(armeAttaque, armeParade),
needResist: this._needResist(armeAttaque, armeParade), needResist: this._needResist(armeAttaque, armeParade),
carac: this.defender.data.data.carac carac: this.defender.data.data.carac
}; };
if (isCreature) { if (isCreature) {
this._prepareRollDataCreature(rollData, competence); this._modifieRollDataCreature(rollData, competence);
} }
return rollData; return rollData;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_needSignificative(attackerRoll) { _needSignificative(attackerRoll) {
return attackerRoll.particuliereAttaque == 'finesse'; return attackerRoll.particuliereAttaque == 'finesse';
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_needResist(armeAttaque, armeParade) { _needResist(armeAttaque, armeParade) {
// Manage weapon categories when parrying (cf. page 115 ) // Manage weapon categories when parrying (cf. page 115 )
@ -399,10 +394,8 @@ export class RdDCombat {
async _onParadeEchec(rollData) { async _onParadeEchec(rollData) {
console.log("RdDCombat._onParadeEchec >>>", rollData); console.log("RdDCombat._onParadeEchec >>>", rollData);
let explications = "<br><strong>Parade échouée, encaissement !</strong>"; let explications = "<br><strong>Parade échouée, encaissement !</strong> ";
if (rollData.demiSurprise) { explications += this.descriptionSurprise(rollData.surprise);
explications += " Demi surprise!";
}
if (rollData.needSignificative) { if (rollData.needSignificative) {
explications += " Significative nécessaire!"; explications += " Significative nécessaire!";
} }
@ -452,13 +445,13 @@ export class RdDCombat {
diffLibre: attackerRoll.diffLibre, diffLibre: attackerRoll.diffLibre,
attackerRoll: attackerRoll, attackerRoll: attackerRoll,
competence: competence, competence: competence,
demiSurprise: this.defender.isDemiSurprise(), surprise: this.defender.getSurprise(),
needSignificative: this._needSignificative(attackerRoll), needSignificative: this._needSignificative(attackerRoll),
carac: this.defender.data.data.carac carac: this.defender.data.data.carac
}; };
if (this.defender.isCreature()) { if (this.defender.isCreature()) {
this._prepareRollDataCreature(rollData, competence); this._modifieRollDataCreature(rollData, competence);
} }
return rollData; return rollData;
} }
@ -497,10 +490,8 @@ export class RdDCombat {
async _onEsquiveEchec(rollData) { async _onEsquiveEchec(rollData) {
console.log("RdDCombat._onEsquiveEchec >>>", rollData); console.log("RdDCombat._onEsquiveEchec >>>", rollData);
let explications = "<br><strong>Esquive échouée, encaissement !</strong>"; let explications = "<br><strong>Esquive échouée, encaissement !</strong> ";
if (rollData.demiSurprise) { explications += RdDCombat.descriptionSurprise(rollData.surprise);
explications += " Demi surprise!";
}
if (rollData.needSignificative) { if (rollData.needSignificative) {
explications += " Significative nécessaire!"; explications += " Significative nécessaire!";
} }
@ -517,6 +508,7 @@ export class RdDCombat {
await this.defender.computeRecul(rollData, true); await this.defender.computeRecul(rollData, true);
this.encaisser(rollData.attackerRoll); this.encaisser(rollData.attackerRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
encaisser(attackerRoll) { encaisser(attackerRoll) {
// TODO: gestion message pour chance/encaissement // TODO: gestion message pour chance/encaissement
@ -569,4 +561,65 @@ export class RdDCombat {
return rolled.isSuccess; return rolled.isSuccess;
} }
/* -------------------------------------------- */
static calculBonusDegats(rollData, actor) {
let dmg = { total: 0, loc: RdDUtility.getLocalisation() };
if (rollData.arme.name.toLowerCase() == "esquive") {
// Specific case management
ui.notifications.warn("Calcul de bonus dégats sur eswquive")
return dmg;
}
dmg.dmgArme = RdDCombat._dmgArme(rollData);
dmg.ignoreArmure = 0; // TODO: calculer pour arcs et arbaletes, gérer pour lmes créatures
dmg.dmgTactique= RdDCombat._dmgTactique(rollData);
dmg.dmgParticuliere= RdDCombat._dmgParticuliere(rollData);
dmg.dmgSurprise= RdDCombat._dmgSurprise(rollData);
dmg.dmgActor = RdDCombat._dmgActor(actor.getBonusDegat(), rollData.selectedCarac.label, dmg.dmgArme);
dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere;
return dmg;
}
static _dmgArme(rollData) {
return parseInt(rollData.arme.data.dommages);
}
static _dmgActor(bonusDegat, categorie, dmgArme) {
switch (categorie) {
case "Tir": return 0;
case "Lancer": return Math.max(0, Math.min(dmgArme, bonusDegat));
}
return bonusDegat;
}
static _dmgTactique(rollData) {
return rollData.isCharge ? 2 : 0;
}
static _dmgParticuliere(rollData) {
return rollData.particuliereAttaque == 'force' ? 5 : 0;
}
static _dmgSurprise(rollData) {
if (rollData.surprise) {
switch (rollData.surprise) {
case 'demi': return 1;
case 'totale': return 10;
}
}
return 0;
}
/* -------------------------------------------- */
static descriptionSurprise(surprise) {
if (surprise) {
switch (surprise) {
case 'demi': return 'demi-surprise';
case 'totale': return 'surprise totale';
}
}
return '';
}
} }

View File

@ -40,7 +40,6 @@ const specialResults = [
{ part: 20, epart: 100, etotal: 100, min: 96, max: 100 } { part: 20, epart: 100, etotal: 100, min: 96, max: 100 }
]; ];
const reussites = [ const reussites = [
{ code: "etotal", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: true, ptTache: -4, ptQualite: -6, quality: "Echec total", condition: (target, roll) => roll >= target.etotal && roll <= 100 }, { code: "etotal", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: true, ptTache: -4, ptQualite: -6, quality: "Echec total", condition: (target, roll) => roll >= target.etotal && roll <= 100 },
{ code: "epart", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: false, ptTache: -2, ptQualite: -4, quality: "Echec particulier", condition: (target, roll) => (roll >= target.epart && roll < target.etotal) }, { code: "epart", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: false, ptTache: -2, ptQualite: -4, quality: "Echec particulier", condition: (target, roll) => (roll >= target.epart && roll < target.etotal) },
@ -149,19 +148,33 @@ export class RdDResolutionTable {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isEchec(rollData) { static isEchec(rollData) {
return rollData.demiSurprise ? !rollData.rolled.isSign : rollData.rolled.isEchec; switch (rollData.surprise) {
case 'demi': return !rollData.rolled.isSign;
case 'totale': return true;
}
return rollData.rolled.isEchec;
} }
/* -------------------------------------------- */
static isEchecTotal(rollData) { static isEchecTotal(rollData) {
return (rollData.demiSurprise && rollData.arme) ? rollData.rolled.isEchec : rollData.rolled.isETotal; if (rollData.arme && rollData.surprise == 'demi') {
return rollData.rolled.isEchec;
}
return rollData.rolled.isETotal;
} }
/* -------------------------------------------- */
static isParticuliere(rollData) { static isParticuliere(rollData) {
return (rollData.demiSurprise && rollData.arme) ? false : rollData.rolled.isPart; if (rollData.arme && rollData.surprise) {
return false;
}
return rollData.rolled.isPart;
} }
/* -------------------------------------------- */
static isReussite(rollData) { static isReussite(rollData) {
return rollData.demiSurprise ? rollData.rolled.isSign : rollData.rolled.isSuccess; switch (rollData.surprise) {
case 'demi': return rollData.rolled.isSign;
case 'totale': return false;
}
return rollData.rolled.isSuccess;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -33,12 +33,11 @@ export class RdDEncaisser extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
performEncaisser(html, mortalite = "mortel") { performEncaisser(html, mortalite = "mortel") {
const ajustement = Number(this.modifier);
const encaissement = new Roll("2d10").roll().total + ajustement;
this.actor.encaisserDommages({ this.actor.encaisserDommages({
degats: encaissement, dmg:{
domArmePlusDom: ajustement, total: Number(this.modifier),
loc: { result: 0, label: "Corps" }, loc: { result: 0, label: "Corps" },
},
mortalite: mortalite mortalite: mortalite
}); });
} }

View File

@ -325,10 +325,10 @@ export class RdDTMRDialog extends Dialog {
return; return;
} }
if (cellDescr.type == "lac" || cellDescr.type == "fleuve" || cellDescr.type == "marais") { if (cellDescr.type == "lac" || cellDescr.type == "fleuve" || cellDescr.type == "marais") {
// TODO: permettre de choisir la voie de draconic?
let draconic = this.actor.getBestDraconic(); let draconic = this.actor.getBestDraconic();
let carac = this.actor.getReveActuel(); let carac = this.actor.getReveActuel();
// TODO: ajouter l'état général?
const etatGeneral = this.actor.data.data.compteurs.etat.value const etatGeneral = this.actor.data.data.compteurs.etat.value
let difficulte = draconic.data.niveau - 7; let difficulte = draconic.data.niveau - 7;
let rolled = await RdDResolutionTable.roll(carac, difficulte); let rolled = await RdDResolutionTable.roll(carac, difficulte);
@ -357,7 +357,7 @@ export class RdDTMRDialog extends Dialog {
} }
if (rolled.isPart) { if (rolled.isPart) {
explication += "<br>Vous avez fait une Réussite Particulière"; explication += "<br>Vous avez fait une Réussite Particulière";
explication += RdDResolutionTable.buildXpMessage(rolled, difficulte); this.actor._appliquerAjoutExperience({ rolled: rolled, seletedCarac: {label: 'reve'}, competence: draconic.name })
msg2MJ += "<br>Et a fait une réussite particulière"; msg2MJ += "<br>Et a fait une réussite particulière";
} }

View File

@ -581,11 +581,12 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeBlessuresSante( degats, mortalite="mortel" ) { static computeBlessuresSante( degats, mortalite, loc) {
let encaissement = RdDUtility.selectEncaissement(degats, mortalite) let encaissement = RdDUtility.selectEncaissement(degats, mortalite)
let over20 = Math.max(degats - 20, 0); let over20 = Math.max(degats - 20, 0);
encaissement.endurance = - RdDUtility._evaluatePerte(encaissement.endurance, over20); encaissement.endurance = - RdDUtility._evaluatePerte(encaissement.endurance, over20);
encaissement.vie = - RdDUtility._evaluatePerte(encaissement.vie, over20); encaissement.vie = - RdDUtility._evaluatePerte(encaissement.vie, over20);
encaissement.locName = loc ? loc.label : "Corps";
return encaissement; return encaissement;
} }
@ -837,9 +838,9 @@ export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _handleMsgEncaisser(data) { static _handleMsgEncaisser(data) {
if (game.user.isGM) { // Seul le GM effectue l'encaissement sur la fiche if (game.user.isGM) { // Seul le GM effectue l'encaissement sur la fiche
let rollData = game.system.rdd.rollDataHandler[data.attackerId]; // Retrieve the rolldata from the store let attackerRoll = game.system.rdd.rollDataHandler[data.attackerId]; // Retrieve the rolldata from the store
let defenderToken = canvas.tokens.get(data.defenderTokenId); let defenderToken = canvas.tokens.get(data.defenderTokenId);
defenderToken.actor.encaisserDommages(rollData); defenderToken.actor.encaisserDommages(attackerRoll);
} }
} }

View File

@ -131,7 +131,7 @@
Jours <input class="blessures-soins" type="text" name='jours' data-dtype="number" value="{{this.jours}}" /> Jours <input class="blessures-soins" type="text" name='jours' data-dtype="number" value="{{this.jours}}" />
- -
Loc. <input class="blessures-soins" type="text" name='localisation' data-dtype="String" Loc. <input class="blessures-soins" type="text" name='localisation' data-dtype="String"
value="{{this.localisation}}" /> value="{{this.loc}}" />
</li> </li>
{{/each}} {{/each}}
</div> </div>
@ -149,7 +149,7 @@
Jours <input class="blessures-soins" type="text" name="jours" data-dtype="number" value="{{bless.jours}}" /> Jours <input class="blessures-soins" type="text" name="jours" data-dtype="number" value="{{bless.jours}}" />
- -
Loc. <input class="blessures-soins" type="text" name="localisation" data-dtype="String" Loc. <input class="blessures-soins" type="text" name="localisation" data-dtype="String"
value="{{bless.localisation}}" /> value="{{bless.loc}}" />
</li> </li>
{{/each}} {{/each}}
</div> </div>
@ -167,7 +167,7 @@
Jours <input class="blessures-soins" type="text" name="jours" data-dtype="number" value="{{bless.jours}}" /> Jours <input class="blessures-soins" type="text" name="jours" data-dtype="number" value="{{bless.jours}}" />
- -
Loc. <input class="blessures-soins" type="text" name="localisation" data-dtype="String" Loc. <input class="blessures-soins" type="text" name="localisation" data-dtype="String"
value="{{bless.localisation}}" /> value="{{bless.loc}}" />
</li> </li>
</li> </li>
{{/each}} {{/each}}

View File

@ -131,7 +131,7 @@
Jours <input class="blessures-soins" type="text" name='jours' data-dtype="number" value="{{this.jours}}" /> Jours <input class="blessures-soins" type="text" name='jours' data-dtype="number" value="{{this.jours}}" />
- -
Loc. <input class="blessures-soins" type="text" name='localisation' data-dtype="String" Loc. <input class="blessures-soins" type="text" name='localisation' data-dtype="String"
value="{{this.localisation}}" /> value="{{this.loc}}" />
</li> </li>
{{/each}} {{/each}}
</div> </div>
@ -149,7 +149,7 @@
Jours <input class="blessures-soins" type="text" name="jours" data-dtype="number" value="{{bless.jours}}" /> Jours <input class="blessures-soins" type="text" name="jours" data-dtype="number" value="{{bless.jours}}" />
- -
Loc. <input class="blessures-soins" type="text" name="localisation" data-dtype="String" Loc. <input class="blessures-soins" type="text" name="localisation" data-dtype="String"
value="{{bless.localisation}}" /> value="{{bless.loc}}" />
</li> </li>
{{/each}} {{/each}}
</div> </div>
@ -167,7 +167,7 @@
Jours <input class="blessures-soins" type="text" name="jours" data-dtype="number" value="{{bless.jours}}" /> Jours <input class="blessures-soins" type="text" name="jours" data-dtype="number" value="{{bless.jours}}" />
- -
Loc. <input class="blessures-soins" type="text" name="localisation" data-dtype="String" Loc. <input class="blessures-soins" type="text" name="localisation" data-dtype="String"
value="{{bless.localisation}}" /> value="{{bless.loc}}" />
</li> </li>
</li> </li>
{{/each}} {{/each}}

View File

@ -394,7 +394,7 @@
</li> </li>
<li> <li>
Loc. Loc.
<input class="blessures-soins" type="text" name="localisation" data-dtype="String" value="{{bless.localisation}}"/> <input class="blessures-soins" type="text" name="localisation" data-dtype="String" value="{{bless.loc}}"/>
</li> </li>
</ul> </ul>
</li> </li>
@ -426,7 +426,7 @@
</li> </li>
<li> <li>
Loc. Loc.
<input class="blessures-soins" type="text" name="localisation" data-dtype="String" value="{{bless.localisation}}"/> <input class="blessures-soins" type="text" name="localisation" data-dtype="String" value="{{bless.loc}}"/>
</li> </li>
</ul> </ul>
</li> </li>
@ -458,7 +458,7 @@
</li> </li>
<li> <li>
Loc. Loc.
<input class="blessures-soins" type="text" name="localisation" data-dtype="String" value="{{bless.localisation}}"/> <input class="blessures-soins" type="text" name="localisation" data-dtype="String" value="{{bless.loc}}"/>
</li> </li>
</ul> </ul>
</li> </li>