Add v12 support

This commit is contained in:
2024-05-23 11:36:03 +02:00
parent a716a3b3d1
commit bddf772c99
157 changed files with 568 additions and 511 deletions

View File

@@ -114,6 +114,28 @@ export class WastelandUtility {
static async ready() {
const skills = await WastelandUtility.loadCompendium("fvtt-wasteland.skills")
this.skills = skills.map(i => i.toObject())
game.system.wasteland.config.listeNiveauSkill = WastelandUtility.createDirectOptionList(0, 10)
game.system.wasteland.config.listeNiveauCreature = WastelandUtility.createDirectOptionList(0, 35)
game.system.wasteland.config.modificateurOptions = WastelandUtility.createArrayOptionList(-15, 15)
game.system.wasteland.config.pointsAmeOptions = WastelandUtility.createDirectOptionList(0, 20)
}
/* -------------------------------------------- */
static createDirectOptionList(min, max) {
let options = {};
for (let i = min; i <= max; i++) {
options[`${i}`] = `${i}`;
}
return options;
}
static createArrayOptionList(min, max) {
let options = [];
for (let i = min; i <= max; i++) {
options.push({key:`${i}`, label:`${i}`});
}
return options;
}
/* -------------------------------------------- */
@@ -142,7 +164,7 @@ export class WastelandUtility {
let rollData = message.getFlag("world", "wasteland-roll")
let actor = WastelandUtility.getActorFromRollData(rollData)
await actor.setPredilectionUsed(rollData.competence._id, predIdx)
rollData.competence = duplicate(actor.getCompetence(rollData.competence._id))
rollData.competence = foundry.utils.duplicate(actor.getCompetence(rollData.competence._id))
await WastelandUtility.rollWasteland(rollData)
})
}
@@ -152,9 +174,7 @@ export class WastelandUtility {
const templatePaths = [
'systems/fvtt-wasteland/templates/editor-notes-gm.html',
'systems/fvtt-wasteland/templates/partial-item-description.html',
'systems/fvtt-wasteland/templates/partial-list-niveau.html',
'systems/fvtt-wasteland/templates/partial-list-niveau-creature.html'
'systems/fvtt-wasteland/templates/partial-item-description.html'
]
return loadTemplates(templatePaths);
}
@@ -188,15 +208,6 @@ export class WastelandUtility {
return undefined;
}
/* -------------------------------------------- */
static createDirectOptionList(min, max) {
let options = {};
for (let i = min; i <= max; i++) {
options[`${i}`] = `${i}`;
}
return options;
}
/* -------------------------------------------- */
static buildListOptions(min, max) {
let options = ""
@@ -221,7 +232,7 @@ export class WastelandUtility {
let id = rollData.rollId;
let oldRollData = this.rollDataStore[id] || {};
let newRollData = mergeObject(oldRollData, rollData);
let newRollData = foundry.utils.mergeObject(oldRollData, rollData);
this.rollDataStore[id] = newRollData;
}
/* -------------------------------------------- */
@@ -293,10 +304,10 @@ export class WastelandUtility {
}
/* -------------------------------------------- */
static computeResult(rollData, actor) {
static async computeResult(rollData, actor) {
if (rollData.charme) {
let resultIndex = false
let resTab = duplicate(rollData.charme.system.resultats)
let resTab = foundry.utils.duplicate(rollData.charme.system.resultats)
for(let id in resTab) {
let res = resTab[id]
if (!resultIndex && rollData.finalResult >= res.value) {
@@ -306,7 +317,7 @@ export class WastelandUtility {
if (resultIndex) {
rollData.charmeDuree = rollData.charme.system.resultats[resultIndex].description
}
let effectRoll = new Roll(rollData.charmeDice).roll({ async: false })
let effectRoll = await new Roll(rollData.charmeDice).roll()
if (rollData.charme.system.charmetype == "tour") {
rollData.contrecoupResult = effectRoll.total
if (rollData.contrecoupResult % 2 == 1) {
@@ -350,7 +361,7 @@ export class WastelandUtility {
}
if (!rollData.attr) {
rollData.actionImg = "systems/fvtt-wasteland/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp"
rollData.attr = duplicate(actor.system.attributs[rollData.attrKey])
rollData.attr = foundry.utils.duplicate(actor.system.attributs[rollData.attrKey])
}
if (rollData.charme) {
@@ -367,7 +378,7 @@ export class WastelandUtility {
//console.log("BEFORE COMP", rollData)
if (rollData.competence) {
rollData.predilections = duplicate(rollData.competence.system.predilections.filter(pred => !pred.used) || [])
rollData.predilections = foundry.utils.duplicate(rollData.competence.system.predilections.filter(pred => !pred.used) || [])
let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.system.niveau}+${rollData.modificateur}+${compmod}`
} else {
@@ -377,14 +388,14 @@ export class WastelandUtility {
rollData.diceFormula += `+${rollData.arme.system.bonusmaniementoff}`
}
let myRoll = new Roll(rollData.diceFormula).roll({ async: false })
let myRoll = await new Roll(rollData.diceFormula).roll()
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = duplicate(myRoll)
rollData.roll = foundry.utils.duplicate(myRoll)
rollData.diceResult = myRoll.terms[0].results[0].result
console.log(">>>> ", myRoll)
rollData.finalResult = myRoll.total
this.computeResult(rollData, actor)
await this.computeResult(rollData, actor)
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-wasteland/templates/chat-generic-result.html`, rollData)
@@ -396,13 +407,13 @@ export class WastelandUtility {
static async bonusRollWasteland(rollData) {
rollData.bonusFormula = rollData.addedBonus
let bonusRoll = new Roll(rollData.bonusFormula).roll({ async: false })
let bonusRoll = await new Roll(rollData.bonusFormula).roll()
await this.showDiceSoNice(bonusRoll, game.settings.get("core", "rollMode"));
rollData.bonusRoll = duplicate(bonusRoll)
rollData.bonusRoll = foundry.utils.duplicate(bonusRoll)
rollData.finalResult += rollData.bonusRoll.total
this.computeResult(rollData)
await this.computeResult(rollData)
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-wasteland/templates/chat-generic-result.html`, rollData)
@@ -432,7 +443,7 @@ export class WastelandUtility {
/* -------------------------------------------- */
static blindMessageToGM(chatOptions) {
let chatGM = duplicate(chatOptions);
let chatGM = foundry.utils.duplicate(chatOptions);
chatGM.whisper = this.getUsers(user => user.isGM);
chatGM.content = "Blinde message of " + game.user.name + "<br>" + chatOptions.content;
console.log("blindMessageToGM", chatGM);
@@ -494,7 +505,7 @@ export class WastelandUtility {
/* -------------------------------------------- */
static getBasicRollData() {
let rollData = {
rollId: randomID(16),
rollId: foundry.utils.randomID(16),
rollMode: game.settings.get("core", "rollMode"),
modificateursOptions: this.getModificateurOptions(),
pointAmeOptions: this.getPointAmeOptions(),