forked from public/bol
Review fight automation
This commit is contained in:
@ -72,7 +72,7 @@ export class BoLRoll {
|
||||
|
||||
let target = BoLUtility.getTarget()
|
||||
|
||||
let weaponData = weapon.data.data
|
||||
let weaponData = weapon.data
|
||||
let attribute = eval(`actor.data.data.attributes.${weaponData.properties.attackAttribute}`)
|
||||
let aptitude = eval(`actor.data.data.aptitudes.${weaponData.properties.attackAptitude}`)
|
||||
|
||||
@ -109,23 +109,25 @@ export class BoLRoll {
|
||||
/* -------------------------------------------- */
|
||||
static weaponCheck(actor, event) {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
const weapon = actor.items.get(li.data("item-id"))
|
||||
let weapon = actor.items.get(li.data("item-id"))
|
||||
if (!weapon) {
|
||||
ui.notifications.warn("Unable to find weapon !")
|
||||
return
|
||||
}
|
||||
weapon = duplicate(weapon)
|
||||
return this.weaponCheckWithWeapon(actor, weapon)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static alchemyCheck(actor, event) {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const alchemy = actor.items.get(li.data("item-id"));
|
||||
let alchemy = actor.items.get(li.data("item-id"));
|
||||
if (!alchemy) {
|
||||
ui.notifications.warn("Unable to find Alchemy !");
|
||||
return;
|
||||
}
|
||||
let alchemyData = alchemy.data.data
|
||||
alchemy = dupicate(alchemy)
|
||||
let alchemyData = alchemy.data
|
||||
if (alchemyData.properties.pccurrent < alchemyData.properties.pccost) {
|
||||
ui.notifications.warn("Pas assez de Points de Cration investis dans la Préparation !")
|
||||
return
|
||||
@ -154,7 +156,7 @@ export class BoLRoll {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static spellCheckWithSpell( actor, spell ) {
|
||||
let spellData = spell.data.data
|
||||
let spellData = spell.data
|
||||
let spellDef = {
|
||||
mode: "spell",
|
||||
actorId: actor.id,
|
||||
@ -184,11 +186,12 @@ export class BoLRoll {
|
||||
return
|
||||
}
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
const spell = actor.items.get(li.data("item-id"))
|
||||
let spell = actor.items.get(li.data("item-id"))
|
||||
if (!spell) {
|
||||
ui.notifications.warn("Impossible de trouver ce sort !")
|
||||
return
|
||||
}
|
||||
spell = duplicate(spell)
|
||||
return this.spellCheckWithSpell( actor, spell)
|
||||
}
|
||||
|
||||
@ -207,7 +210,7 @@ export class BoLRoll {
|
||||
$('#roll-nbdice').val("2 + " + String(Math.abs(this.rollData.bmDice)) + letter)
|
||||
}
|
||||
let rollbase = this.rollData.attrValue + "+" + this.rollData.aptValue
|
||||
if ( this.rollData.weapon && this.rollData.weapon.data.data.properties.onlymodifier ) {
|
||||
if ( this.rollData.weapon && this.rollData.weapon.data.properties.onlymodifier ) {
|
||||
rollbase = ""
|
||||
}
|
||||
$('#roll-modifier').val(rollbase + "+" + this.rollData.careerBonus + "+" + this.rollData.mod + "+" +
|
||||
@ -337,8 +340,8 @@ export class BoLRoll {
|
||||
/* -------------------------------------------- */
|
||||
static preProcessWeapon(rollData, defender) {
|
||||
if (rollData.mode == "weapon") {
|
||||
rollData.weaponModifier = rollData.weapon.data.data.properties.attackModifiers ?? 0;
|
||||
rollData.attackBonusDice = rollData.weapon.data.data.properties.attackBonusDice
|
||||
rollData.weaponModifier = rollData.weapon.data.properties.attackModifiers ?? 0;
|
||||
rollData.attackBonusDice = rollData.weapon.data.properties.attackBonusDice
|
||||
if (defender) { // If target is selected
|
||||
rollData.defence = defender.defenseValue
|
||||
rollData.armorMalus = defender.armorMalusValue
|
||||
@ -429,7 +432,7 @@ export class BoLRoll {
|
||||
rollData.nbDice += (rollData.attackBonusDice) ? 1 : 0
|
||||
|
||||
let rollbase = rollData.attrValue + rollData.aptValue
|
||||
if ( rollData.weapon && rollData.weapon.data.data.properties.onlymodifier ) {
|
||||
if ( rollData.weapon && rollData.weapon.data.properties.onlymodifier ) {
|
||||
rollbase = 0
|
||||
}
|
||||
const modifiers = rollbase + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier + rollData.appliedArmorMalus
|
||||
@ -454,7 +457,6 @@ export class BoLRoll {
|
||||
export class BoLDefaultRoll {
|
||||
|
||||
constructor(rollData) {
|
||||
BoLUtility.storeRoll(rollData)
|
||||
this.rollData = rollData
|
||||
if (this.rollData.isSuccess == undefined) { // First init
|
||||
this.rollData.isSuccess = false;
|
||||
@ -500,7 +502,7 @@ export class BoLDefaultRoll {
|
||||
actor.spendPowerPoint(this.rollData.ppCost + this.rollData.ppCostArmor)
|
||||
}
|
||||
if (this.rollData.mode == "alchemy") { // PP cost management
|
||||
actor.resetAlchemyStatus(this.rollData.alchemy.id)
|
||||
actor.resetAlchemyStatus(this.rollData.alchemy._id)
|
||||
}
|
||||
|
||||
await this.sendChatMessage()
|
||||
@ -509,14 +511,15 @@ export class BoLDefaultRoll {
|
||||
/* -------------------------------------------- */
|
||||
async sendChatMessage() {
|
||||
let actor = game.actors.get( this.rollData.actorId)
|
||||
this._buildChatMessage(this.rollData).then(msgFlavor => {
|
||||
this.rollData.roll.toMessage({
|
||||
this._buildChatMessage(this.rollData).then( async msgFlavor => {
|
||||
let msg = await this.rollData.roll.toMessage({
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
//whisper: BoLUtility.getWhisperRecipientsAndGMs(this.rollData.actor.name),
|
||||
flavor: msgFlavor,
|
||||
speaker: ChatMessage.getSpeaker({ actor: actor }),
|
||||
})
|
||||
msg.setFlag("world", "bol-roll-data", this.rollData)
|
||||
})
|
||||
}
|
||||
|
||||
@ -555,14 +558,15 @@ export class BoLDefaultRoll {
|
||||
/* -------------------------------------------- */
|
||||
async sendDamageMessage() {
|
||||
let actor = game.actors.get( this.rollData.actorId)
|
||||
this._buildDamageChatMessage(this.rollData).then(msgFlavor => {
|
||||
this.rollData.damageRoll.toMessage({
|
||||
this._buildDamageChatMessage(this.rollData).then(async msgFlavor => {
|
||||
let msg = await this.rollData.damageRoll.toMessage({
|
||||
user: game.user.id,
|
||||
flavor: msgFlavor,
|
||||
speaker: ChatMessage.getSpeaker({ actor: actor }),
|
||||
flags: { msgType: "default" }
|
||||
})
|
||||
});
|
||||
msg.setFlag("world", "bol-roll-data", this.rollData)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -582,7 +586,7 @@ export class BoLDefaultRoll {
|
||||
/* -------------------------------------------- */
|
||||
async rollDamage() {
|
||||
if (this.rollData.mode != "weapon") { // Only specific process in Weapon mode
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
if (this.rollData.isSuccess) {
|
||||
@ -594,8 +598,9 @@ export class BoLDefaultRoll {
|
||||
if (this.rollData.damageMode == 'damage-plus-12') {
|
||||
bonusDmg = 12
|
||||
}
|
||||
let attrDamageValue = this.getDamageAttributeValue(this.rollData.weapon.data.data.properties.damageAttribute)
|
||||
let weaponFormula = BoLUtility.getDamageFormula(this.rollData.weapon.data.data, this.rollData.fightOption)
|
||||
console.log("ROLLWEAPON: ", this.rollData)
|
||||
let attrDamageValue = this.getDamageAttributeValue(this.rollData.weapon.data.properties.damageAttribute)
|
||||
let weaponFormula = BoLUtility.getDamageFormula(this.rollData.weapon.data, this.rollData.fightOption)
|
||||
|
||||
let damageFormula = weaponFormula + "+" + bonusDmg + "+" + attrDamageValue
|
||||
console.log("DAMAGE !!!", damageFormula, attrDamageValue, this.rollData)
|
||||
|
Reference in New Issue
Block a user