Diverses prise en compte technique
This commit is contained in:
@ -14,13 +14,10 @@ export class HawkmoonUtility {
|
||||
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
||||
HawkmoonUtility.pushInitiativeOptions(html, options);
|
||||
})
|
||||
Hooks.on("dropCanvasData", (canvas, data) => {
|
||||
HawkmoonUtility.dropItemOnToken(canvas, data)
|
||||
});
|
||||
|
||||
this.rollDataStore = {}
|
||||
this.defenderStore = {}
|
||||
HawkmoonCommands.init();
|
||||
HawkmoonCommands.init()
|
||||
|
||||
Handlebars.registerHelper('count', function (list) {
|
||||
return list.length;
|
||||
@ -107,7 +104,7 @@ export class HawkmoonUtility {
|
||||
let predIdx = $(event.currentTarget).data("predilection-index")
|
||||
let messageId = HawkmoonUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "mournblade-roll")
|
||||
let rollData = message.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
await actor.setPredilectionUsed(rollData.competence._id, predIdx)
|
||||
rollData.competence = duplicate(actor.getCompetence(rollData.competence._id))
|
||||
@ -123,7 +120,8 @@ export class HawkmoonUtility {
|
||||
'systems/fvtt-hawkmoon-cyd/templates/partial-item-description.html',
|
||||
'systems/fvtt-hawkmoon-cyd/templates/partial-item-nav.html',
|
||||
'systems/fvtt-hawkmoon-cyd/templates/partial-list-niveau.html',
|
||||
'systems/fvtt-hawkmoon-cyd/templates/partial-item-prix.html'
|
||||
'systems/fvtt-hawkmoon-cyd/templates/partial-item-prix.html',
|
||||
'systems/fvtt-hawkmoon-cyd/templates/partial-sante-etat.html',
|
||||
]
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
@ -303,16 +301,16 @@ export class HawkmoonUtility {
|
||||
rollData.attr = duplicate(actor.system.attributs[rollData.attrKey])
|
||||
}
|
||||
|
||||
rollData.diceFormula = rollData.mainDice
|
||||
if (rollData.doubleD20) { // Multiply result !
|
||||
rollData.diceFormula += "*2"
|
||||
if (!rollData.isReroll) {
|
||||
actor.changeEclat(-1)
|
||||
}
|
||||
if ( rollData.maitriseId != "none") {
|
||||
rollData.selectedMaitrise = rollData.maitrises.find(p => p.id == rollData.maitriseId )
|
||||
rollData.diceFormula = "2" + rollData.mainDice + "kh"
|
||||
} else {
|
||||
rollData.diceFormula = "1" + rollData.mainDice
|
||||
}
|
||||
|
||||
//console.log("BEFORE COMP", rollData)
|
||||
if (rollData.competence) {
|
||||
rollData.predilections = duplicate(rollData.competence.system.predilections.filter(pred => !pred.used) || [])
|
||||
rollData.predilections = duplicate(rollData.competence.system.predilections.filter(pred => pred.acquise && !pred.maitrise && !pred.used) || [])
|
||||
let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0
|
||||
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.system.niveau}+${rollData.modificateur}+${compmod}`
|
||||
} else {
|
||||
@ -341,14 +339,6 @@ export class HawkmoonUtility {
|
||||
rollData.finalResult = myRoll.total
|
||||
this.computeResult(rollData)
|
||||
|
||||
if (rollData.rune) {
|
||||
let subAme = rollData.runeame
|
||||
if (rollData.isEchec && !rollData.isDramatique) {
|
||||
subAme = Math.ceil((subAme + 1) / 2)
|
||||
}
|
||||
actor.subPointsAme(rollData.runemode, subAme)
|
||||
}
|
||||
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-hawkmoon-cyd/templates/chat-generic-result.html`, rollData)
|
||||
}, rollData)
|
||||
@ -451,7 +441,7 @@ export class HawkmoonUtility {
|
||||
chatOptions.alias = chatOptions.alias || name
|
||||
let msg = await ChatMessage.create(chatOptions)
|
||||
console.log("=======>", rollData)
|
||||
msg.setFlag("world", "mournblade-roll", rollData)
|
||||
msg.setFlag("world", "hawkmoon-roll", rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -493,7 +483,7 @@ export class HawkmoonUtility {
|
||||
let msgId = li.data("message-id")
|
||||
let msg = game.messages.get(msgId)
|
||||
if (msg) {
|
||||
let rollData = msg.getFlag("world", "mournblade-roll")
|
||||
let rollData = msg.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.changeBonneAventure(changed)
|
||||
rollData.isReroll = true
|
||||
@ -512,122 +502,57 @@ export class HawkmoonUtility {
|
||||
let msgId = li.data("message-id")
|
||||
let msg = game.messages.get(msgId)
|
||||
if (msg) {
|
||||
let rollData = msg.getFlag("world", "mournblade-roll")
|
||||
let rollData = msg.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.changeEclat(changed)
|
||||
rollData.isReroll = true
|
||||
rollData.textBonus = "Bonus d'Eclat"
|
||||
rollData.addedBonus = addedBonus
|
||||
HawkmoonUtility.bonusRollHawkmoon(rollData)
|
||||
if (addedBonus == "reroll") {
|
||||
HawkmoonUtility.rollHawkmoon(rollData)
|
||||
} else {
|
||||
rollData.addedBonus = addedBonus
|
||||
HawkmoonUtility.bonusRollHawkmoon(rollData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static chatRollMenu(html, options) {
|
||||
let canApply = li => canvas.tokens.controlled.length && li.find(".mournblade-roll").length
|
||||
let canApplyBALoyal = function (li) {
|
||||
let canApply = li => canvas.tokens.controlled.length && li.find(".hawkmoon-roll").length
|
||||
let canApplyBA = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "mournblade-roll")
|
||||
let rollData = message.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "loyal")
|
||||
return (!rollData.isReroll && actor.getBonneAventure() > 0 )
|
||||
}
|
||||
let canApplyPELoyal = function (li) {
|
||||
let canApplyPE = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "mournblade-roll")
|
||||
let rollData = message.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "loyal")
|
||||
}
|
||||
let canApplyBAChaotique = 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)
|
||||
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "chaotique")
|
||||
}
|
||||
let canApplyBAChaotique3 = 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)
|
||||
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", "mournblade-roll")
|
||||
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
|
||||
}
|
||||
let canCompetenceDouble = 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) {
|
||||
return rollData.competence.data.doublebonus
|
||||
}
|
||||
return false
|
||||
return (!rollData.isReroll && actor.getEclat() > 0 )
|
||||
}
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouer +3 (1 point de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBALoyal,
|
||||
condition: canApply && canApplyBA,
|
||||
callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -1, "+3")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouer +6 (1 point de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBALoyal && canCompetenceDouble,
|
||||
callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -1, "+6")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouer +1d6 (1 point de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBAChaotique,
|
||||
callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -1, "+1d6")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouer +2d6 (1 point de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBAChaotique && canCompetenceDouble,
|
||||
callback: li => HawkmoonUtility.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,
|
||||
callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -3, "reroll")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouter +10 (1 Point d'Eclat)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyPELoyal,
|
||||
condition: canApply && canApplyPE,
|
||||
callback: li => HawkmoonUtility.applyEclatRoll(li, -1, "+10")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouter +20 (1 Point d'Eclat)",
|
||||
name: "Relancer le dé (1 point d'Eclat)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyPELoyal && canCompetenceDouble,
|
||||
callback: li => HawkmoonUtility.applyEclatRoll(li, -1, "+20")
|
||||
condition: canApply && canApplyPE,
|
||||
callback: li => HawkmoonUtility.applyEclatRoll(li, -3, "reroll")
|
||||
}
|
||||
)
|
||||
return options
|
||||
|
Reference in New Issue
Block a user