Initial import

This commit is contained in:
2023-11-26 17:00:12 +01:00
parent 09b89f794f
commit 386ce186af
64 changed files with 268 additions and 247 deletions

View File

@@ -536,40 +536,49 @@ export class WastelandUtility {
/* -------------------------------------------- */
static chatRollMenu(html, options) {
let canApply = li => canvas.tokens.controlled.length && li.find(".wasteland-roll").length
let canApplyBALoyal = function (li) {
let hasBA = function (li) {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "wasteland-roll")
let actor = WastelandUtility.getActorFromRollData(rollData)
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "loyal")
if (rollData?.actorId) {
let actor = game.actors.get(rollData.actorId)
return actor.getBonneAventure() > 0
}
return false
}
let canApplyPELoyal = function (li) {
let hasBA2 = function (li) {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "wasteland-roll")
let actor = WastelandUtility.getActorFromRollData(rollData)
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "loyal")
if (rollData?.actorId) {
let actor = game.actors.get(rollData.actorId)
return actor.getBonneAventure() >= 2
}
return false
}
let canApplyBAChaotique = function (li) {
let hasBA3 = function (li) {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "wasteland-roll")
let actor = WastelandUtility.getActorFromRollData(rollData)
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "chaotique")
if (rollData?.actorId) {
let actor = game.actors.get(rollData.actorId)
return actor.getBonneAventure() >= 3
}
return false
}
let canApplyBAChaotique3 = function (li) {
let hasPE = function (li) {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "wasteland-roll")
let actor = WastelandUtility.getActorFromRollData(rollData)
return (!rollData.isReroll && actor.getBonneAventure() > 2 && actor.getAlignement() == "chaotique")
}
let canApplyPEChaotique = function (li) {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "wasteland-roll")
let actor = WastelandUtility.getActorFromRollData(rollData)
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "chaotique")
if (rollData?.actorId) {
let actor = game.actors.get(rollData.actorId)
return actor.getEclat() >= 1
}
return false
}
let hasPredilection = function (li) {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "wasteland-roll")
let actor = WastelandUtility.getActorFromRollData(rollData)
if (rollData.competence) {
let nbPred = rollData.competence.data.predilections.filter(pred => !pred.used).length
return (!rollData.isReroll && rollData.competence && nbPred > 0)
@@ -579,7 +588,6 @@ export class WastelandUtility {
let canCompetenceDouble = function (li) {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "wasteland-roll")
let actor = WastelandUtility.getActorFromRollData(rollData)
if (rollData.competence) {
return rollData.competence.data.doublebonus
}
@@ -587,58 +595,74 @@ export class WastelandUtility {
}
options.push(
{
name: "Ajouer +3 (1 point de Bonne Aventure)",
name: "Ajouter +3 (1 point de Bonne Aventure)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && canApplyBALoyal,
condition: canApply && hasBA,
callback: li => WastelandUtility.applyBonneAventureRoll(li, -1, "+3")
}
)
options.push(
{
name: "Ajouer +6 (1 point de Bonne Aventure)",
name: "Gain de 1 Point de Santé / 24 heure (1 point de Bonne Aventure)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && canApplyBALoyal && canCompetenceDouble,
callback: li => WastelandUtility.applyBonneAventureRoll(li, -1, "+6")
condition: canApply && hasBA,
callback: li => WastelandUtility.incDecSante(1)
}
)
options.push(
{
name: "Ajouer +1d6 (1 point de Bonne Aventure)",
name: "Gain de 2 Points de Santé / 24 heure (2 points de Bonne Aventure)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && canApplyBAChaotique,
callback: li => WastelandUtility.applyBonneAventureRoll(li, -1, "+1d6")
condition: canApply && hasBA2,
callback: li => WastelandUtility.incDecSante(2)
}
)
options.push(
{
name: "Ajouer +2d6 (1 point de Bonne Aventure)",
name: "Relancer le jet (3 points de Bonne Aventure)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && canApplyBAChaotique && canCompetenceDouble,
callback: li => WastelandUtility.applyBonneAventureRoll(li, -1, "+2d6")
}
)
options.push(
{
name: "Relancer le dé (3 points de Bonne Aventure)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && canApplyBAChaotique3,
condition: canApply && hasBA3,
callback: li => WastelandUtility.applyBonneAventureRoll(li, -3, "reroll")
}
)
options.push(
{
name: "Bénéficier d'1 action supplémentaire (3 points de Bonne Aventure)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && hasBA3,
callback: li => WastelandUtility.applyBonneAventureRoll(li, -3, "newaction")
}
)
options.push(
{
name: "Ajouter +10 (1 Point d'Eclat)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && canApplyPELoyal,
condition: canApply && hasPE,
callback: li => WastelandUtility.applyEclatRoll(li, -1, "+10")
}
)
options.push(
{
name: "Ajouter +20 (1 Point d'Eclat)",
name: "Double le résultat du d20 (1 Point d'Eclat)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && canApplyPELoyal && canCompetenceDouble,
callback: li => WastelandUtility.applyEclatRoll(li, -1, "+20")
condition: canApply && hasPE,
callback: li => WastelandUtility.applyEclatRoll(li, -1, "double20")
}
)
options.push(
{
name: "Annuler une blessure (1 Point d'Eclat)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && hasPE,
callback: li => WastelandUtility.cancelBlessure(li)
}
)
options.push(
{
name: "Recharger ses points de BA (1 Point d'Eclat)",
icon: "<i class='fas fa-user-plus'></i>",
condition: canApply && hasPE,
callback: li => WastelandUtility.reloadBA(li)
}
)
return options