Dur au mal, parade, initiative management, amelioration dialogues, bonus/malus sur jets

This commit is contained in:
2022-11-29 10:54:56 +01:00
parent 4ecfb2c833
commit 567710d922
12 changed files with 111 additions and 25 deletions

View File

@@ -47,16 +47,31 @@ export class HawkmoonActor extends Actor {
return super.create(data, options);
}
/* -------------------------------------------- */
getBonusDefenseFromTalents() {
let talents = this.items.filter(item => item.type == "talent" && item.system.isautomated)
let bonus = 0
for (let talent of talents) {
for (let auto of talent.system.automations) {
if (auto.eventtype == "bonus-permanent" && auto.bonusname == "bonus-defensif") {
bonus += Number(auto.bonus || 0)
}
}
}
return bonus
}
/* -------------------------------------------- */
prepareArme(arme) {
arme = duplicate(arme)
let combat = this.getCombatValues()
if (arme.system.typearme == "contact" || arme.system.typearme == "contactjet") {
let bonusDefense = this.getBonusDefenseFromTalents()
arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée"))
arme.system.attrKey = "pui"
arme.system.totalDegats = arme.system.degats + "+" + combat.bonusDegatsTotal
arme.system.totalOffensif = this.system.attributs.pui.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense + bonusDefense
arme.system.isdefense = true
}
if (arme.system.typearme == "jet" || arme.system.typearme == "tir") {
@@ -205,7 +220,8 @@ export class HawkmoonActor extends Actor {
prepareDerivedData() {
if (this.type == 'personnage') {
let vigueur = Math.floor((this.system.attributs.pui.value + this.system.attributs.tre.value) / 2)
let talentBonus = this.getVigueurBonus()
let vigueur = Math.floor((this.system.attributs.pui.value + this.system.attributs.tre.value) / 2) + talentBonus
if (vigueur != this.system.sante.vigueur) {
this.update({ 'system.sante.vigueur': vigueur })
}
@@ -298,6 +314,21 @@ export class HawkmoonActor extends Actor {
getVigueur() {
return this.system.sante.vigueur
}
/* -------------------------------------------- */
getVigueurBonus() {
let talents = this.items.filter(item => item.type == "talent" && item.system.isautomated)
let bonus = 0
for (let talent of talents) {
for (let auto of talent.system.automations) {
if (auto.eventtype == "bonus-permanent" && auto.bonusname == "vigueur") {
bonus += Number(auto.bonus || 0)
}
}
}
return bonus
}
/* -------------------------------------------- */
getBonneAventure() {
return this.system.bonneaventure.actuelle
@@ -417,7 +448,8 @@ export class HawkmoonActor extends Actor {
/* -------------------------------------------- */
getInitiativeScore() {
return this.lastInit || -1
let init = this.getFlag("world", "last-initiative")
return init || -1
}
/* -------------------------------------------- */
@@ -464,6 +496,8 @@ export class HawkmoonActor extends Actor {
rollData.alias = this.name
rollData.actorImg = this.img
rollData.actorId = this.id
rollData.isToken = this.isToken
rollData.tokenId = this.token?.id
rollData.img = this.img
rollData.attributs = HawkmoonUtility.getAttributs()
rollData.maitriseId = "none"
@@ -518,6 +552,7 @@ export class HawkmoonActor extends Actor {
}
let rollData = this.getCommonRollData(arme.system.attrKey, arme.system.competence._id)
rollData.arme = arme
HawkmoonUtility.updateWithTarget(rollData)
console.log("ARME!", rollData)
let rollDialog = await HawkmoonRollDialog.create(this, rollData)
rollDialog.render(true)

View File

@@ -8,9 +8,9 @@ export class HawkmoonCombat extends Combat {
ids = typeof ids === "string" ? [ids] : ids;
for (let cId = 0; cId < ids.length; cId++) {
const c = this.combatants.get(ids[cId]);
let id = c._id || c.id;
//console.log("Init for combattant", c )
let id = c._id || c.id
let initValue = c.actor ? c.actor.getInitiativeScore() : 0
//console.log("Init bonus", initBonus, roll.total)
await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: initValue } ]);
}

View File

@@ -5,7 +5,7 @@ export class HawkmoonRollDialog extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData ) {
let options = { classes: ["HawkmoonDialog"], width: 340, height: 'fit-content', 'z-index': 99999 };
let options = { classes: ["HawkmoonDialog"], width: 320, height: 'fit-content', 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-hawkmoon-cyd/templates/roll-dialog-generic.html', rollData);
return new HawkmoonRollDialog(actor, rollData, html, options );
@@ -70,7 +70,11 @@ export class HawkmoonRollDialog extends Dialog {
this.rollData.maitriseId = String(event.currentTarget.value)
})
html.find('#competence-talents').change((event) => {
this.rollData.selectedTalents = $('#competence-talents').val()
this.rollData.selectedTalents = $('#competence-talents').val()
})
html.find('#bonus-malus-context').change((event) => {
this.rollData.bonusMalusContext = Number(event.currentTarget.value)
})
}
}

View File

@@ -363,8 +363,9 @@ export class HawkmoonUtility {
}
}
}
rollData.diceFormula += `+${rollData.bonusMalusContext}`
} else {
rollData.diceFormula += `+${rollData.attr.value}*${rollData.multiplier}+${rollData.modificateur}`
rollData.diceFormula += `+${rollData.attr.value}*${rollData.multiplier}+${rollData.modificateur}+${rollData.bonusMalusContext}`
}
// Ajout adversités
@@ -382,7 +383,12 @@ export class HawkmoonUtility {
rollData.finalResult = myRoll.total
this.computeResult(rollData)
if (rollData.isInit) {
actor.lastInit = rollData.finalResult
let actorInit = actor
if ( rollData.isToken && rollData.tokenId) {
actorInit = game.canvas.tokens.get(rollData.tokenId).actor
}
actorInit.setFlag("world", "last-initiative", rollData.finalResult)
//console.log("IS TOKEN ?????", actor, actor.isToken)
}
this.createChatWithRollMode(rollData.alias, {
@@ -501,8 +507,8 @@ export class HawkmoonUtility {
pointAmeOptions: this.getPointAmeOptions(),
difficulte: 0,
modificateur: 0,
bonusMalusContext: 0
}
HawkmoonUtility.updateWithTarget(rollData)
return rollData
}