Gestion plus fine ame+sante

This commit is contained in:
2023-12-29 18:36:37 +01:00
parent 2a8617d781
commit 9c20f277ea
78 changed files with 407 additions and 305 deletions

View File

@@ -60,6 +60,7 @@ export class MournbladeActorSheet extends ActorSheet {
config: game.system.mournblade.config,
protectionTotal: this.actor.getProtectionTotal(),
santeMalus: this.actor.getStatusMalus(),
ameMalus: this.actor.getAmeMalus(),
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
options: this.options,
owner: this.document.isOwner,
@@ -147,6 +148,15 @@ export class MournbladeActorSheet extends ActorSheet {
const itemType = $(event.currentTarget).data("type")
this.actor.createEmbeddedDocuments('Item', [{ name: `Nouveau ${itemType}`, type: itemType }], { renderSheet: true })
})
html.find('.sante-modify').click((event) => {
const santeType = $(event.currentTarget).data("type")
const value = $(event.currentTarget).data("value")
this.actor.incDecSante(santeType, value, false)
})
html.find('.ame-modify').click((event) => {
const value = $(event.currentTarget).data("value")
this.actor.incDecAme(value)
})
html.find('.lock-unlock-sheet').click((event) => {

View File

@@ -114,8 +114,8 @@ export class MournbladeActor extends Actor {
for (let mod of this.items) {
if (mod.type == "modifier" && mod.system.modifiertype == "roll") {
let modObj = mod.toObject()
modObj .system.apply = true
modifiers.push( modObj )
modObj.system.apply = true
modifiers.push(modObj)
}
}
MournbladeUtility.sortArrayObjectsByName(modifiers)
@@ -123,8 +123,8 @@ export class MournbladeActor extends Actor {
}
/* -------------------------------------------- */
getItemSorted( types) {
let items = this.items.filter(item => types.includes(item.type )) || []
getItemSorted(types) {
let items = this.items.filter(item => types.includes(item.type)) || []
MournbladeUtility.sortArrayObjectsByName(items)
return items
}
@@ -201,10 +201,10 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getAspect() {
return (this.system.balance.loi > this.system.balance.chaos) ? this.system.balance.loi : this.system.balance.chaos
return (this.system.balance.loi > this.system.balance.chaos) ? this.system.balance.loi : this.system.balance.chaos
}
getMarge() {
return Math.abs( this.system.balance.loi - this.system.balance.chaos)
return Math.abs(this.system.balance.loi - this.system.balance.chaos)
}
getAlignement() {
return (this.system.balance.loi > this.system.balance.chaos) ? "loyal" : "chaotique"
@@ -287,22 +287,40 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getStatusMalus() {
if (this.system.biodata.ignoresantemalus) {
return 0
}
let malusL = 0
let malusNL = 0
if (this.system.sante.base-this.system.sante.letaux < 10) {
if (this.system.sante.base - this.system.sante.letaux < 10) {
malusL = -2
}
if (this.system.sante.base-this.system.sante.letaux < 5) {
if (this.system.sante.base - this.system.sante.letaux < 5) {
malusL = -5
}
if (this.system.sante.base-this.system.sante.nonletaux < 10) {
if (this.system.sante.base - this.system.sante.nonletaux < 10) {
malusNL = -2
}
if (this.system.sante.base-this.system.sante.nonletaux < 5) {
if (this.system.sante.base - this.system.sante.nonletaux < 5) {
malusNL = -5
}
return Math.min(malusL, malusNL)
}
/* -------------------------------------------- */
getAmeMalus() {
if (this.system.biodata.ignoreamemalus) {
return 0
}
let malusA = 0
if (this.system.ame.currentmax - this.system.ame.value < 10) {
malusA = -2
}
if (this.system.ame.currentmax - this.system.ame.value < 5) {
malusA = -5
}
return malusA
}
/* -------------------------------------------- */
editItemField(itemId, itemType, itemField, dataType, value) {
@@ -320,27 +338,43 @@ export class MournbladeActor extends Actor {
}
/* -------------------------------------------- */
incDecSante(type, value, applyArmure=true) {
if (applyArmure) {
incDecSante(type, value, applyArmure = true) {
value = Number(value)
if (value && applyArmure) {
let protection = this.getProtectionTotal()
value -= protection
value = Math.max(0, value)
value = Math.max(0, Number(value))
}
if (value) {
let newSante = duplicate(this.system.sante)
newSante[type] += value
newSante[type] += Number(value)
newSante[type] = Math.max(0, newSante[type])
if (newSante[type] > this.system.sante.base) {
value -= this.system.sante.base - newSante[type]
newSante[type] = this.system.sante.base
} else {
value = 0
}
newSante[type] = Math.min(newSante[type], newSante.base)
if (value && type == "nonletaux") {
newSante["letaux"] += value
}
this.update({ 'system.sante': newSante })
ui.notifications.info(this.name + "a subi " + value + " points de santé " + type + ".")
}
}
/* -------------------------------------------- */
incDecAme(value) {
value = Number(value)
if (value) {
let newAme = duplicate(this.system.ame)
newAme.value += Number(value)
newAme.value = Math.max(0, newAme.value)
newAme.value = Math.min(newAme.value, newAme.currentmax)
this.update({ 'system.ame': newAme })
}
}
/* -------------------------------------------- */
getBonneAventure() {
return this.system.bonneaventure.actuelle
@@ -372,12 +406,12 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
subPointsAme(runeMode, value) {
let ame = duplicate(this.system.ame)
if(runeMode == "prononcer") {
ame.value -= value
if (runeMode == "prononcer") {
ame.value += value
} else {
ame.currentmax -= value
}
this.update( {'system.ame': ame})
this.update({ 'system.ame': ame })
}
/* -------------------------------------------- */
@@ -457,22 +491,22 @@ export class MournbladeActor extends Actor {
}
/* -------------------------------------------- */
getInitiativeScore( ) {
getInitiativeScore() {
return Number(this.system.attributs.adr.value) + Number(this.system.combat.initbonus)
}
/* -------------------------------------------- */
getBestDefenseValue() {
let defenseList = this.items.filter(item => (item.type =="arme" || item.type == "bouclier") && item.system.equipped)
let defenseList = this.items.filter(item => (item.type == "arme" || item.type == "bouclier") && item.system.equipped)
let maxDef = 0
let bestArme
for(let arme of defenseList) {
for (let arme of defenseList) {
if (arme.type == "arme" && arme.system.isdefense) {
arme = this.prepareArme(arme)
}
if (arme.type == "bouclier" ) {
if (arme.type == "bouclier") {
arme = this.prepareBouclier(arme)
}
if ( arme.system.totalDefensif > maxDef) {
if (arme.system.totalDefensif > maxDef) {
maxDef = arme.system.totalDefensif
bestArme = duplicate(arme)
}
@@ -493,6 +527,7 @@ export class MournbladeActor extends Actor {
rollData.attributs = MournbladeUtility.getAttributs()
rollData.selectDifficulte = true
rollData.malusSante = this.getStatusMalus() + this.system.sante.malusmanuel
rollData.malusAme = this.getAmeMalus()
rollData.modifiers = this.getModifiersForRoll()
if (attrKey) {
@@ -507,7 +542,7 @@ export class MournbladeActor extends Actor {
rollData.actionImg = rollData.competence?.img
}
if (compName) {
rollData.competence = duplicate(this.items.find( item => item.name.toLowerCase() == compName.toLowerCase()) || {})
rollData.competence = duplicate(this.items.find(item => item.name.toLowerCase() == compName.toLowerCase()) || {})
rollData.actionImg = rollData.competence?.img
}
return rollData
@@ -529,22 +564,22 @@ export class MournbladeActor extends Actor {
}
/* -------------------------------------------- */
async rollRune(runeId) {
async rollRune(runeId) {
let comp = this.items.find(comp => comp.type == "competence" && comp.name.toLowerCase() == "savoir : runes")
if ( !comp) {
if (!comp) {
ui.notifications.warn("La compétence Savoirs : Runes n'a pas été trouvée, abandon.")
return
}
let rollData = this.getCommonRollData("cla", undefined, "Savoir : Runes")
rollData.rune = duplicate(this.items.get(runeId) || {})
rollData.rune = duplicate(this.items.get(runeId) || {})
rollData.difficulte = rollData.rune?.system?.seuil || 0
rollData.runemode = "prononcer"
rollData.runeame = 1
rollData.runeame = 1
console.log("runeData", rollData)
let rollDialog = await MournbladeRollDialog.create(this, rollData)
rollDialog.render(true)
}
/* -------------------------------------------- */
async rollArmeOffensif(armeId) {
let arme = this.items.get(armeId)

View File

@@ -353,7 +353,7 @@ export class MournbladeUtility {
} else {
rollData.diceFormula += `+${rollData.attr.value}*2+${rollData.modificateur}`
}
rollData.diceFormula += `+${rollData.malusSante}`
rollData.diceFormula += `+${rollData.malusSante}+${rollData.malusAme}`
if (rollData.arme?.type == "arme") {
rollData.diceFormula += `+${rollData.arme.system.bonusmaniementoff}`
@@ -530,7 +530,10 @@ export class MournbladeUtility {
ui.notifications.info("L'arme de " + defender.name + " est arrachée de ses mains (à gérer manuellement)" )
}
let degats = rollData.finalResult
defender.incDecSante((rollData.arme.system.nonletaux) ? "nonletaux" : "letaux", +degats, rollData.ignoreDefenseArmor)
let type = (rollData.arme.system.nonletaux) ? "nonletaux" : "letaux"
defender.incDecSante(type, +degats, rollData.ignoreDefenseArmor)
ui.notifications.info(defender.name + "a subi " + degats + " points de santé " + type + ".")
}
}