|
|
|
@ -116,37 +116,29 @@ export class MaleficesUtility {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static isArmorLight(armor) {
|
|
|
|
|
if (armor && (armor.system.armortype.includes("light") || armor.system.armortype.includes("clothes"))) {
|
|
|
|
|
return true
|
|
|
|
|
static getActorFromRollData(rollData) {
|
|
|
|
|
let actor = game.actors.get(rollData.actorId)
|
|
|
|
|
if (rollData.tokenId) {
|
|
|
|
|
let token = canvas.tokens.placeables.find(t => t.id == rollData.tokenId)
|
|
|
|
|
if (token) {
|
|
|
|
|
actor = token.actor
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
return actor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static async chatListeners(html) {
|
|
|
|
|
|
|
|
|
|
html.on("click", '.view-item-from-chat', event => {
|
|
|
|
|
game.system.Malefices.creator.openItemView(event)
|
|
|
|
|
html.on("click", '.roll-destin', event => {
|
|
|
|
|
let messageId = MaleficesUtility.findChatMessageId(event.currentTarget)
|
|
|
|
|
let message = game.messages.get(messageId)
|
|
|
|
|
let rollData = message.getFlag("world", "rolldata")
|
|
|
|
|
let actor = this.getActorFromRollData(rollData)
|
|
|
|
|
actor.incDecDestin(-1)
|
|
|
|
|
rollData.isReroll = true
|
|
|
|
|
this.rollMalefices(rollData)
|
|
|
|
|
})
|
|
|
|
|
html.on("click", '.roll-defense-melee', event => {
|
|
|
|
|
let rollId = $(event.currentTarget).data("roll-id")
|
|
|
|
|
let rollData = MaleficesUtility.getRollData(rollId)
|
|
|
|
|
rollData.defenseWeaponId = $(event.currentTarget).data("defense-weapon-id")
|
|
|
|
|
let actor = game.canvas.tokens.get(rollData.defenderTokenId).actor
|
|
|
|
|
if (actor && (game.user.isGM || actor.isOwner)) {
|
|
|
|
|
actor.rollDefenseMelee(rollData)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
html.on("click", '.roll-defense-ranged', event => {
|
|
|
|
|
let rollId = $(event.currentTarget).data("roll-id")
|
|
|
|
|
let rollData = MaleficesUtility.getRollData(rollId)
|
|
|
|
|
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
|
|
|
|
|
if (defender && (game.user.isGM || defender.isOwner)) {
|
|
|
|
|
defender.rollDefenseRanged(rollData)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
@ -418,7 +410,7 @@ export class MaleficesUtility {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static getArmorPenalty( item ) {
|
|
|
|
|
static getArmorPenalty(item) {
|
|
|
|
|
if (item && (item.type == "shield" || item.type == "armor")) {
|
|
|
|
|
return __armorPenalties[item.system.category]
|
|
|
|
|
}
|
|
|
|
@ -470,59 +462,38 @@ export class MaleficesUtility {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static updateSkill(skill) {
|
|
|
|
|
skill.system.level = skill.system.background + skill.system.basic + skill.system.class + skill.system.explevel
|
|
|
|
|
if (skill.system.level > 7) { skill.system.level = 7 }
|
|
|
|
|
skill.system.skilldice = __skillLevel2Dice[skill.system.level]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static getDiceFromCover(cover) {
|
|
|
|
|
if (cover == "cover50") return 1
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static getDiceFromSituational(cover) {
|
|
|
|
|
if (cover == "prone") return 1
|
|
|
|
|
if (cover == "dodge") return 1
|
|
|
|
|
if (cover == "moving") return 1
|
|
|
|
|
if (cover == "engaged") return 1
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static async rollMalefices(rollData) {
|
|
|
|
|
|
|
|
|
|
let actor = game.actors.get(rollData.actorId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Build the dice formula
|
|
|
|
|
let diceFormula = "1d20"
|
|
|
|
|
rollData.target = rollData.attr.value + rollData.bonusMalusPerso + rollData.bonusMalusSituation + rollData.bonusMalusDef
|
|
|
|
|
if (rollData.attr.abbrev == "physique") {
|
|
|
|
|
rollData.target += rollData.phyMalus
|
|
|
|
|
}
|
|
|
|
|
rollData.diceFormula = diceFormula
|
|
|
|
|
|
|
|
|
|
// Performs roll
|
|
|
|
|
console.log("Roll formula", diceFormula)
|
|
|
|
|
let myRoll = rollData.roll
|
|
|
|
|
if (!myRoll) { // New rolls only of no rerolls
|
|
|
|
|
myRoll = new Roll(diceFormula).roll({ async: false })
|
|
|
|
|
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
|
|
|
|
}
|
|
|
|
|
let myRoll = new Roll(diceFormula).roll({ async: false })
|
|
|
|
|
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
|
|
|
|
rollData.roll = myRoll
|
|
|
|
|
|
|
|
|
|
rollData.isSuccess = false
|
|
|
|
|
if (myRoll.total <= rollData.target ) {
|
|
|
|
|
if (myRoll.total <= rollData.target) {
|
|
|
|
|
rollData.isSuccess = true
|
|
|
|
|
}
|
|
|
|
|
if (myRoll.total == 1 ) {
|
|
|
|
|
if (myRoll.total == 1) {
|
|
|
|
|
rollData.isSuccess = true
|
|
|
|
|
rollData.isCritical = true
|
|
|
|
|
}
|
|
|
|
|
if (myRoll.total == 20 ) {
|
|
|
|
|
if (myRoll.total == 20) {
|
|
|
|
|
rollData.isSuccess = false
|
|
|
|
|
rollData.isFumble = true
|
|
|
|
|
rollData.isFumble = true
|
|
|
|
|
}
|
|
|
|
|
if (myRoll.total <= Math.floor(rollData.target/3) ) {
|
|
|
|
|
if (myRoll.total <= Math.floor(rollData.target / 3)) {
|
|
|
|
|
rollData.isPart = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -531,7 +502,7 @@ export class MaleficesUtility {
|
|
|
|
|
})
|
|
|
|
|
msg.setFlag("world", "rolldata", rollData)
|
|
|
|
|
if (rollData.mode == "initiative") {
|
|
|
|
|
actor.setFlag("world", "initiative", myRoll.total)
|
|
|
|
|
actor.setFlag("world", "initiative", myRoll.total)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log("Rolldata result", rollData)
|
|
|
|
|