Foundry v13 migration
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { YggdrasillUtility } from "./yggdrasill-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class YggdrasillActorSheet extends ActorSheet {
|
||||
export class YggdrasillActorSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
@@ -25,7 +25,7 @@ export class YggdrasillActorSheet extends ActorSheet {
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = foundry.utils.duplicate(this.object)
|
||||
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: objectData.id,
|
||||
@@ -60,14 +60,14 @@ export class YggdrasillActorSheet extends ActorSheet {
|
||||
sortsSejdr:this.actor.getSortsSejdr(),
|
||||
sortsGaldr:this.actor.getSortsGaldr(),
|
||||
runes: this.actor.getRunes(),
|
||||
optionsCarac: YggdrasillUtility.createDirectOptionList(0, 20),
|
||||
optionsDMDP: YggdrasillUtility.createDirectSortedOptionList(-10, +10),
|
||||
optionsBase: YggdrasillUtility.createDirectOptionList(0, 20),
|
||||
optionsFuror: YggdrasillUtility.createDirectOptionList(0, 15),
|
||||
tiragerunes: await TextEditor.enrichHTML(this.object.system.tiragesrunes, {async: true}),
|
||||
description: await TextEditor.enrichHTML(this.object.system.description, {async: true}),
|
||||
notes: await TextEditor.enrichHTML(this.object.system.notes, {async: true}),
|
||||
gmnotes: await TextEditor.enrichHTML(this.object.system.biodata.gmnotes, {async: true}),
|
||||
optionsCarac: YggdrasillUtility.createDirectOptionList(0, 20),
|
||||
optionsDMDP: YggdrasillUtility.createDirectSortedOptionList(-10, +10),
|
||||
optionsBase: YggdrasillUtility.createDirectOptionList(0, 20),
|
||||
optionsFuror: YggdrasillUtility.createDirectOptionList(0, 15),
|
||||
tiragerunes: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.tiragesrunes, {async: true}),
|
||||
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.description, {async: true}),
|
||||
notes: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.notes, {async: true}),
|
||||
gmnotes: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.biodata.gmnotes, {async: true}),
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
editScore: this.options.editScore,
|
||||
@@ -113,11 +113,11 @@ updateDP( data ) {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
YggdrasillUtility.confirmDelete(this, li);
|
||||
});
|
||||
|
||||
|
||||
html.find('#isEpuise').click(event => {
|
||||
this.actor.toggleEpuise( );
|
||||
} );
|
||||
|
||||
|
||||
html.find('.munition-moins').click(event => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const item = this.actor.items.get(li.data("item-id"));
|
||||
@@ -159,29 +159,29 @@ updateDP( data ) {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const sortId = li.data("item-id");
|
||||
this.actor.rollSort(sortId, "sejdr");
|
||||
});
|
||||
});
|
||||
html.find('.sort-galdr').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const sortId = li.data("item-id");
|
||||
this.actor.rollSort(sortId, "galdr");
|
||||
});
|
||||
});
|
||||
html.find('.sort-rune').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const sortId = li.data("item-id");
|
||||
this.actor.rollSort(sortId, "rune");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
html.find('.arme-label a').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const armeId = li.data("arme-id");
|
||||
this.actor.rollArme(armeId);
|
||||
});
|
||||
});
|
||||
html.find('.carac-roll').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
let categ = li.data("carac-categ");
|
||||
let carac = li.data("carac-key");
|
||||
this.actor.rollCarac(categ, carac);
|
||||
});
|
||||
});
|
||||
html.find('.weapon-damage').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const weapon = this.actor.items.get(li.data("item-id"));
|
||||
@@ -195,12 +195,12 @@ updateDP( data ) {
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
this.options.editScore = !this.options.editScore;
|
||||
this.render(true);
|
||||
});
|
||||
});
|
||||
html.find('.item-link a').click((event) => {
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
const item = this.actor.items.get(itemId);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
});
|
||||
html.find('.item-equip').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.actor.equiperObject( li.data("item-id") );
|
||||
|
@@ -6,7 +6,7 @@
|
||||
import { YggdrasillUtility } from "./yggdrasill-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class YggdrasillFigurantSheet extends ActorSheet {
|
||||
export class YggdrasillFigurantSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
@@ -25,7 +25,7 @@ export class YggdrasillFigurantSheet extends ActorSheet {
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = foundry.utils.duplicate(this.object)
|
||||
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: objectData.id,
|
||||
@@ -41,9 +41,9 @@ export class YggdrasillFigurantSheet extends ActorSheet {
|
||||
encTotal: this.actor.getEncTotal(),
|
||||
monnaies: this.actor.getMonnaies(),
|
||||
optionsAttr: Array.fromRange(41, 1),
|
||||
optionsBase: YggdrasillUtility.createDirectOptionList(0, 20),
|
||||
description: await TextEditor.enrichHTML(this.object.system.description, {async: true}),
|
||||
notes: await TextEditor.enrichHTML(this.object.system.notes, {async: true}),
|
||||
optionsBase: YggdrasillUtility.createDirectOptionList(0, 20),
|
||||
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.description, {async: true}),
|
||||
notes: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.notes, {async: true}),
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
editScore: this.options.editScore,
|
||||
@@ -74,7 +74,7 @@ export class YggdrasillFigurantSheet extends ActorSheet {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
YggdrasillUtility.confirmDelete(this, li);
|
||||
});
|
||||
|
||||
|
||||
html.find('.equipement-moins').click(event => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
this.actor.decrementeQuantite( li.data("item-id") );
|
||||
@@ -89,16 +89,16 @@ export class YggdrasillFigurantSheet extends ActorSheet {
|
||||
let attrKey = li.data("attr-key");
|
||||
let attrSubKey = $(event.currentTarget).data("attr-sub-key");
|
||||
this.actor.rollAttribute(attrKey, attrSubKey);
|
||||
});
|
||||
});
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
this.options.editScore = !this.options.editScore;
|
||||
this.render(true);
|
||||
});
|
||||
});
|
||||
html.find('.item-link a').click((event) => {
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
const item = this.actor.items.get(itemId);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
});
|
||||
html.find('.item-equip').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.actor.equiperObject( li.data("item-id") );
|
||||
|
@@ -4,7 +4,7 @@ import { YggdrasillUtility } from "./yggdrasill-utility.js";
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class YggdrasillItemSheet extends ItemSheet {
|
||||
export class YggdrasillItemSheet extends foundry.appv1.sheets.ItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
@@ -26,7 +26,7 @@ export class YggdrasillItemSheet extends ItemSheet {
|
||||
{
|
||||
class: "post",
|
||||
icon: "fas fa-comment",
|
||||
onclick: ev => {}
|
||||
onclick: ev => {}
|
||||
})
|
||||
return buttons
|
||||
}
|
||||
@@ -40,11 +40,11 @@ export class YggdrasillItemSheet extends ItemSheet {
|
||||
sheetBody.css("height", bodyHeight);
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = foundry.utils.duplicate(this.object);
|
||||
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: objectData.id,
|
||||
@@ -56,7 +56,7 @@ export class YggdrasillItemSheet extends ItemSheet {
|
||||
data: foundry.utils.deepClone(this.object.system),
|
||||
optionsBase: YggdrasillUtility.createDirectOptionList(0, 20),
|
||||
optionsNiveaux4: Array.fromRange(5, 1),
|
||||
description: await TextEditor.enrichHTML(this.object.system.description, {async: true}),
|
||||
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.object.system.description, {async: true}),
|
||||
limited: this.object.limited,
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
@@ -65,7 +65,7 @@ export class YggdrasillItemSheet extends ItemSheet {
|
||||
}
|
||||
return formData;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
@@ -73,7 +73,7 @@ export class YggdrasillItemSheet extends ItemSheet {
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
@@ -85,9 +85,9 @@ export class YggdrasillItemSheet extends ItemSheet {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.object.options.actor.deleteEmbeddedDocuments( "Item", [li.data("item-id") ] ).then( this.render(true));
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
get template()
|
||||
{
|
||||
|
@@ -30,7 +30,7 @@ Hooks.once("init", async function () {
|
||||
YggdrasillUtility.preloadHandlebarsTemplates();
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Set an initiative formula for the system
|
||||
// Set an initiative formula for the system
|
||||
CONFIG.Combat.initiative = {
|
||||
formula: "1d20",
|
||||
decimals: 0
|
||||
@@ -52,22 +52,16 @@ Hooks.once("init", async function () {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("fvtt-yggdrasill", YggdrasillActorSheet, { types: ["personnage"], makeDefault: true });
|
||||
Actors.registerSheet("fvtt-yggdrasill", YggdrasillFigurantSheet, { types: ["figurant"], makeDefault: false });
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("fvtt-yggdrasill", YggdrasillItemSheet, { makeDefault: true });
|
||||
foundry.documents.collections.Actors.unregisterSheet("core", foundry.appv1.sheets.ActorSheet);
|
||||
foundry.documents.collections.Actors.registerSheet("fvtt-yggdrasill", YggdrasillActorSheet, { types: ["personnage"], makeDefault: true });
|
||||
foundry.documents.collections.Actors.registerSheet("fvtt-yggdrasill", YggdrasillFigurantSheet, { types: ["figurant"], makeDefault: false });
|
||||
foundry.documents.collections.Items.unregisterSheet("core", foundry.appv1.sheets.ItemSheet);
|
||||
foundry.documents.collections.Items.registerSheet("fvtt-yggdrasill", YggdrasillItemSheet, { makeDefault: true });
|
||||
|
||||
// Init/registers
|
||||
Hooks.on('renderChatLog', (log, html, data) => {
|
||||
//YggdrasillUtility.registerChatCallbacks(html);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
function welcomeMessage() {
|
||||
//ChatUtility.removeMyChatMessageContaining('<div id="welcome-message-sos">');
|
||||
ChatMessage.create({
|
||||
user: game.user.id,
|
||||
whisper: [game.user.id],
|
||||
|
@@ -11,24 +11,24 @@ export class YggdrasillRoll extends Dialog {
|
||||
let html
|
||||
let h = 440;
|
||||
if ( rollData.mode == "competence") {
|
||||
html = await renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-competence.html', rollData);
|
||||
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-competence.html', rollData);
|
||||
h = 340;
|
||||
} else if (rollData.mode == "carac") {
|
||||
html = await renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-carac.html', rollData);
|
||||
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-carac.html', rollData);
|
||||
h = 320;
|
||||
} else if (rollData.mode == "attribut") {
|
||||
html = await renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-attribut.html', rollData);
|
||||
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-attribut.html', rollData);
|
||||
h = 320;
|
||||
} else if (rollData.mode == "armecc") {
|
||||
html = await renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-armecc.html', rollData);
|
||||
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-armecc.html', rollData);
|
||||
} else if (rollData.mode == "sejdr") {
|
||||
html = await renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-sejdr.html', rollData);
|
||||
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-sejdr.html', rollData);
|
||||
} else if (rollData.mode == "rune") {
|
||||
html = await renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-rune.html', rollData);
|
||||
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-rune.html', rollData);
|
||||
} else if (rollData.mode == "galdr") {
|
||||
html = await renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-galdr.html', rollData);
|
||||
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-galdr.html', rollData);
|
||||
} else {
|
||||
html = await renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-armetir.html', rollData);
|
||||
html = await foundry.applications.handlebars.renderTemplate('systems/fvtt-yggdrasill/templates/roll-dialog-armetir.html', rollData);
|
||||
}
|
||||
let options = { classes: ["yggdrasilldialog"], width: 600, height: h, 'z-index': 99999 };
|
||||
return new YggdrasillRoll(actor, rollData, html, options );
|
||||
@@ -39,11 +39,11 @@ export class YggdrasillRoll extends Dialog {
|
||||
let conf = {
|
||||
title: (rollData.mode == "competence") ? "Compétence" : "Caractéristique",
|
||||
content: html,
|
||||
buttons: {
|
||||
buttons: {
|
||||
roll: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer le Test",
|
||||
callback: () => { this.roll() }
|
||||
callback: () => { this.roll() }
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
@@ -68,7 +68,7 @@ export class YggdrasillRoll extends Dialog {
|
||||
YggdrasillUtility.rollYggdrasill( this.rollData )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updateGaldrSR( ) {
|
||||
let sdDuree = Number(dureeGaldrSD[this.rollData.dureeGaldr]);
|
||||
@@ -88,12 +88,12 @@ export class YggdrasillRoll extends Dialog {
|
||||
let support = 0;
|
||||
|
||||
this.rollData.dureeRune = 6 - this.rollData.agiliteCarac.value;
|
||||
if ( this.rollData.supportRune == "peau") {
|
||||
if ( this.rollData.supportRune == "peau") {
|
||||
support = 3;
|
||||
this.rollData.echelleDuree = "Actions";
|
||||
this.rollData.echelleDureeVie = "Heures"
|
||||
}
|
||||
if ( this.rollData.supportRune == "tissu") {
|
||||
if ( this.rollData.supportRune == "tissu") {
|
||||
support = 6;
|
||||
this.rollData.echelleDuree = "Tours";
|
||||
this.rollData.echelleDureeVie = "Jours"
|
||||
@@ -156,12 +156,12 @@ export class YggdrasillRoll extends Dialog {
|
||||
$("#caracValue").text(carac.value+"d10");
|
||||
});
|
||||
|
||||
html.find('#typeAttack').change((event) => {
|
||||
html.find('#typeAttack').change((event) => {
|
||||
let attackType = event.currentTarget.value;
|
||||
let attackDef
|
||||
if ( this.rollData.mode == 'armecc')
|
||||
if ( this.rollData.mode == 'armecc')
|
||||
attackDef = this.actor.getAttaqueData( attackType);
|
||||
else
|
||||
else
|
||||
attackDef = this.actor.getTirData( attackType);
|
||||
this.rollData.attackDef = attackDef;
|
||||
this.rollData.selectedCarac = attackDef.carac;
|
||||
@@ -192,9 +192,9 @@ export class YggdrasillRoll extends Dialog {
|
||||
this.rollData.zoneGaldr = event.currentTarget.value;
|
||||
this.updateGaldrSR();
|
||||
});
|
||||
|
||||
|
||||
html.find('#bonusMalus').change((event) => {
|
||||
|
||||
|
||||
html.find('#bonusMalus').change((event) => {
|
||||
this.rollData.bonusMalus = Number(event.currentTarget.value);
|
||||
});
|
||||
html.find('#furorUsage').change((event) => {
|
||||
@@ -208,5 +208,5 @@ export class YggdrasillRoll extends Dialog {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user