Cleanup et preparation Foundry v12

This commit is contained in:
2024-05-01 09:33:34 +02:00
parent 8f0bf91464
commit 85e0249822
173 changed files with 659 additions and 341 deletions

View File

@ -12,9 +12,7 @@ export class YggdrasillUtility {
const templatePaths = [
'systems/fvtt-yggdrasill/templates/actor-sheet.html',
'systems/fvtt-yggdrasill/templates/editor-notes-gm.html',
'systems/fvtt-yggdrasill/templates/hud-actor-attaque.html',
'systems/fvtt-yggdrasill/templates/hud-actor-sort.html'
'systems/fvtt-yggdrasill/templates/editor-notes-gm.html'
]
return loadTemplates(templatePaths);
}
@ -27,7 +25,14 @@ export class YggdrasillUtility {
}
return options;
}
/* -------------------------------------------- */
static createOptions( min, max) {
let options = [];
for(let i=min; i<=max; i++) {
options.push( {key:i, label: `${i}` } );
}
return options;
}
/* -------------------------------------------- */
static createDirectOptionList( min, max) {
let options = {};
@ -45,24 +50,15 @@ export class YggdrasillUtility {
}
return options;
}
/* -------------------------------------------- */
static buildSROptions( ) {
static buildListOptions(min, max) {
let options = ""
options += `<option value="0">Aucun</option>`
options += `<option value="5">Très Simple (5)</option>`
options += `<option value="7">Simple (7)</option>`
options += `<option value="10">Aisé (10)</option>`
options += `<option value="14">Moyen (14)</option>`
options += `<option value="19">Difficile (19)</option>`
options += `<option value="25">Trés Difficile (25)</option>`
options += `<option value="32">Exceptionnel (32)</option>`
options += `<option value="40">Légendaire (40)</option>`
options += `<option value="49">Divin (49)</option>`
for (let i = min; i <= max; i++) {
options += `<option value="${i}">${i}</option>`
}
return options;
}
/* -------------------------------------------- */
static onSocketMesssage( msg ) {
if( !game.user.isGM ) return; // Only GM
@ -92,7 +88,7 @@ export class YggdrasillUtility {
let maxTabMaxIndex = isFurorUsage ? nbDice : 2;
for (let i=0; i<nbDice; i++) {
rolls[i] = new Roll("1d10x10").roll( {async: false}) //+sumDice+"+"+rollData.furorUsage+"d10+"+niveauCompetence+"+"+rollData.finalBM).roll( { async: false} );
rolls[i] = await new Roll("1d10x10").roll( ) //+sumDice+"+"+rollData.furorUsage+"d10+"+niveauCompetence+"+"+rollData.finalBM).roll( { async: false} );
if ( i == nbDice-1 ) {
await this.showDiceSoNice(rolls[i], game.settings.get("core", "rollMode") );
} else {
@ -122,7 +118,7 @@ export class YggdrasillUtility {
let niveau = rollData.subAttr.value;
// Bonus/Malus total
rollData.finalBM = rollData.bonusMalus;
rollData.finalBM = Number(rollData.bonusMalus);
// Gestion cas blessé (malus de -3)
if ( rollData.isBlesse) { // Cas blesse : malus de -3
rollData.finalBM -= 3;
@ -132,15 +128,15 @@ export class YggdrasillUtility {
rollData.rawDices = results.rawDices
rollData.maxTab = results.maxTab
rollData.rolls = results.rolls
rollData.bonus = niveau + rollData.finalBM
rollData.bonus = niveau + Number(rollData.finalBM)
rollData.finalTotal = rollData.maxTab[0].value + rollData.maxTab[1].value;
rollData.finalTotal += rollData.bonus
rollData.finalTotal = Number(rollData.maxTab[0].value) + Number(rollData.maxTab[1].value);
rollData.finalTotal += Number(rollData.bonus)
// Compute total SR
rollData.srFinal = rollData.sr;
rollData.srFinal = Number(rollData.sr);
if ( rollData.bonusdefense ) {
rollData.srFinal += rollData.bonusdefense;
rollData.srFinal += Number(rollData.bonusdefense);
}
if ( rollData.srFinal > 0 ) {
isCritical = rollData.finalTotal >= rollData.srFinal*2;
@ -154,7 +150,7 @@ export class YggdrasillUtility {
// Dégats
if ( isSuccess && rollData.subAttr.degats ) {
rollData.degatsExplain = `Marge(${marge}) + Physique(${rollData.valuePhysique}) + 1d10`;
rollData.rollDegats = new Roll("1d10+"+marge+"+"+rollData.valuePhysique).roll( { async: false} );
rollData.rollDegats = await new Roll("1d10+"+marge+"+"+rollData.valuePhysique).roll( );
await this.showDiceSoNice(rollData.rollDegats, game.settings.get("core", "rollMode") );
rollData.degats = rollData.rollDegats.total;
}
@ -192,7 +188,7 @@ export class YggdrasillUtility {
}
// Bonus/Malus total
rollData.finalBM = rollData.bonusMalus;
rollData.finalBM = Number(rollData.bonusMalus);
if ( rollData.attackDef) {
rollData.finalBM -= rollData.attackDef.malus;
}
@ -226,7 +222,7 @@ export class YggdrasillUtility {
for (let i=0; i<rollData.furorUsage; i++) {
rollData.furorResult += rollData.furorMaxTab[i].value
}
rollData.finalTotal += rollData.furorResult + rollData.bonusTotal;
rollData.finalTotal += Number(rollData.furorResult) + Number(rollData.bonusTotal);
rollData.niveauCompetence = niveauCompetence
// Compute total SR
@ -270,7 +266,7 @@ export class YggdrasillUtility {
// Specific GALDR
if ( rollData.sort?.type == "sortgaldr" && rollData.isSuccess) {
let galdrRoll = new Roll( rollData.dureeGaldr.substring(0, rollData.dureeGaldr.length - 1) ).roll( { async: false} );
let galdrRoll = await new Roll( rollData.dureeGaldr.substring(0, rollData.dureeGaldr.length - 1) ).roll( );
await this.showDiceSoNice(galdrRoll, game.settings.get("core", "rollMode") );
rollData.dureeGaldrText = galdrRoll.total + " " + dureeGaldrText[rollData.dureeGaldr];
if ( rollData.sort.system.voie == "illusion") {
@ -310,7 +306,7 @@ export class YggdrasillUtility {
/* -------------------------------------------- */
static blindMessageToGM(chatOptions) {
let chatGM = duplicate(chatOptions);
let chatGM = foundry.utils.duplicate(chatOptions);
chatGM.whisper = this.getUsers(user => user.isGM);
chatGM.content = "Message aveugle de " + game.user.name + "<br>" + chatOptions.content;
console.log("blindMessageToGM", chatGM);