Ajout fenetre de roll + gestion de base des rolls
This commit is contained in:
@@ -27,7 +27,7 @@ export class MournbladeActorSheet extends ActorSheet {
|
||||
async getData() {
|
||||
const objectData = MournbladeUtility.data(this.object);
|
||||
|
||||
let actorData = duplicate(MournbladeUtility.templateData(this.object));
|
||||
let actorData = duplicate(MournbladeUtility.templateData(this.object))
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
@@ -64,10 +64,6 @@ export class MournbladeActorSheet extends ActorSheet {
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
html.bind("keydown", function(e) { // Ignore Enter in actores sheet
|
||||
if (e.keyCode === 13) return false;
|
||||
});
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
@@ -81,64 +77,6 @@ export class MournbladeActorSheet extends ActorSheet {
|
||||
MournbladeUtility.confirmDelete(this, li);
|
||||
});
|
||||
|
||||
html.find('.spec-group-activate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
this.actor.specPowerActivate( itemId)
|
||||
});
|
||||
html.find('.spec-group-deactivate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
this.actor.specPowerDeactivate( itemId)
|
||||
});
|
||||
|
||||
html.find('.equip-activate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
this.actor.equipActivate( itemId)
|
||||
});
|
||||
html.find('.equip-deactivate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
this.actor.equipDeactivate( itemId)
|
||||
});
|
||||
|
||||
html.find('.effect-used').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
this.actor.perkEffectUsed( itemId)
|
||||
});
|
||||
|
||||
html.find('.perk-status').change(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
this.actor.updatePerkStatus( itemId, ev.currentTarget.value)
|
||||
});
|
||||
html.find('.power-cost-spent').change(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
this.actor.updatePowerSpentCost( itemId, ev.currentTarget.value)
|
||||
});
|
||||
html.find('.perk-used').change(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
let index = Number($(ev.currentTarget).data("use-index") )
|
||||
this.actor.updatePerkUsed( itemId, index, ev.currentTarget.checked )
|
||||
});
|
||||
|
||||
html.find('.subactor-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let actorId = li.data("actor-id");
|
||||
let actor = game.actors.get( actorId );
|
||||
actor.sheet.render(true);
|
||||
});
|
||||
|
||||
html.find('.subactor-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let actorId = li.data("actor-id");
|
||||
this.actor.delSubActor(actorId);
|
||||
});
|
||||
|
||||
html.find('.quantity-minus').click(event => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
this.actor.incDecQuantity( li.data("item-id"), -1 );
|
||||
@@ -148,49 +86,16 @@ export class MournbladeActorSheet extends ActorSheet {
|
||||
this.actor.incDecQuantity( li.data("item-id"), +1 );
|
||||
} );
|
||||
|
||||
html.find('.unarmed-attack').click((event) => {
|
||||
this.actor.rollUnarmedAttack();
|
||||
html.find('.roll-attribut').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
let attrKey = li.data("attr-key")
|
||||
this.actor.rollAttribut(attrKey)
|
||||
});
|
||||
html.find('.generic-pool-roll').click((event) => {
|
||||
this.openGenericRoll()
|
||||
} );
|
||||
html.find('.attack-melee').click((event) => {
|
||||
this.actor.rollPool( 'com');
|
||||
});
|
||||
html.find('.attack-ranged').click((event) => {
|
||||
this.actor.rollPool( 'agi');
|
||||
});
|
||||
html.find('.defense-roll').click((event) => {
|
||||
this.actor.rollPool( 'def', true);
|
||||
});
|
||||
html.find('.damage-melee').click((event) => {
|
||||
this.actor.rollPool( 'str');
|
||||
});
|
||||
html.find('.damage-ranged').click((event) => {
|
||||
this.actor.rollPool( 'per');
|
||||
});
|
||||
html.find('.damage-resistance').click((event) => {
|
||||
this.actor.rollPool( 'phy');
|
||||
});
|
||||
|
||||
html.find('.roll-stat').click((event) => {
|
||||
const statId = $(event.currentTarget).data("stat-key");
|
||||
this.actor.rollStat(statId);
|
||||
});
|
||||
html.find('.roll-mr').click((event) => {
|
||||
this.actor.rollMR();
|
||||
});
|
||||
|
||||
html.find('.roll-spec').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const specId = li.data("item-id");
|
||||
this.actor.rollSpec(specId);
|
||||
});
|
||||
html.find('.power-roll').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const powerId = li.data("item-id");
|
||||
this.actor.rollPower(powerId);
|
||||
});
|
||||
html.find('.weapon-roll').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const weaponId = li.data("item-id");
|
||||
@@ -208,49 +113,15 @@ export class MournbladeActorSheet extends ActorSheet {
|
||||
this.actor.rollWeapon(weaponId, true);
|
||||
});
|
||||
|
||||
html.find('.weapon-damage').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const weapon = this.actor.getOwnedItem(li.data("item-id"));
|
||||
this.actor.rollDamage(weapon, 'damage');
|
||||
});
|
||||
|
||||
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.getOwnedItem(itemId);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
html.find('.item-equip').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.actor.equipItem( li.data("item-id") );
|
||||
this.render(true);
|
||||
});
|
||||
html.find('.power-activate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.actor.activatePower( li.data("item-id") );
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
html.find('.change-worstfear').change(ev => {
|
||||
this.actor.manageWorstFear( ev.currentTarget.checked )
|
||||
});
|
||||
html.find('.change-desires').change(ev => {
|
||||
this.actor.manageDesires( ev.currentTarget.checked )
|
||||
});
|
||||
|
||||
html.find('.update-field').change(ev => {
|
||||
const fieldName = $(ev.currentTarget).data("field-name");
|
||||
let value = Number(ev.currentTarget.value);
|
||||
this.actor.update( { [`${fieldName}`]: value } );
|
||||
});
|
||||
html.find('.perk-active').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.actor.activatePerk( li.data("item-id") );
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,6 @@ export class MournbladeActor extends Actor {
|
||||
super._preUpdate(changed, options, user);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getActivePerks() {
|
||||
let perks = this.data.items.filter(item => item.type == 'perk' && item.data.data.active);
|
||||
return perks;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getItemById(id) {
|
||||
let item = this.data.items.find(item => item.id == id);
|
||||
@@ -117,7 +112,7 @@ export class MournbladeActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAttribute(attrKey) {
|
||||
return this.data.data.attributes[attrKey];
|
||||
return this.data.data.attributes[attrKey]
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -164,38 +159,30 @@ export class MournbladeActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData(statKey = undefined, useShield = false) {
|
||||
getCommonRollData(attrKey = undefined, compKey = undefined) {
|
||||
let rollData = MournbladeUtility.getBasicRollData()
|
||||
rollData.alias = this.name
|
||||
rollData.actorImg = this.img
|
||||
rollData.actorId = this.id
|
||||
rollData.img = this.img
|
||||
rollData.activePerks = duplicate(this.getActivePerks())
|
||||
|
||||
if (statKey) {
|
||||
rollData.statKey = statKey
|
||||
rollData.stat = this.getStat(statKey)
|
||||
rollData.statDicesLevel = rollData.stat.value
|
||||
rollData.statMod = rollData.stat.mod
|
||||
rollData.specList = this.getRelevantSpec(statKey)
|
||||
rollData.selectedSpec = "0"
|
||||
if (attrKey) {
|
||||
rollData.attrKey = attrKey
|
||||
rollData.attr = duplicate(this.data.data.attributs[attrKey])
|
||||
}
|
||||
if (compKey) {
|
||||
rollData.compKey = compKey
|
||||
// TODO!
|
||||
}
|
||||
|
||||
this.addEffects(rollData)
|
||||
this.addArmorsShields(rollData, statKey, useShield)
|
||||
this.addWeapons(rollData, statKey, useShield)
|
||||
this.addEquipments(rollData, statKey)
|
||||
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async startRoll(rollData) {
|
||||
this.syncRoll(rollData);
|
||||
//console.log("ROLL DATA", rollData)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData);
|
||||
console.log(rollDialog);
|
||||
rollDialog.render(true);
|
||||
async rollAttribut(attrKey) {
|
||||
let rollData = this.getCommonRollData(attrKey)
|
||||
console.log("RollDatra", rollData)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,22 @@ export class MournbladeRollDialog extends Dialog {
|
||||
/* -------------------------------------------- */
|
||||
constructor(actor, rollData, html, options, close = undefined) {
|
||||
let conf = {
|
||||
title: (rollData.mode == "skill") ? "Skill" : "Roll",
|
||||
title: "Test de Capacité",
|
||||
content: html,
|
||||
buttons: {
|
||||
roll: {
|
||||
rolld10: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Roll !",
|
||||
callback: () => { this.roll() }
|
||||
label: "Lancer 1d10",
|
||||
callback: () => { this.roll("1d10") }
|
||||
},
|
||||
rolld20: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer 1d20",
|
||||
callback: () => { this.roll("1d20") }
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Cancel",
|
||||
label: "Annuler",
|
||||
callback: () => { this.close() }
|
||||
} },
|
||||
close: close
|
||||
@@ -32,148 +37,17 @@ export class MournbladeRollDialog extends Dialog {
|
||||
|
||||
super(conf, options);
|
||||
|
||||
this.actor = actor;
|
||||
this.rollData = rollData;
|
||||
this.actor = actor
|
||||
this.rollData = rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
roll () {
|
||||
roll ( dice) {
|
||||
this.rollData.mainDice = dice
|
||||
MournbladeUtility.rollMournblade( this.rollData )
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
manageEffects( effectIdx, toggled) {
|
||||
let effect = this.rollData.effectsList[effectIdx]
|
||||
if (effect) {
|
||||
effect.applied = toggled
|
||||
|
||||
let level, genre, idVal
|
||||
if (effect.type == 'hindrance' ) {
|
||||
level = effect.value
|
||||
genre = 'positive'
|
||||
idVal = "#hindranceDicesLevel"
|
||||
}
|
||||
if (effect.type == 'effect' ) {
|
||||
let effectData = effect.effect
|
||||
level = effectData.data.effectlevel
|
||||
genre = effectData.data.genre
|
||||
effectData.data.isUsed = toggled
|
||||
if (effectData.data.bonusdice) {
|
||||
idVal = "#bonusDicesLevel"
|
||||
}
|
||||
if (effectData.data.reducedicevalue || effectData.data.statdice) {
|
||||
idVal = "#statDicesLevel"
|
||||
}
|
||||
if (effectData.data.otherdice) {
|
||||
idVal = "#otherDicesLevel"
|
||||
}
|
||||
if (effectData.data.hindrance) {
|
||||
idVal = "#hindranceDicesLevel"
|
||||
genre = 'positive' // Dynamic fix
|
||||
}
|
||||
}
|
||||
// Now process the dice level update
|
||||
let newLevel = Number($(idVal).val())
|
||||
console.log("Ongoing", newLevel, toggled, idVal )
|
||||
if (toggled) {
|
||||
if ( genre == 'positive') {
|
||||
newLevel += Number(level)
|
||||
}else {
|
||||
newLevel -= Number(level)
|
||||
}
|
||||
}else {
|
||||
if ( genre == 'positive') {
|
||||
newLevel -= Number(level)
|
||||
}else {
|
||||
newLevel += Number(level)
|
||||
}
|
||||
}
|
||||
newLevel = (newLevel<0) ? 0 : newLevel
|
||||
$(idVal).val(newLevel)
|
||||
}
|
||||
//console.log("Effect", effect, toggled)
|
||||
this.rollData.statDicesLevel = Number($('#statDicesLevel').val())
|
||||
this.rollData.specDicesLevel = Number($('#specDicesLevel').val())
|
||||
this.rollData.bonusDicesLevel = Number($('#bonusDicesLevel').val())
|
||||
this.rollData.hindranceDicesLevel = Number($('#hindranceDicesLevel').val())
|
||||
this.rollData.otherDicesLevel = Number($('#otherDicesLevel').val())
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
manageArmors( armorIdx, toggled) {
|
||||
let armor = this.rollData.armorsList[armorIdx]
|
||||
if (armor) {
|
||||
armor.applied = toggled
|
||||
if (armor.type == 'other' ) {
|
||||
if (toggled) {
|
||||
this.rollData.otherDicesLevel += Number(armor.value)
|
||||
} else {
|
||||
this.rollData.otherDicesLevel -= Number(armor.value)
|
||||
this.rollData.otherDicesLevel = (this.rollData.otherDicesLevel<0) ? 0 : this.rollData.otherDicesLevel
|
||||
}
|
||||
$("#otherDicesLevel").val(this.rollData.otherDicesLevel)
|
||||
}
|
||||
}
|
||||
console.log("Armor", armorIdx, toggled)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
manageWeapons( weaponIdx, toggled) {
|
||||
let weapon = this.rollData.weaponsList[weaponIdx]
|
||||
if (weapon) {
|
||||
if (toggled) {
|
||||
this.rollData.weaponName = weapon.weapon.name
|
||||
} else {
|
||||
this.rollData.weaponName = undefined
|
||||
}
|
||||
weapon.applied = toggled
|
||||
if (weapon.type == 'damage' || weapon.type == 'enhanced' ) {
|
||||
if (toggled) {
|
||||
this.rollData.otherDicesLevel += Number(weapon.value)
|
||||
} else {
|
||||
this.rollData.weaponName = undefined
|
||||
this.rollData.otherDicesLevel -= Number(weapon.value)
|
||||
this.rollData.otherDicesLevel = (this.rollData.otherDicesLevel<0) ? 0 : this.rollData.otherDicesLevel
|
||||
}
|
||||
$("#otherDicesLevel").val(this.rollData.otherDicesLevel)
|
||||
}
|
||||
}
|
||||
console.log("Weapon", weaponIdx, toggled, this.rollData.otherDicesLevel, weapon)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
manageEquip( equipIdx, toggled) {
|
||||
let equip = this.rollData.equipmentsList[equipIdx]
|
||||
if (equip) {
|
||||
equip.applied = toggled
|
||||
let idVal = "#otherDicesLevel" // Default
|
||||
if (equip.equip.data.bonusdice) {
|
||||
idVal = "#bonusDicesLevel"
|
||||
}
|
||||
if (equip.equip.data.statdice) {
|
||||
idVal = "#statDicesLevel"
|
||||
}
|
||||
if (equip.equip.data.otherdice) {
|
||||
idVal = "#otherDicesLevel"
|
||||
}
|
||||
let newLevel = Number($(idVal).val())
|
||||
if (toggled) {
|
||||
newLevel += Number(equip.value)
|
||||
} else {
|
||||
newLevel -= Number(equip.value)
|
||||
}
|
||||
newLevel = (newLevel <0) ? 0 : newLevel
|
||||
$(idVal).val(newLevel)
|
||||
// Then refresh
|
||||
this.rollData.statDicesLevel = Number($('#statDicesLevel').val())
|
||||
this.rollData.specDicesLevel = Number($('#specDicesLevel').val())
|
||||
this.rollData.bonusDicesLevel = Number($('#bonusDicesLevel').val())
|
||||
this.rollData.hindranceDicesLevel = Number($('#hindranceDicesLevel').val())
|
||||
this.rollData.otherDicesLevel = Number($('#otherDicesLevel').val())
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
@@ -183,57 +57,12 @@ export class MournbladeRollDialog extends Dialog {
|
||||
}
|
||||
$(function () { onLoad(); });
|
||||
|
||||
html.find('#specList').change(async (event) => {
|
||||
this.rollData.selectedSpec = event.currentTarget.value
|
||||
let spec = this.rollData.specList.find(item => item._id == this.rollData.selectedSpec)
|
||||
if ( spec) {
|
||||
this.rollData.specDiceLevel = spec.data.level
|
||||
this.rollData.specName = spec.name
|
||||
$('#specDicesLevel').val(this.rollData.specDiceLevel)
|
||||
} else {
|
||||
this.rollData.specName = undefined
|
||||
$('#specDicesLevel').val(0)
|
||||
}
|
||||
const content = await renderTemplate("systems/fvtt-Mournblade-rpg/templates/roll-dialog-generic.html", this.rollData)
|
||||
this.data.content = content
|
||||
this.render(true)
|
||||
});
|
||||
html.find('#statDicesLevel').change((event) => {
|
||||
this.rollData.statDicesLevel = Number(event.currentTarget.value)
|
||||
});
|
||||
html.find('#specDicesLevel').change((event) => {
|
||||
this.rollData.specDicesLevel = Number(event.currentTarget.value)
|
||||
});
|
||||
html.find('#bonusDicesLevel').change((event) => {
|
||||
this.rollData.bonusDicesLevel = Number(event.currentTarget.value)
|
||||
});
|
||||
html.find('#hindranceDicesLevel').change((event) => {
|
||||
this.rollData.hindranceDicesLevel = Number(event.currentTarget.value)
|
||||
});
|
||||
html.find('#otherDicesLevel').change((event) => {
|
||||
this.rollData.otherDicesLevel = Number(event.currentTarget.value)
|
||||
});
|
||||
html.find('.effect-clicked').change((event) => {
|
||||
let toggled = event.currentTarget.checked
|
||||
let effectIdx = $(event.currentTarget).data("effect-idx")
|
||||
this.manageEffects( effectIdx, toggled)
|
||||
});
|
||||
html.find('.armor-clicked').change((event) => {
|
||||
let toggled = event.currentTarget.checked
|
||||
let armorIdx = $(event.currentTarget).data("armor-idx")
|
||||
this.manageArmors( armorIdx, toggled)
|
||||
});
|
||||
html.find('.weapon-clicked').change((event) => {
|
||||
let toggled = event.currentTarget.checked
|
||||
let weaponIdx = $(event.currentTarget).data("weapon-idx")
|
||||
this.manageWeapons( weaponIdx, toggled)
|
||||
});
|
||||
html.find('.equip-clicked').change((event) => {
|
||||
let toggled = event.currentTarget.checked
|
||||
let equipIdx = $(event.currentTarget).data("equip-idx")
|
||||
this.manageEquip( equipIdx, toggled)
|
||||
});
|
||||
|
||||
|
||||
html.find('#modificateur').change(async (event) => {
|
||||
this.rollData.modificateur = Number(event.currentTarget.value)
|
||||
})
|
||||
html.find('#difficulte').change(async (event) => {
|
||||
this.rollData.difficulte = Number(event.currentTarget.value)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,23 +22,38 @@ export class MournbladeUtility {
|
||||
|
||||
Handlebars.registerHelper('count', function (list) {
|
||||
return list.length;
|
||||
});
|
||||
})
|
||||
Handlebars.registerHelper('includes', function (array, val) {
|
||||
return array.includes(val);
|
||||
});
|
||||
})
|
||||
Handlebars.registerHelper('upper', function (text) {
|
||||
return text.toUpperCase();
|
||||
});
|
||||
})
|
||||
Handlebars.registerHelper('lower', function (text) {
|
||||
return text.toLowerCase()
|
||||
})
|
||||
Handlebars.registerHelper('upperFirst', function (text) {
|
||||
if (typeof text !== 'string') return text
|
||||
return text.charAt(0).toUpperCase() + text.slice(1)
|
||||
});
|
||||
})
|
||||
Handlebars.registerHelper('notEmpty', function (list) {
|
||||
return list.length > 0;
|
||||
});
|
||||
})
|
||||
Handlebars.registerHelper('mul', function (a, b) {
|
||||
return parseInt(a) * parseInt(b);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getModificateurOptions() {
|
||||
let opt = []
|
||||
for (let i = -15; i <= 15; i++) {
|
||||
opt.push( `<option value="${i}">${i}</option>` )
|
||||
}
|
||||
return opt.concat("\n")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getAttributs() {
|
||||
return { adr: "Adresse", pui: "Puissance", cla: "Clairvoyance", pre: "Présence", tre: "Trempe"}
|
||||
@@ -247,8 +262,43 @@ export class MournbladeUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async rollMournblade(rollData) {
|
||||
|
||||
rollData.diceFormula = rollData.mainDice
|
||||
if (rollData.competence) {
|
||||
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.data.niveau}+${rollData.modificateur}`
|
||||
} else {
|
||||
rollData.diceFormula += `+${rollData.attr.value}*2+${rollData.modificateur}`
|
||||
}
|
||||
|
||||
let myRoll = rollData.roll
|
||||
if (!myRoll) { // New rolls only of no rerolls
|
||||
myRoll = new Roll(rollData.diceFormula).roll({ async: false });
|
||||
console.log("ROLL : ", rollData.diceFormula)
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"));
|
||||
rollData.roll = myRoll
|
||||
}
|
||||
console.log(">>>> ", myRoll)
|
||||
|
||||
rollData.finalResult = myRoll.total
|
||||
if ( rollData.mainDice == "1d20") {
|
||||
let diceValue = myRoll.terms[0].results[0].result
|
||||
console.log("PAIR/IMP", diceValue)
|
||||
if ( diceValue % 2 == 1) {
|
||||
console.log("PAIR/IMP2", diceValue)
|
||||
rollData.finalResult -= myRoll.terms[0].results[0].result // Substract value
|
||||
if (diceValue == 1 || diceValue == 11) {
|
||||
rollData.isDramatique = true
|
||||
rollData.isSuccess = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rollData.difficulte > 0 && !rollData.isDramatique) {
|
||||
rollData.isSuccess = (myRoll.finalResult >= rollData.difficulte)
|
||||
rollData.isHeroique = ((myRoll.finalResult - rollData.difficulte) >= 10)
|
||||
rollData.isDramatique = ((myRoll.finalResult - rollData.difficulte) <= -10)
|
||||
}
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-Mournblade-rpg/templates/chat-generic-result.html`, rollData)
|
||||
content: await renderTemplate(`systems/fvtt-mournblade/templates/chat-generic-result.html`, rollData)
|
||||
});
|
||||
|
||||
// And save the roll
|
||||
@@ -291,7 +341,7 @@ export class MournbladeUtility {
|
||||
} else {
|
||||
item = game.items.get(dataItem.id)
|
||||
}
|
||||
return item;
|
||||
return item
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -338,6 +388,9 @@ export class MournbladeUtility {
|
||||
let rollData = {
|
||||
rollId: randomID(16),
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
modificateursOptions : this.getModificateurOptions(),
|
||||
difficulte: 0,
|
||||
modificateur: 0,
|
||||
}
|
||||
MournbladeUtility.updateWithTarget(rollData)
|
||||
return rollData
|
||||
|
||||
Reference in New Issue
Block a user