Diverses prise en compte technique

This commit is contained in:
2022-10-25 17:54:13 +02:00
parent b64eeb226a
commit 5c54062b81
17 changed files with 159 additions and 291 deletions

View File

@@ -71,6 +71,7 @@ export class HawkmoonActor extends Actor {
}
return arme
}
/* -------------------------------------------- */
getWeapons() {
let armes = []
@@ -78,9 +79,6 @@ export class HawkmoonActor extends Actor {
if (arme.type == "arme") {
armes.push(this.prepareArme(arme))
}
if (arme.type == "bouclier") {
armes.push(this.prepareBouclier(arme))
}
}
return armes
}
@@ -173,7 +171,10 @@ export class HawkmoonActor extends Actor {
prepareDerivedData() {
if (this.type == 'personnage') {
// TODO
let vigueur = Math.floor( (this.system.attributs.pui.value + this.system.attributs.tre.value) / 2)
if (vigueur != this.system.sante.vigueur) {
this.update( { 'system.sante.vigueur': vigueur})
}
}
super.prepareDerivedData()
@@ -350,9 +351,10 @@ export class HawkmoonActor extends Actor {
rollData.actorImg = this.img
rollData.actorId = this.id
rollData.img = this.img
rollData.canEclatDoubleD20 = true
rollData.doubleD20 = false
rollData.attributs = HawkmoonUtility.getAttributs()
rollData.maitriseId = "none"
rollData.nbEclat = this.system.eclat.value
rollData.nbBA = this.system.bonneaventure.actuelle
if (attrKey) {
rollData.attrKey = attrKey
@@ -363,6 +365,7 @@ export class HawkmoonActor extends Actor {
}
if (compId) {
rollData.competence = duplicate(this.items.get(compId) || {})
rollData.maitrises = rollData.competence.system.predilections.filter(p => p.maitrise )
rollData.actionImg = rollData.competence?.img
}
if (compName) {

View File

@@ -134,41 +134,56 @@ export class HawkmoonItemSheet extends ItemSheet {
let index = li.data("prediction-index")
let pred = duplicate(this.object.system.predilections)
pred[index].name = ev.currentTarget.value
this.object.update( { 'data.predilections': pred })
pred[index].id = pred[index].id || randomID(16)
this.object.update( { 'system.predilections': pred })
})
html.find('.edit-predilection-description').change(ev => {
const li = $(ev.currentTarget).parents(".prediction-item")
let index = li.data("prediction-index")
let pred = duplicate(this.object.system.predilections)
pred[index].description = ev.currentTarget.value
this.object.update( { 'data.predilections': pred })
pred[index].id = pred[index].id || randomID(16)
this.object.update( { 'system.predilections': pred })
})
html.find('.delete-prediction').click(ev => {
html.find('.predilection-acquise').change(ev => {
const li = $(ev.currentTarget).parents(".prediction-item")
let index = li.data("prediction-index")
let pred = duplicate(this.object.system.predilections)
pred.splice(index,1)
this.object.update( { 'data.predilections': pred })
})
pred[index].acquise = ev.currentTarget.checked
pred[index].id = pred[index].id || randomID(16)
this.object.update( { 'system.predilections': pred })
})
html.find('.predilection-maitrise').change(ev => {
const li = $(ev.currentTarget).parents(".prediction-item")
let index = li.data("prediction-index")
let pred = duplicate(this.object.system.predilections)
pred[index].maitrise = ev.currentTarget.checked
this.object.update( { 'data.predilections': pred })
pred[index].id = pred[index].id || randomID(16)
this.object.update( { 'system.predilections': pred })
})
html.find('.predilection-used').change(ev => {
const li = $(ev.currentTarget).parents(".prediction-item")
let index = li.data("prediction-index")
let pred = duplicate(this.object.system.predilections)
pred[index].used = ev.currentTarget.checked
this.object.update( { 'data.predilections': pred })
pred[index].id = pred[index].id || randomID(16)
this.object.update( { 'system.predilections': pred })
})
html.find('.delete-prediction').click(ev => {
const li = $(ev.currentTarget).parents(".prediction-item")
let index = li.data("prediction-index")
let pred = duplicate(this.object.system.predilections)
pred.splice(index,1)
this.object.update( { 'system.predilections': pred })
})
html.find('#add-predilection').click(ev => {
let pred = duplicate(this.object.system.predilections)
pred.push( { name: "Nouvelle prédilection", used: false })
this.object.update( { 'data.predilections': pred })
pred.push( { name: "Nouvelle prédilection", id: randomID(16), used: false })
this.object.update( { 'system.predilections': pred })
})
// Update Inventory Item
html.find('.item-delete').click(ev => {

View File

@@ -20,12 +20,12 @@ export class HawkmoonRollDialog extends Dialog {
rolld10: {
icon: '<i class="fas fa-check"></i>',
label: "Lancer 1d10",
callback: () => { this.roll("1d10") }
callback: () => { this.roll("d10") }
},
rolld20: {
icon: '<i class="fas fa-check"></i>',
label: "Lancer 1d20",
callback: () => { this.roll("1d20") }
callback: () => { this.roll("d20") }
},
cancel: {
icon: '<i class="fas fa-times"></i>',
@@ -66,14 +66,8 @@ export class HawkmoonRollDialog extends Dialog {
html.find('#attrKey').change(async (event) => {
this.rollData.attrKey = String(event.currentTarget.value)
})
html.find('#runemode').change(async (event) => {
this.rollData.runemode = String(event.currentTarget.value)
html.find('#select-maitrise').change(async (event) => {
this.rollData.maitriseId = String(event.currentTarget.value)
})
html.find('#runeame').change(async (event) => {
this.rollData.runeame = Number(event.currentTarget.value)
})
html.find('#doubleD20').change(async (event) => {
this.rollData.doubleD20 = event.currentTarget.checked
})
}
}

View File

@@ -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