Migration datamodels !

This commit is contained in:
2026-01-10 16:05:56 +01:00
parent 627ccc707b
commit 438caf3b1c
3946 changed files with 318813 additions and 3453 deletions

View File

@@ -1,6 +1,6 @@
/* -------------------------------------------- */
import { WastelandUtility } from "./wasteland-utility.js";
import { WastelandRollDialog } from "./wasteland-roll-dialog.js";
import { WastelandRollDialog } from "./applications/wasteland-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]
@@ -53,6 +53,7 @@ export class WastelandActor extends Actor {
arme = foundry.utils.duplicate(arme)
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
@@ -62,6 +63,7 @@ export class WastelandActor extends Actor {
}
}
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
@@ -296,6 +298,10 @@ export class WastelandActor extends Actor {
changeEclat(value) {
let newE = this.system.eclat.value
newE += value
// Empêcher que l'éclat devienne négatif
if (newE < 0) {
newE = 0
}
this.update({ 'system.eclat.value': newE })
}
@@ -382,6 +388,32 @@ export class WastelandActor extends Actor {
await this.updateEmbeddedDocuments('Item', [{ _id: compId, 'system.predilections': pred }])
}
/* -------------------------------------------- */
async resetAllPredilections() {
let updates = []
for (let item of this.items) {
if (item.type === "competence" && item.system.predilections && item.system.predilections.length > 0) {
let pred = foundry.utils.duplicate(item.system.predilections)
let hasUsed = false
for (let p of pred) {
if (p.used) {
p.used = false
hasUsed = true
}
}
if (hasUsed) {
updates.push({ _id: item.id, 'system.predilections': pred })
}
}
}
if (updates.length > 0) {
await this.updateEmbeddedDocuments('Item', updates)
ui.notifications.info(`${updates.length} prédilection(s) réinitialisée(s) pour ${this.name}`)
} else {
ui.notifications.info(`Aucune prédilection à réinitialiser pour ${this.name}`)
}
}
/* -------------------------------------------- */
getInitiativeScore( ) {
return Number(this.system.attributs.adr.value) + Number(this.system.combat.initbonus)
@@ -414,10 +446,12 @@ export class WastelandActor extends Actor {
rollData.actorId = this.id
rollData.tokenId = this.token?.id
rollData.img = this.img
rollData.canEclatDoubleD20 = true // Always true in Wastelan
rollData.canEclatDoubleD20 = this.getEclat() >= 1 // Vérifier que l'acteur a au moins 1 point d'éclat
rollData.doubleD20 = false
rollData.attributs = WastelandUtility.getAttributs()
rollData.config = foundry.utils.duplicate(game.system.wasteland.config)
rollData.desavantages = {}
rollData.isMonte = this.system.combat.monte
if (attrKey) {
rollData.attrKey = attrKey
@@ -440,8 +474,7 @@ export class WastelandActor extends Actor {
/* -------------------------------------------- */
async launchRoll(rollData) {
console.log("RollData", rollData)
let rollDialog = await WastelandRollDialog.create(this, rollData)
rollDialog.render(true)
await WastelandRollDialog.create(this, rollData)
}
/* -------------------------------------------- */
rollAttribut(attrKey) {
@@ -467,7 +500,7 @@ export class WastelandActor extends Actor {
async rollPouvoir(pouvoirId) {
let pouvoir = foundry.utils.duplicate(this.items.get(pouvoirId) || {})
if (pouvoir?.system) {
let rollData = this.getCommonRollData(pouvoir.system.attribut, undefined, pouvoir.system.competence)
let rollData = this.getCommonRollData(pouvoir.system.attribut1, undefined, pouvoir.system.competence)
if (!rollData.competence) {
ui.notifications.error("Le pouvoir " + pouvoir.name + " n'a pas de compétence associée. Editez le pouvoir avec la compétence associée.")
return
@@ -488,6 +521,12 @@ export class WastelandActor extends Actor {
}
let rollData = this.getCommonRollData(arme.system.attrKey, arme.system.competence._id)
rollData.arme = arme
rollData.typeAttaque = "assaut"
rollData.typeCouvert = "aucun"
rollData.hasDesavantageBonus = true
rollData.visee = false
rollData.ciblecourt = false
rollData.cibleconsciente = false
this.launchRoll(rollData)
}
@@ -511,8 +550,52 @@ export class WastelandActor extends Actor {
actionImg: arme.img,
}
WastelandUtility.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-wasteland/templates/chat-degats-result.html`, rollData)
content: await foundry.applications.handlebars.renderTemplate(`systems/fvtt-wasteland/templates/chat-degats-result-v2.hbs`, rollData)
})
}
/* -------------------------------------------- */
async rollAssommer() {
let rollData = this.getCommonRollData("adr", undefined, "Mouvements")
rollData.specialAction = "Assommer"
rollData.typeAttaque = "assommer"
rollData.typeCouvert = "aucun"
rollData.hasDesavantageBonus = true
if (rollData.defender) {
rollData.selectDifficulte = false
rollData.difficulte = rollData.defender.system.attributs.tre.value * 2
}
this.launchRoll(rollData)
}
/* -------------------------------------------- */
async rollFuir() {
let rollData = this.getCommonRollData("adr", undefined, "Mouvements")
rollData.specialAction = "Fuir"
rollData.typeAttaque = "fuir"
rollData.typeCouvert = "aucun"
rollData.hasDesavantageBonus = true
if (rollData.defender) {
rollData.selectDifficulte = false
let comp = rollData.defender.items.find(it => it.type == "competence" && it.name.toLowerCase() == "mouvements")
rollData.difficulte = rollData.defender.system.attributs.adr.value + ((comp) ? comp.system.niveau : rollData.defender.system.attributs.adr.value)
}
this.launchRoll(rollData)
}
/* -------------------------------------------- */
async rollImmobiliser() {
let rollData = this.getCommonRollData("pui", undefined, "Mêlée")
rollData.specialAction = "Immobiliser"
rollData.typeAttaque = "immobiliser"
rollData.typeCouvert = "aucun"
rollData.hasDesavantageBonus = true
if (rollData.defender) {
rollData.selectDifficulte = false
rollData.difficulte = rollData.armeDefense ? rollData.armeDefense.system.totalDefensif : 10
}
this.launchRoll(rollData)
}
}