#87 - Init du premier round

This commit is contained in:
sladecraven 2021-02-04 16:35:22 +01:00
parent b2dab45646
commit ae03fabd9e
5 changed files with 63 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import { RdDRoll } from "./rdd-roll.js";
import { RdDRollTables } from "./rdd-rolltables.js";
import { ReglesOptionelles } from "./regles-optionelles.js";
/* -------------------------------------------- */
export class RdDCombat {
static init() {

View File

@ -97,6 +97,8 @@ const _patch_initiative = () => {
messageOptions
);
roll.toMessage(messageData, { rollMode, create: true });
RdDUtility.processPremierRoundInit( );
}
return this;
};

View File

@ -63,6 +63,26 @@ const tableCaracDerivee = {
32: { xp: 180, poids: "1501-2000", plusdom:+11, sconst: 10, sust: 17 }
}
/* -------------------------------------------- */
const premierRoundInit = [
{ type: 'competence', pattern: 'hast', init: 3.90},
{ type: 'competence', pattern: 'lance', init: 3.85},
{ type: 'arme', pattern: 'bâton', init: 3.80},
{ type: 'arme', pattern: 'double dragonne', init: 3.75},
{ type: 'arme', pattern: 'esparlongue', init: 3.70},
{ type: 'arme', pattern: 'pée dragonne', init: 3.65},
{ type: 'arme', pattern: 'bâtarde', init: 3.60},
{ type: 'arme', pattern: 'cyane', init: 3.55},
{ type: 'arme', pattern: 'sorde', init: 3.50},
{ type: 'arme', pattern: 'grande hache', init: 3.45},
{ type: 'arme', pattern: 'bataille', init: 3.40},
{ type: 'arme', pattern: 'gnome', init: 3.35},
{ type: 'arme', pattern: 'masse', init: 3.30},
{ type: 'arme', pattern: 'gourdin', init: 3.25},
{ type: 'competence', pattern: 'fléau', init: 3.20},
{ type: 'arme', pattern: 'dague', init: 3.15},
];
/* -------------------------------------------- */
function _buildAllSegmentsFatigue(max) {
const cycle = [5, 2, 4, 1, 3, 0];
@ -665,6 +685,37 @@ export class RdDUtility {
}
}
/* -------------------------------------------- */
static processPremierRoundInit() {
// Check if we have the whole init !
if ( game.user.isGM) {
let initDone = true;
for( let combatant of game.combat.data.combatants) {
if ( !combatant.initiative ) initDone = false;
}
if (initDone && game.combat.current.round == 1) { // Premier round !
for( let combatant of game.combat.data.combatants) {
let arme = combatant.initiativeData.arme;
//console.log("Parsed !!!", combatant, initDone, game.combat.current, arme);
if ( arme && arme.type == "arme" ) {
for (let initData of premierRoundInit) {
if ( ( initData == 'competence' && arme.data.competence.toLowerCase().includes(initData.pattern)) ||
(arme.name.toLowerCase().includes(initData.pattern)) ) {
let msg = `<h4>L'initiative de ${combatant.actor.name} a été modifiée !</h4>
<hr>
<div>
Etant donné son ${arme.name}, son initative pour ce premier round est désormais de ${initData.init}.
</div>`
ChatMessage.create( { content: msg } );
game.combat.setInitiative(combatant._id, initData.init);
}
}
}
}
}
}
}
/* -------------------------------------------- */
static rollInitiativeCompetence(combatantId, arme) {
const combatant = game.combat.getCombatant(combatantId);
@ -707,6 +758,8 @@ export class RdDUtility {
let malus = actor.getEtatGeneral(); // Prise en compte état général
// Cas des créatures et entités vs personnages
let rollFormula = initOffset + "+ ( (" + RdDUtility.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)";
// Garder la trace de l'arme/compétence utilisée pour l'iniative
combatant.initiativeData = { arme: arme } // pour reclasser l'init au round 0
game.combat.rollInitiative(combatantId, rollFormula);
}

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.3.13",
"version": "1.3.14",
"manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9",

View File

@ -0,0 +1,5 @@
<h4>L'initiative de {{alias}} a été modifiée !</h4>
<hr>
<div>
Etant donné son {{armeName}}, son initative pour ce premier round est désormais de {{initValue}}.
</div>