forked from public/bol
Review fight automation + alchimie
This commit is contained in:
@ -336,6 +336,7 @@ export class BoLActor extends Actor {
|
||||
let newPP = this.data.data.resources.power.value - ppCost
|
||||
newPP = (newPP < 0) ? 0 : newPP
|
||||
this.update({ 'data.resources.power.value': newPP })
|
||||
return newPP
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
|
@ -126,7 +126,7 @@ export class BoLRoll {
|
||||
ui.notifications.warn("Unable to find Alchemy !");
|
||||
return;
|
||||
}
|
||||
alchemy = dupicate(alchemy)
|
||||
alchemy = duplicate(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 !")
|
||||
@ -156,7 +156,6 @@ export class BoLRoll {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static spellCheckWithSpell( actor, spell ) {
|
||||
let spellData = spell.data
|
||||
let spellDef = {
|
||||
mode: "spell",
|
||||
actorId: actor.id,
|
||||
@ -168,14 +167,14 @@ export class BoLRoll {
|
||||
ppCurrent: Number(actor.data.data.resources.power.value),
|
||||
careerBonus: actor.getSorcererBonus(),
|
||||
ppCostArmor: actor.getPPCostArmor(),
|
||||
ppCost: Number(spell.data.data.properties.ppcost),
|
||||
mod: Number(spellData.properties.difficulty),
|
||||
ppCost: Number(spell.data.properties.ppcost),
|
||||
mod: Number(spell.data.properties.difficulty),
|
||||
armorAgiMalus: actor.getArmorAgiMalus(),
|
||||
armorInitMalus: actor.getArmorInitMalus(),
|
||||
label: spell.name,
|
||||
description: game.i18n.localize('BOL.ui.focusSpell') + " : " + spell.name,
|
||||
}
|
||||
console.log("SPELL!", spellDef)
|
||||
//console.log("SPELL!", spellDef)
|
||||
return this.displayRollDialog(spellDef)
|
||||
}
|
||||
|
||||
@ -464,10 +463,10 @@ export class BoLDefaultRoll {
|
||||
this.rollData.isFumble = false;
|
||||
}
|
||||
if (this.rollData.optionsId) {
|
||||
$(`#${this.rollData.optionsId}`).hide() // Hide the options roll buttons
|
||||
BoLUtility.cleanupButtons( this.rollData.optionsId)
|
||||
}
|
||||
if (this.rollData.applyId) {
|
||||
$(`#${this.rollData.applyId}`).hide() // Hide the options roll buttons
|
||||
BoLUtility.cleanupButtons( this.rollData.applyId)
|
||||
}
|
||||
this.rollData.optionsId = randomID(16)
|
||||
this.rollData.applyId = randomID(16)
|
||||
@ -499,7 +498,7 @@ export class BoLDefaultRoll {
|
||||
actor.registerInit(r.total, this.rollData.isCritical, this.rollData.isFumble)
|
||||
}
|
||||
if (this.rollData.isSuccess && this.rollData.mode == "spell") { // PP cost management
|
||||
actor.spendPowerPoint(this.rollData.ppCost + this.rollData.ppCostArmor)
|
||||
this.rollData.remainingPP = actor.spendPowerPoint(this.rollData.ppCost + this.rollData.ppCostArmor)
|
||||
}
|
||||
if (this.rollData.mode == "alchemy") { // PP cost management
|
||||
actor.resetAlchemyStatus(this.rollData.alchemy._id)
|
||||
@ -598,7 +597,6 @@ export class BoLDefaultRoll {
|
||||
if (this.rollData.damageMode == 'damage-plus-12') {
|
||||
bonusDmg = 12
|
||||
}
|
||||
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)
|
||||
|
||||
@ -611,7 +609,7 @@ export class BoLDefaultRoll {
|
||||
await this.rollData.damageRoll.roll({ "async": false })
|
||||
this.rollData.damageTotal = this.rollData.damageRoll.total
|
||||
}
|
||||
$(`#${this.rollData.optionsId}`).hide() // Hide the options roll buttons
|
||||
BoLUtility.cleanupButtons(this.rollData.optionsId)
|
||||
this.sendDamageMessage()
|
||||
}
|
||||
}
|
||||
|
@ -127,16 +127,16 @@ export class BoLUtility {
|
||||
return undefined;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static getOtherWhisperRecipients( name) {
|
||||
static getOtherWhisperRecipients(name) {
|
||||
let users = []
|
||||
for( let user of game.users) {
|
||||
if ( !user.isGM && user.name != name) {
|
||||
users.push( user.data._id)
|
||||
for (let user of game.users) {
|
||||
if (!user.isGM && user.name != name) {
|
||||
users.push(user.data._id)
|
||||
}
|
||||
}
|
||||
return users
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getWhisperRecipientsAndGMs(name) {
|
||||
let recep1 = ChatMessage.getWhisperRecipients(name) || [];
|
||||
@ -173,34 +173,39 @@ export class BoLUtility {
|
||||
//console.log("FOUND 1!!! ", actor)
|
||||
if (actor && actor.isOwner) return
|
||||
else if (game.user.isGM || data.author.id === game.user.id) return
|
||||
|
||||
|
||||
const divButtons = chatCard.find('.actions-section')
|
||||
console.log("FOUND 2!! ", divButtons)
|
||||
divButtons.hide()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getRollDataFromMessage( event ) {
|
||||
static getRollDataFromMessage(event) {
|
||||
let messageId = BoLUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
return message.getFlag("world", "bol-roll-data")
|
||||
return message.getFlag("world", "bol-roll-data")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static cleanupButtons(id) {
|
||||
$(`#${id}`).hide() // Hide the options roll buttons
|
||||
game.socket.emit("system.bol", { name: "msg_cleanup_buttons", data: { id: id } })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
|
||||
// Damage handling
|
||||
html.on("click", '.chat-damage-apply', event => {
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
console.log("DATA !!!", rollData)
|
||||
$(`#${rollData.applyId}`).hide()
|
||||
BoLUtility.cleanupButtons(rollData.applyId)
|
||||
BoLUtility.sendAttackSuccess(rollData)
|
||||
});
|
||||
|
||||
html.on("click", '.chat-damage-roll', event => {
|
||||
event.preventDefault();
|
||||
event.preventDefault()
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
rollData.damageMode = event.currentTarget.attributes['data-damage-mode'].value
|
||||
let bolRoll = new BoLDefaultRoll(rollData)
|
||||
bolRoll.rollDamage()
|
||||
});
|
||||
@ -208,7 +213,7 @@ export class BoLUtility {
|
||||
html.on("click", '.transform-legendary-roll', event => {
|
||||
event.preventDefault();
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
let actor = game.actors.get( rollData.actorId)
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.subHeroPoints(1)
|
||||
let r = new BoLDefaultRoll(rollData)
|
||||
r.upgradeToLegendary()
|
||||
@ -217,7 +222,7 @@ export class BoLUtility {
|
||||
html.on("click", '.transform-heroic-roll', event => {
|
||||
event.preventDefault();
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
let actor = game.actors.get( rollData.actorId)
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.subHeroPoints(1)
|
||||
let r = new BoLDefaultRoll(rollData)
|
||||
r.upgradeToHeroic()
|
||||
@ -226,7 +231,7 @@ export class BoLUtility {
|
||||
html.on("click", '.hero-reroll', event => {
|
||||
event.preventDefault();
|
||||
let rollData = BoLUtility.getRollDataFromMessage(event)
|
||||
let actor = game.actors.get( rollData.actorId)
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.subHeroPoints(1)
|
||||
rollData.reroll = false // Disable reroll option for second roll
|
||||
let r = new BoLDefaultRoll(rollData)
|
||||
@ -238,24 +243,24 @@ export class BoLUtility {
|
||||
let attackId = event.currentTarget.attributes['data-attack-id'].value
|
||||
let defenseMode = event.currentTarget.attributes['data-defense-mode'].value
|
||||
let weaponId = (event.currentTarget.attributes['data-weapon-id']) ? event.currentTarget.attributes['data-weapon-id'].value : -1
|
||||
|
||||
// Remove message for all
|
||||
let msgId = BoLUtility.findChatMessageId(event.currentTarget)
|
||||
if (game.user.isGM) {
|
||||
console.log("Process handling !!! -> GM direct damage handling")
|
||||
BoLUtility.processDamageHandling(event, attackId, defenseMode, weaponId)
|
||||
BoLUtility.processDamageHandling(attackId, defenseMode, weaponId, msgId)
|
||||
} else {
|
||||
console.log("Process handling !!! -> socket emit")
|
||||
game.socket.emit("system.bol", { name: "msg_damage_handling", data: { event: event, attackId: attackId, defenseMode: defenseMode, weaponId: weaponId } });
|
||||
game.socket.emit("system.bol", { name: "msg_damage_handling", data: { msgId: msgId, attackId: attackId, defenseMode: defenseMode, weaponId: weaponId } })
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processDamageHandling(event, attackId, defenseMode, weaponId = -1) {
|
||||
static async processDamageHandling(attackId, defenseMode, weaponId = -1, msgId) {
|
||||
if (!game.user.isGM) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
BoLUtility.removeChatMessageId(BoLUtility.findChatMessageId(event.currentTarget));
|
||||
|
||||
console.log("Damage Handling", event, attackId, defenseMode, weaponId)
|
||||
BoLUtility.removeChatMessageId( msgId )
|
||||
console.log("Damage Handling", attackId, defenseMode, weaponId)
|
||||
// Only GM process this
|
||||
let attackDef = this.attackStore[attackId]
|
||||
if (attackDef && attackDef.defenderId) {
|
||||
@ -270,7 +275,7 @@ export class BoLUtility {
|
||||
if (defenseMode == 'damage-with-armor') {
|
||||
let armorFormula = defender.getArmorFormula()
|
||||
attackDef.rollArmor = new Roll(armorFormula)
|
||||
attackDef.rollArmor.roll( { async: false } )
|
||||
attackDef.rollArmor.roll({ async: false })
|
||||
attackDef.armorProtect = (attackDef.rollArmor.total < 0) ? 0 : attackDef.rollArmor.total
|
||||
attackDef.finalDamage = attackDef.damageTotal - attackDef.armorProtect
|
||||
attackDef.finalDamage = (attackDef.finalDamage < 0) ? 0 : attackDef.finalDamage
|
||||
@ -298,21 +303,35 @@ export class BoLUtility {
|
||||
attackDef.weaponHero = defender.weapons.find(item => item._id == weaponId);
|
||||
defender.deleteEmbeddedDocuments("Item", [weaponId]);
|
||||
}
|
||||
|
||||
let defenderUser
|
||||
for (let user of game.users) {
|
||||
if ( user.character && user.character.id == defender.id ) {
|
||||
defenderUser = user
|
||||
}
|
||||
}
|
||||
let damageResults = {
|
||||
attackId: attackDef.id,
|
||||
attacker: attackDef.attacker,
|
||||
rollArmor: attackDef.rollArmor,
|
||||
rollHero: attackDef.rollHero,
|
||||
weaponHero: attackDef.weaponHero,
|
||||
armorProtect: attackDef.armorProtect,
|
||||
name: defender.name,
|
||||
defender: defender,
|
||||
defenseMode: attackDef.defenseMode,
|
||||
finalDamage: attackDef.finalDamage
|
||||
}
|
||||
ChatMessage.create({
|
||||
alias: defender.name,
|
||||
whisper: BoLUtility.getWhisperRecipientsAndGMs(defender.name),
|
||||
content: await renderTemplate('systems/bol/templates/chat/rolls/defense-result-card.hbs', {
|
||||
attackId: attackDef.id,
|
||||
attacker: attackDef.attacker,
|
||||
rollArmor: attackDef.rollArmor,
|
||||
rollHero: attackDef.rollHero,
|
||||
weaponHero: attackDef.weaponHero,
|
||||
armorProtect: attackDef.armorProtect,
|
||||
name: defender.name,
|
||||
defender: defender,
|
||||
defenseMode: attackDef.defenseMode,
|
||||
finalDamage: attackDef.finalDamage
|
||||
})
|
||||
content: await renderTemplate('systems/bol/templates/chat/rolls/defense-result-card.hbs', damageResults)
|
||||
})
|
||||
console.log("Defender data : ", defenderUser)
|
||||
ChatMessage.create({
|
||||
alias: defender.name,
|
||||
whisper: BoLUtility.getOtherWhisperRecipients(defenderUser?.name),
|
||||
content: await renderTemplate('systems/bol/templates/chat/rolls/defense-summary-card.hbs', damageResults)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -417,8 +436,11 @@ export class BoLUtility {
|
||||
if (sockmsg.name == "msg_attack_success") {
|
||||
BoLUtility.processAttackSuccess(sockmsg.data)
|
||||
}
|
||||
if (sockmsg.name == "msg_cleanup_buttons") {
|
||||
$(`#${sockmsg.data.id}`).hide() // Hide the options roll buttons
|
||||
}
|
||||
if (sockmsg.name == "msg_damage_handling") {
|
||||
BoLUtility.processDamageHandling(sockmsg.data.event, sockmsg.data.attackId, sockmsg.data.defenseMode)
|
||||
BoLUtility.processDamageHandling(sockmsg.data.attackId, sockmsg.data.defenseMode, sockmsg.data.weaponId, sockmsg.data.msgId)
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,11 +472,11 @@ export class BoLUtility {
|
||||
let postForm = 'kh' + nbDice
|
||||
let modIndex = 3
|
||||
// Upgrade damage if needed
|
||||
if ( upgradeDamage && ( !res[3] || res[3]=="") ) {
|
||||
if (upgradeDamage && (!res[3] || res[3] == "")) {
|
||||
res[3] = "B" // Upgrade to bonus
|
||||
}
|
||||
if (res[3]) {
|
||||
if ( upgradeDamage && res[3] == 'M') {
|
||||
if (upgradeDamage && res[3] == 'M') {
|
||||
res[3] = "" // Disable lamlus for upgradeDamage
|
||||
}
|
||||
if (res[3] == 'M') {
|
||||
|
Reference in New Issue
Block a user