forked from public/bol
Review fight automation
This commit is contained in:
@ -63,12 +63,12 @@ export class BoLUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static storeRoll(roll) {
|
||||
this.lastRoll = roll
|
||||
this.rollTab[roll.id] = roll
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getLastRoll() {
|
||||
return this.lastRoll
|
||||
static getRoll(rollId) {
|
||||
return this.rollTab[roll.id]
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -180,27 +180,34 @@ export class BoLUtility {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getRollDataFromMessage( event ) {
|
||||
let messageId = BoLUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
return message.getFlag("world", "bol-roll-data")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
// Damage handling
|
||||
html.on("click", '.chat-damage-apply', event => {
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
console.log("DATA !!!", rollData)
|
||||
$(`#${rollData.applyId}`).hide()
|
||||
BoLUtility.sendAttackSuccess(rollData)
|
||||
});
|
||||
|
||||
html.on("click", '.chat-damage-roll', event => {
|
||||
event.preventDefault();
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
rollData.damageMode = event.currentTarget.attributes['data-damage-mode'].value;
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
let bolRoll = new BoLDefaultRoll(rollData)
|
||||
bolRoll.rollDamage()
|
||||
});
|
||||
|
||||
html.on("click", '.transform-legendary-roll', event => {
|
||||
event.preventDefault();
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
let actor = game.actors.get( rollData.actorId)
|
||||
actor.subHeroPoints(1)
|
||||
let r = new BoLDefaultRoll(rollData)
|
||||
@ -209,7 +216,7 @@ export class BoLUtility {
|
||||
|
||||
html.on("click", '.transform-heroic-roll', event => {
|
||||
event.preventDefault();
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
let actor = game.actors.get( rollData.actorId)
|
||||
actor.subHeroPoints(1)
|
||||
let r = new BoLDefaultRoll(rollData)
|
||||
@ -218,7 +225,7 @@ export class BoLUtility {
|
||||
|
||||
html.on("click", '.hero-reroll', event => {
|
||||
event.preventDefault();
|
||||
let rollData = BoLUtility.getLastRoll()
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
let actor = game.actors.get( rollData.actorId)
|
||||
actor.subHeroPoints(1)
|
||||
rollData.reroll = false // Disable reroll option for second roll
|
||||
@ -264,15 +271,15 @@ export class BoLUtility {
|
||||
let armorFormula = defender.getArmorFormula()
|
||||
attackDef.rollArmor = new Roll(armorFormula)
|
||||
attackDef.rollArmor.roll( { async: false } )
|
||||
console.log("Armor roll ", attackDef.rollArmor)
|
||||
attackDef.armorProtect = (attackDef.rollArmor.total < 0) ? 0 : attackDef.rollArmor.total;
|
||||
attackDef.finalDamage = attackDef.damageRoll.total - attackDef.armorProtect;
|
||||
attackDef.finalDamage = (attackDef.finalDamage < 0) ? 0 : attackDef.finalDamage;
|
||||
defender.sufferDamage(attackDef.finalDamage);
|
||||
attackDef.armorProtect = (attackDef.rollArmor.total < 0) ? 0 : attackDef.rollArmor.total
|
||||
attackDef.finalDamage = attackDef.damageTotal - attackDef.armorProtect
|
||||
attackDef.finalDamage = (attackDef.finalDamage < 0) ? 0 : attackDef.finalDamage
|
||||
defender.sufferDamage(attackDef.finalDamage)
|
||||
console.log("Armor roll -> result ", attackDef)
|
||||
}
|
||||
if (defenseMode == 'damage-without-armor') {
|
||||
attackDef.finalDamage = attackDef.damageRoll.total;
|
||||
defender.sufferDamage(attackDef.finalDamage);
|
||||
attackDef.finalDamage = attackDef.damageTotal
|
||||
defender.sufferDamage(attackDef.finalDamage)
|
||||
}
|
||||
if (defenseMode == 'hero-reduce-damage') {
|
||||
let armorFormula = defender.getArmorFormula()
|
||||
@ -281,7 +288,7 @@ export class BoLUtility {
|
||||
attackDef.armorProtect = (attackDef.rollArmor.total < 0) ? 0 : attackDef.rollArmor.total
|
||||
attackDef.rollHero = new Roll("1d6")
|
||||
attackDef.rollHero.roll({ async: false })
|
||||
attackDef.finalDamage = attackDef.damageRoll.total - attackDef.rollHero.total - attackDef.armorProtect
|
||||
attackDef.finalDamage = attackDef.damageTotal - attackDef.rollHero.total - attackDef.armorProtect
|
||||
attackDef.finalDamage = (attackDef.finalDamage < 0) ? 0 : attackDef.finalDamage
|
||||
defender.sufferDamage(attackDef.finalDamage)
|
||||
defender.subHeroPoints(1)
|
||||
@ -417,8 +424,8 @@ export class BoLUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeSpellCost(spell, nbOptCond = 0) {
|
||||
let pp = spell.data.data.properties.ppcost
|
||||
let minpp = __circle2minpp[spell.data.data.properties.circle]
|
||||
let pp = spell.data.properties.ppcost
|
||||
let minpp = __circle2minpp[spell.data.properties.circle]
|
||||
pp = (pp - nbOptCond < minpp) ? minpp : pp - nbOptCond
|
||||
return pp
|
||||
}
|
||||
|
Reference in New Issue
Block a user