Gestion des predilections et rework dons
This commit is contained in:
@ -94,9 +94,16 @@ export class MournbladeUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
html.on("click", '.view-item-from-chat', event => {
|
||||
game.system.Mournblade.creator.openItemView(event)
|
||||
});
|
||||
html.on("click", '.predilection-reroll', async event => {
|
||||
let predIdx = $(event.currentTarget).data("predilection-index")
|
||||
let messageId = MournbladeUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "mournblade-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
await actor.setPredilectionUsed( rollData.competence._id, predIdx)
|
||||
rollData.competence = duplicate( actor.getCompetence(rollData.competence._id) )
|
||||
MournbladeUtility.rollMournblade(rollData)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -126,7 +133,7 @@ export class MournbladeUtility {
|
||||
}
|
||||
|
||||
static findChatMessage(current) {
|
||||
return MournbladeUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'));
|
||||
return MournbladeUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'))
|
||||
}
|
||||
|
||||
static findNodeMatching(current, predicate) {
|
||||
@ -288,12 +295,11 @@ export class MournbladeUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async rollMournblade(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
if (rollData.attrKey == "tochoose") { // No attr selected, force address
|
||||
rollData.attrKey = "adr"
|
||||
}
|
||||
if ( !rollData.attr) {
|
||||
console.log("ATTR!!!", rollData.attrKey)
|
||||
rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + actor.data.data.attributs[rollData.attrKey].labelnorm + ".webp"
|
||||
rollData.attr = duplicate(actor.data.data.attributs[rollData.attrKey])
|
||||
}
|
||||
@ -306,6 +312,7 @@ export class MournbladeUtility {
|
||||
}
|
||||
}
|
||||
if (rollData.competence) {
|
||||
rollData.predilections = duplicate( rollData.competence.data.predilections.filter( pred => !pred.used) || [] )
|
||||
let compmod = (rollData.competence.data.niveau == 0) ? -3 : 0
|
||||
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.data.niveau}+${rollData.modificateur}+${compmod}`
|
||||
} else {
|
||||
@ -523,6 +530,16 @@ export class MournbladeUtility {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
return ( !rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "chaotique")
|
||||
}
|
||||
let hasPredilection = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "mournblade-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
if ( rollData.competence) {
|
||||
let nbPred = rollData.competence.data.predilections.filter( pred => !pred.used).length
|
||||
return ( !rollData.isReroll && rollData.competence && nbPred > 0 )
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
options.push(
|
||||
{
|
||||
@ -556,14 +573,6 @@ export class MournbladeUtility {
|
||||
callback: li => MournbladeUtility.applyEclatRoll(li, -1, "+10")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouter +1d20(1 Point d'Eclat)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyPEChaotique,
|
||||
callback: li => MournbladeUtility.applyEclatRoll(li, -1, "+1d20")
|
||||
}
|
||||
)
|
||||
return options
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user