Migration datamodels !
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* -------------------------------------------- */
|
||||
import { MournbladeUtility } from "./mournblade-utility.js";
|
||||
import { MournbladeRollDialog } from "./mournblade-roll-dialog.js";
|
||||
import { MournbladeRollDialog } from "./applications/mournblade-roll-dialog.mjs";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const __degatsBonus = [-2, -2, -1, -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9, 10, 10]
|
||||
@@ -12,6 +12,28 @@ const __vitesseBonus = [-2, -2, -1, -1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6
|
||||
* @extends {Actor}
|
||||
*/
|
||||
export class MournbladeActor extends Actor {
|
||||
prepareData() {
|
||||
super.prepareData();
|
||||
|
||||
// Calculate derived attributes
|
||||
const data = this.system;
|
||||
|
||||
// Calculate total health
|
||||
data.sante.total = data.sante.base + data.sante.bonus;
|
||||
|
||||
// Calculate current health
|
||||
data.sante.current = data.sante.total - data.sante.nonletaux - data.sante.letaux;
|
||||
|
||||
// Calculate total ame
|
||||
data.ame.total = data.ame.fullmax;
|
||||
|
||||
// Calculate balance
|
||||
data.balance.total = data.balance.loi + data.balance.chaos;
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
this.prepareData();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
@@ -64,22 +86,38 @@ export class MournbladeActor extends Actor {
|
||||
let combat = this.getCombatValues()
|
||||
if (arme.system.typearme == "contact" || arme.system.typearme == "contactjet") {
|
||||
arme.system.isMelee = true
|
||||
arme.system.competence = foundry.utils.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 + combat.attaqueModifier
|
||||
if (arme.system.isdefense) {
|
||||
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef
|
||||
let competence = this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée")
|
||||
if (competence) {
|
||||
arme.system.competence = foundry.utils.duplicate(competence)
|
||||
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 + combat.attaqueModifier
|
||||
if (arme.system.isdefense) {
|
||||
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef
|
||||
}
|
||||
} else {
|
||||
arme.system.competence = null
|
||||
arme.system.totalOffensif = 0
|
||||
arme.system.totalDegats = arme.system.degats
|
||||
arme.system.totalDefensif = 0
|
||||
}
|
||||
}
|
||||
if (arme.system.typearme == "jet" || arme.system.typearme == "tir") {
|
||||
arme.system.isDistance = true
|
||||
arme.system.competence = foundry.utils.duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance"))
|
||||
arme.system.attrKey = "adr"
|
||||
arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff + combat.attaqueModifier
|
||||
arme.system.totalDegats = arme.system.degats
|
||||
if (arme.system.isdefense) {
|
||||
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef
|
||||
let competence = this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance")
|
||||
if (competence) {
|
||||
arme.system.competence = foundry.utils.duplicate(competence)
|
||||
arme.system.attrKey = "adr"
|
||||
arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff + combat.attaqueModifier
|
||||
arme.system.totalDegats = arme.system.degats
|
||||
if (arme.system.isdefense) {
|
||||
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef
|
||||
}
|
||||
} else {
|
||||
arme.system.competence = null
|
||||
arme.system.totalOffensif = 0
|
||||
arme.system.totalDegats = arme.system.degats
|
||||
arme.system.totalDefensif = 0
|
||||
}
|
||||
}
|
||||
return arme
|
||||
@@ -88,13 +126,21 @@ export class MournbladeActor extends Actor {
|
||||
prepareBouclier(bouclier) {
|
||||
bouclier = foundry.utils.duplicate(bouclier)
|
||||
let combat = this.getCombatValues()
|
||||
bouclier.system.competence = foundry.utils.duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée"))
|
||||
bouclier.system.attrKey = "pui"
|
||||
bouclier.system.totalDegats = bouclier.system.degats + "+" + combat.bonusDegatsTotal
|
||||
bouclier.system.totalOffensif = this.system.attributs.pui.value + bouclier.system.competence.system.niveau
|
||||
bouclier.system.isdefense = true
|
||||
bouclier.system.bonusmaniementoff = 0
|
||||
bouclier.system.totalDefensif = combat.defenseTotal + bouclier.system.competence.system.niveau + bouclier.system.bonusdefense
|
||||
let competence = this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée")
|
||||
if (competence) {
|
||||
bouclier.system.competence = foundry.utils.duplicate(competence)
|
||||
bouclier.system.attrKey = "pui"
|
||||
bouclier.system.totalDegats = bouclier.system.degats + "+" + combat.bonusDegatsTotal
|
||||
bouclier.system.totalOffensif = this.system.attributs.pui.value + bouclier.system.competence.system.niveau
|
||||
bouclier.system.isdefense = true
|
||||
bouclier.system.bonusmaniementoff = 0
|
||||
bouclier.system.totalDefensif = combat.defenseTotal + bouclier.system.competence.system.niveau + bouclier.system.bonusdefense
|
||||
} else {
|
||||
bouclier.system.competence = null
|
||||
bouclier.system.totalOffensif = 0
|
||||
bouclier.system.totalDegats = bouclier.system.degats
|
||||
bouclier.system.totalDefensif = 0
|
||||
}
|
||||
return bouclier
|
||||
}
|
||||
|
||||
@@ -258,11 +304,13 @@ export class MournbladeActor extends Actor {
|
||||
|
||||
if (this.type == 'personnage') {
|
||||
let newSante = this.system.sante.bonus + (this.system.attributs.pui.value + this.system.attributs.tre.value) * 2 + 5
|
||||
if (this.system.sante.base != newSante) {
|
||||
if (this.system.sante.base != newSante && this._id) {
|
||||
// Only update if the actor already exists (has an _id)
|
||||
this.update({ 'system.sante.base': newSante })
|
||||
}
|
||||
let newAme = (this.system.attributs.cla.value + this.system.attributs.tre.value) * this.system.biodata.amemultiplier + 5
|
||||
if (this.system.ame.fullmax != newAme) {
|
||||
if (this.system.ame.fullmax != newAme && this._id) {
|
||||
// Only update if the actor already exists (has an _id)
|
||||
this.update({ 'system.ame.fullmax': newAme })
|
||||
}
|
||||
}
|
||||
@@ -589,16 +637,14 @@ export class MournbladeActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async rollAttribut(attrKey) {
|
||||
let rollData = this.getCommonRollData(attrKey)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
await MournbladeRollDialog.create(this, rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetence(attrKey, compId) {
|
||||
let rollData = this.getCommonRollData(attrKey, compId)
|
||||
console.log("RollDatra", rollData)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
await MournbladeRollDialog.create(this, rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -614,8 +660,7 @@ export class MournbladeActor extends Actor {
|
||||
rollData.runemode = "prononcer"
|
||||
rollData.runeame = 1
|
||||
console.log("runeData", rollData)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
await MournbladeRollDialog.create(this, rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -642,8 +687,7 @@ export class MournbladeActor extends Actor {
|
||||
}
|
||||
console.log("ARME!", rollData)
|
||||
this.depenseRessources(arme)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
await MournbladeRollDialog.create(this, rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -657,8 +701,7 @@ export class MournbladeActor extends Actor {
|
||||
rollData.difficulte = rollData.defender.system.attributs.tre.value * 2
|
||||
}
|
||||
console.log("Assomer!", rollData)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
await MournbladeRollDialog.create(this, rollData)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async rollFuir() {
|
||||
@@ -672,8 +715,7 @@ export class MournbladeActor extends Actor {
|
||||
rollData.difficulte = rollData.defender.system.attributs.adr.value + ((comp) ? comp.system.niveau : rollData.defender.system.attributs.adr.value)
|
||||
}
|
||||
console.log("Fuir!", rollData)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
await MournbladeRollDialog.create(this, rollData)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async rollImmobiliser() {
|
||||
@@ -686,15 +728,14 @@ export class MournbladeActor extends Actor {
|
||||
rollData.difficulte = rollData.defenderCombatValues.defenseTotal
|
||||
}
|
||||
console.log("Immobiliser!", rollData)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
await MournbladeRollDialog.create(this, rollData)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async rollArmeSpecial(armeId) {
|
||||
let arme = this.items.get(armeId)
|
||||
if (arme) {
|
||||
MournbladeUtility.createChatWithRollMode("GM", {
|
||||
content: await renderTemplate(`systems/fvtt-mournblade/templates/chat-display-description.html`, arme)
|
||||
content: await renderTemplate(`systems/fvtt-mournblade/templates/chat-display-description.hbs`, arme)
|
||||
}, arme)
|
||||
this.depenseRessources(arme)
|
||||
}
|
||||
@@ -722,7 +763,7 @@ export class MournbladeActor extends Actor {
|
||||
actionImg: arme.img,
|
||||
}
|
||||
MournbladeUtility.createChatWithRollMode(rollData.alias, {
|
||||
content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-mournblade/templates/chat-degats-result.html`, rollData)
|
||||
content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-mournblade/templates/chat-degats-result-v2.hbs`, rollData)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user