Foundry v13 migration

This commit is contained in:
2025-05-02 00:00:24 +02:00
parent ee7f37878f
commit bb3a4fc5f7
186 changed files with 776 additions and 674 deletions

View File

@@ -1,26 +1,26 @@
/* -------------------------------------------- */
/* -------------------------------------------- */
/* -------------------------------------------- */
/* -------------------------------------------- */
const dureeGaldrText = { "1d5a": "Actions", "1d10t": "Tours", "1d10m": "Minutes", "1d10h": "Heures", "1d5j": "Jours"};
const ciblesGaldrText = { "1": "1", "2_4": "2 à 4", "5_9": "5 à 9", "10_49": "10 à 49", "50plus": "50 et plus"};
/* -------------------------------------------- */
/* -------------------------------------------- */
export class YggdrasillUtility {
/* -------------------------------------------- */
/* -------------------------------------------- */
static async preloadHandlebarsTemplates() {
const templatePaths = [
'systems/fvtt-yggdrasill/templates/actor-sheet.html',
'systems/fvtt-yggdrasill/templates/editor-notes-gm.html'
]
return loadTemplates(templatePaths);
return foundry.applications.handlebars.loadTemplates(templatePaths);
}
/* -------------------------------------------- */
static createDirectSortedOptionList( min, max) {
let options = [];
for(let i=min; i<=max; i++) {
for(let i=min; i<=max; i++) {
options.push( {value:i, text: `${i}` } );
}
return options;
@@ -28,7 +28,7 @@ export class YggdrasillUtility {
/* -------------------------------------------- */
static createOptions( min, max) {
let options = [];
for(let i=min; i<=max; i++) {
for(let i=min; i<=max; i++) {
options.push( {key:i, label: `${i}` } );
}
return options;
@@ -50,15 +50,7 @@ export class YggdrasillUtility {
}
return options;
}
/* -------------------------------------------- */
static buildListOptions(min, max) {
let options = ""
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
@@ -83,7 +75,7 @@ export class YggdrasillUtility {
/* -------------------------------------------- */
static async specificYggRoll( nbDice, isFurorUsage = false) {
let rawDices = []
let rolls = []
let rolls = []
let maxTab = []
let maxTabMaxIndex = isFurorUsage ? nbDice : 2;
@@ -99,10 +91,10 @@ export class YggdrasillUtility {
rolls.sort((a,b) => a.total-b.total);
rolls.reverse();
for (let i=0; i<maxTabMaxIndex; i++) {
maxTab[i] = {idx: 0, value: 0};
if (rolls[i].total != undefined) maxTab[i].value = rolls[i].total;
if (rolls[i]?.total != undefined) maxTab[i].value = rolls[i].total;
}
return { rawDices: rawDices, maxTab: maxTab, rolls: rolls }
@@ -114,7 +106,7 @@ export class YggdrasillUtility {
let isCritical = false;
let isFailure = false;
let isSuccess = false;
let marge = 0;
let marge = 0;
let niveau = rollData.subAttr.value;
// Bonus/Malus total
@@ -124,7 +116,7 @@ export class YggdrasillUtility {
rollData.finalBM -= 3;
}
let results = await this.specificYggRoll( 2 )
let results = await this.specificYggRoll( 2 )
rollData.rawDices = results.rawDices
rollData.maxTab = results.maxTab
rollData.rolls = results.rolls
@@ -132,13 +124,13 @@ export class YggdrasillUtility {
rollData.finalTotal = Number(rollData.maxTab[0].value) + Number(rollData.maxTab[1].value);
rollData.finalTotal += Number(rollData.bonus)
// Compute total SR
rollData.srFinal = Number(rollData.sr);
if ( rollData.bonusdefense ) {
rollData.srFinal += Number(rollData.bonusdefense);
}
if ( rollData.srFinal > 0 ) {
}
if ( rollData.srFinal > 0 ) {
isCritical = rollData.finalTotal >= rollData.srFinal*2;
isSuccess = rollData.finalTotal >= rollData.srFinal;
marge = rollData.finalTotal - rollData.srFinal;
@@ -151,7 +143,7 @@ export class YggdrasillUtility {
if ( isSuccess && rollData.subAttr.degats ) {
rollData.degatsExplain = `Marge(${marge}) + Physique(${rollData.valuePhysique}) + 1d10`;
rollData.rollDegats = await new Roll("1d10+"+marge+"+"+rollData.valuePhysique).roll( );
await this.showDiceSoNice(rollData.rollDegats, game.settings.get("core", "rollMode") );
await this.showDiceSoNice(rollData.rollDegats, game.settings.get("core", "rollMode") );
rollData.degats = rollData.rollDegats.total;
}
@@ -164,22 +156,22 @@ export class YggdrasillUtility {
console.log("ROLLLL ATTR!!!!", rollData);
this.createChatWithRollMode( rollData.alias, {
content: await renderTemplate(`systems/fvtt-yggdrasill/templates/chat-generic-result.html`, rollData)
content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-yggdrasill/templates/chat-generic-result.html`, rollData)
});
}
/* -------------------------------------------- */
static async rollYggdrasill( rollData ) {
let sumDice = ( rollData.isEpuise | rollData.isMeurtri) ? 1 : 2;
let sumDice = ( rollData.isEpuise | rollData.isMeurtri) ? 1 : 2;
// Init stuff
let isCritical = false;
let isFailure = false;
let isSuccess = false;
let marge = 0;
let marge = 0;
let nbDice = rollData.selectedCarac.value;
let niveauCompetence = 0;
// Select niveau de competence/arme/carac
if ( rollData.mode != "carac" ) {
niveauCompetence = rollData.competence.system.niveau;
@@ -192,23 +184,23 @@ export class YggdrasillUtility {
if ( rollData.attackDef) {
rollData.finalBM -= rollData.attackDef.malus;
}
if ( rollData.sort && rollData.sort.system.malus ) {
if ( rollData?.sort?.system?.malus ) {
rollData.finalBM += rollData.sort.system.malus;
}
// Gestion cas blessé (malus de -3)
if ( rollData.isBlesse) { // Cas blesse : malus de -3
rollData.finalBM -= 3;
}
if (sumDice > nbDice) sumDice = nbDice;
let results = await this.specificYggRoll( nbDice )
let results = await this.specificYggRoll( nbDice )
rollData.rawDices = results.rawDices
rollData.maxTab = results.maxTab
rollData.rolls = results.rolls
console.log("RES", results, nbDice, sumDice)
if ( rollData.furorUsage > 0 ) {
results = await this.specificYggRoll( rollData.furorUsage, true )
if ( rollData.furorUsage > 0 ) {
results = await this.specificYggRoll( rollData.furorUsage, true )
rollData.furorRawDices = results.rawDices
rollData.furorMaxTab = results.maxTab
rollData.furorRolls = results.rolls
@@ -229,9 +221,9 @@ export class YggdrasillUtility {
rollData.srFinal = rollData.sr;
if ( rollData.bonusdefense ) {
rollData.srFinal += rollData.bonusdefense;
}
if ( rollData.srFinal > 0 ) {
}
if ( rollData.srFinal > 0 ) {
isCritical = rollData.finalTotal >= rollData.srFinal*2;
isSuccess = rollData.finalTotal >= rollData.srFinal;
marge = rollData.finalTotal - rollData.srFinal;
@@ -245,7 +237,7 @@ export class YggdrasillUtility {
}
if (nbDice >= 3 ) {
let nbOnes = 0
for (let roll of rollData.rolls) {
for (let roll of rollData.rolls) {
if (roll.dice[0].results[0].result == 1 ) nbOnes++;
}
isFailure = nbOnes >= 3;
@@ -253,7 +245,7 @@ export class YggdrasillUtility {
// Dégats
if ( isSuccess && (rollData.mode == "armecc" || rollData.mode == "armedist") ) {
rollData.degatsExplain = `Marge(${marge}) + Degats Arme(${rollData.arme.system.degat}) + Bonus Attaque(${rollData.attackDef.bonusdegats})`;
rollData.degatsExplain = `Marge(${marge}) + Degats Arme(${rollData.arme.system.degat}) + Bonus Attaque(${rollData.attackDef.bonusdegats})`;
rollData.degats = marge + rollData.arme.system.degat + rollData.attackDef.bonusdegats;
}
@@ -339,7 +331,7 @@ export class YggdrasillUtility {
static createChatWithRollMode(name, chatOptions) {
this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions);
}
/* -------------------------------------------- */
static async confirmDelete(actorSheet, li) {
let itemId = li.data("item-id");
@@ -368,7 +360,7 @@ export class YggdrasillUtility {
d.render(true);
}
/* -------------------------------------------- */
static async showDiceSoNice(roll, rollMode) {
if (game.modules.get("dice-so-nice")?.active) {