Automatisations de combats, WIP
This commit is contained in:
@ -153,6 +153,15 @@ export class HawkmoonUtility {
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
actor.rollArmeDegats(rollData.arme._id, rollData.targetVigueur, rollData)
|
||||
})
|
||||
html.on("click", '.roll-chat-degat-devastateur', async event => {
|
||||
let messageId = HawkmoonUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "hawkmoon-roll")
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
rollData.applyCoupDevastateur = true
|
||||
actor.rollArmeDegats(rollData.arme._id, rollData.targetVigueur, rollData)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -250,27 +259,12 @@ export class HawkmoonUtility {
|
||||
let newRollData = mergeObject(oldRollData, rollData);
|
||||
this.rollDataStore[id] = newRollData;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static saveRollData(rollData) {
|
||||
game.socket.emit("system.fvtt-hawkmoon-cyd", {
|
||||
name: "msg_update_roll", data: rollData
|
||||
}); // Notify all other clients of the roll
|
||||
this.updateRollData(rollData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getRollData(id) {
|
||||
return this.rollDataStore[id];
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static onSocketMesssage(msg) {
|
||||
//console.log("SOCKET MESSAGE", msg.name, game.user.character.id, msg.data.defenderId);
|
||||
if (msg.name == "msg_update_defense_state") {
|
||||
this.updateDefenseState(msg.data.defenderId, msg.data.rollId);
|
||||
}
|
||||
if (msg.name == "msg_update_roll") {
|
||||
this.updateRollData(msg.data);
|
||||
if (msg.name == "msg_apply_combativite") {
|
||||
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
|
||||
defender.changeEtatCombativite(msg.data.value)
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,7 +346,15 @@ export class HawkmoonUtility {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static applyCombativite(rollData, value) {
|
||||
if (game.user.isGM) {
|
||||
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
|
||||
defender.changeEtatCombativite(value)
|
||||
} else {
|
||||
game.socket.emit("system.fvtt-hawkmoon-cyd", { msg: "msg_apply_combativite", data: { defenderTokenId: rollData.defenderTokenId, value } });
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static async rollHawkmoon(rollData) {
|
||||
|
||||
@ -364,6 +366,9 @@ export class HawkmoonUtility {
|
||||
rollData.actionImg = "systems/fvtt-hawkmoon-cyd/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp"
|
||||
rollData.attr = duplicate(actor.system.attributs[rollData.attrKey])
|
||||
}
|
||||
if (rollData.attrKey2 != "none") {
|
||||
rollData.attr2 = duplicate(actor.system.attributs[rollData.attrKey2])
|
||||
}
|
||||
|
||||
if (rollData.maitriseId != "none") {
|
||||
rollData.selectedMaitrise = rollData.maitrises.find(p => p.id == rollData.maitriseId)
|
||||
@ -377,7 +382,7 @@ export class HawkmoonUtility {
|
||||
rollData.predilections = duplicate(rollData.competence.system.predilections || [])
|
||||
let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0
|
||||
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.system.niveau}+${rollData.modificateur}+${compmod}`
|
||||
|
||||
|
||||
if (rollData.selectedTalents && rollData.selectedTalents.length > 0) {
|
||||
for (let id of rollData.selectedTalents) {
|
||||
let talent = rollData.talents.find(t => t._id == id)
|
||||
@ -396,9 +401,12 @@ export class HawkmoonUtility {
|
||||
}
|
||||
}
|
||||
rollData.diceFormula += `+${rollData.bonusMalusContext}`
|
||||
} else if (rollData.attr2) {
|
||||
rollData.diceFormula += `+${rollData.attr.value}+${rollData.attr2.value}+${rollData.modificateur}+${rollData.bonusMalusContext}`
|
||||
} else {
|
||||
rollData.diceFormula += `+${rollData.attr.value}*${rollData.multiplier}+${rollData.modificateur}+${rollData.bonusMalusContext}`
|
||||
}
|
||||
|
||||
// Bonus arme naturelle en défense
|
||||
if (rollData.bonusArmeNaturelle) {
|
||||
rollData.diceFormula += `+${rollData.bonusArmeNaturelle}`
|
||||
@ -453,8 +461,24 @@ export class HawkmoonUtility {
|
||||
content: await renderTemplate(`systems/fvtt-hawkmoon-cyd/templates/chat-generic-result.html`, rollData)
|
||||
}, rollData)
|
||||
|
||||
if (rollData.arme && rollData.isSuccess && rollData.defenderTokenId) {
|
||||
this.applyCombativite(rollData, 1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getCombativiteList(nbActivite) {
|
||||
let list = [ { value: 0, label: "Combatif"}]
|
||||
for (let i = 1; i < nbActivite-2; i++) {
|
||||
list.push({ value: i, label:"Eprouvé " + i} )
|
||||
}
|
||||
list[nbActivite-2] = { value: nbActivite-2, label:"Affaibli"}
|
||||
list[nbActivite-1] = { value: nbActivite-1, label:"Très Affaibli"}
|
||||
list[nbActivite] = { value: nbActivite, label:"Vaincu"}
|
||||
return list
|
||||
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static async bonusRollHawkmoon(rollData) {
|
||||
rollData.bonusFormula = rollData.addedBonus
|
||||
|
Reference in New Issue
Block a user