Ajout item Blessure
This commit is contained in:
@ -78,6 +78,7 @@ export class RdDBaseActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static filterItemsPerTypeForSheet(formData, itemTypes) {
|
||||
formData.blessures = Misc.arrayOrEmpty(itemTypes['blessure']);
|
||||
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']);
|
||||
formData.recettesAlchimiques = Misc.arrayOrEmpty(itemTypes['recettealchimique']);
|
||||
formData.maladies = Misc.arrayOrEmpty(itemTypes['maladie']);
|
||||
|
@ -33,7 +33,7 @@ const typesObjetsDraconiques = ["queue", "ombre", "souffle", "tete", "signedraco
|
||||
const typesObjetsConnaissance = ["meditation", "recettealchimique", "sort"]
|
||||
const typesObjetsEffet = ["possession", "poison", "maladie"]
|
||||
const typesObjetsCompetence = ["competence", "competencecreature"]
|
||||
const typesObjetsTemporels = ["poison", "maladie", "queue", "ombre", "souffle", "signedraconique", "rencontre"]
|
||||
const typesObjetsTemporels = ["blessure", "poison", "maladie", "queue", "ombre", "souffle", "signedraconique", "rencontre"]
|
||||
const typesEnvironnement = typesInventaireMateriel;
|
||||
const encBrin = 0.00005; // un brin = 1 décigramme = 1/10g = 1/10000kg = 1/20000 enc
|
||||
const encPepin = 0.0007; /* un pépin de gemme = 1/10 cm3 = 1/1000 l = 3.5/1000 kg = 7/2000 kg = 7/1000 enc
|
||||
|
19
module/item/blessure.js
Normal file
19
module/item/blessure.js
Normal file
@ -0,0 +1,19 @@
|
||||
import { RdDItem } from "../item.js";
|
||||
|
||||
export class RdDItemBlessure extends RdDItem {
|
||||
|
||||
static get defaultIcon() {
|
||||
return "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp";
|
||||
}
|
||||
|
||||
async calculerFinPeriodeTemporel(debut) {
|
||||
return await debut.nouveauJour().addJours(this.system.gravite);
|
||||
}
|
||||
|
||||
async onFinPeriode(oldTimestamp, newTimestamp) {
|
||||
if (this.system.gravite <= 0) {
|
||||
await super.onFinPeriode(oldTimestamp, newTimestamp)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
16
module/item/sheet-blessure.js
Normal file
16
module/item/sheet-blessure.js
Normal file
@ -0,0 +1,16 @@
|
||||
import { RdDItemSheet } from "../item-sheet.js";
|
||||
|
||||
export class RdDBlessureItemSheet extends RdDItemSheet {
|
||||
|
||||
static get ITEM_TYPE() { return "blessure" };
|
||||
|
||||
async getData() {
|
||||
const formData = await super.getData();
|
||||
formData.disabled = formData.options.isGM || formData.options.isOwned ? '' : 'disabled';
|
||||
return formData;
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
}
|
||||
}
|
@ -416,6 +416,49 @@ class _10_5_0_UpdatePeriodicite extends Migration {
|
||||
}
|
||||
}
|
||||
|
||||
class _10_7_0_MigrationBlessures extends Migration {
|
||||
get code() { return "migration-blessures"; }
|
||||
get version() { return "10.7.0"; }
|
||||
|
||||
async migrate() {
|
||||
const timestamp = game.system.rdd.calendrier.getTimestamp()
|
||||
await Promise.all(game.actors.filter(it => it.isPersonnage() || it.isCreature())
|
||||
.map(async (actor) => {
|
||||
const legeres = actor.system.blessures?.legeres.liste.filter(it => it.active).map(it => this.creerBlessure(2, 'légère', it, timestamp)) ?? [];
|
||||
const graves = actor.system.blessures?.graves.liste.filter(it => it.active).map(it => this.creerBlessure(4, 'grave', it, timestamp)) ?? [];
|
||||
const critiques = actor.system.blessures?.critiques.liste.filter(it => it.active).map(it => this.creerBlessure(6, 'critique', it, timestamp));
|
||||
const blessures = legeres.concat(graves).concat(critiques);
|
||||
if (blessures.length > 0) {
|
||||
await actor.createEmbeddedDocuments("Item", blessures);
|
||||
}
|
||||
await actor.update({
|
||||
'system.blessures.legeres.liste': [],
|
||||
'system.blessures.graves.liste': [],
|
||||
'system.blessures.critiques.liste': []
|
||||
})
|
||||
}));
|
||||
}
|
||||
creerBlessure(gravite, graviteTexte, blessure, timestamp) {
|
||||
const dateBlessure = timestamp.addJours(-blessure.jours);
|
||||
const datePremiereRecup = dateBlessure.addJours(gravite);
|
||||
return {
|
||||
name: `Blessure ${graviteTexte}`,
|
||||
type: 'blessure',
|
||||
img: `systems/foundryvtt-reve-de-dragon/icons/sante/blessure${blessure.psdone ? '-soins' : ''}.webp`,
|
||||
system: {
|
||||
gravite: gravite,
|
||||
difficulte: -gravite,
|
||||
debut: { indexDate: dateBlessure.indexDate, indexMinute: 0 },
|
||||
fin: { indexDate: datePremiereRecup.indexDate, indexMinute: 0 },
|
||||
premierssoins: { done: blessure.psdone, bonus: blessure.premiers_soins },
|
||||
soinscomplets: { done: blessure.scdone, bonus: blessure.soins_complets },
|
||||
localisation: blessure.localisation,
|
||||
jours: blessure.jours
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class Migrations {
|
||||
static getMigrations() {
|
||||
return [
|
||||
@ -431,6 +474,7 @@ export class Migrations {
|
||||
new _10_3_17_Monnaies(),
|
||||
new _10_4_6_ServicesEnCommerces(),
|
||||
new _10_5_0_UpdatePeriodicite(),
|
||||
new _10_7_0_MigrationBlessures(),
|
||||
];
|
||||
}
|
||||
|
||||
@ -447,7 +491,7 @@ export class Migrations {
|
||||
migrate() {
|
||||
const currentVersion = game.settings.get(SYSTEM_RDD, "systemMigrationVersion");
|
||||
if (isNewerVersion(game.system.version, currentVersion)) {
|
||||
//if (true) { /* comment previous and uncomment here to test before upgrade */
|
||||
//if (true) { /* comment previous and uncomment here to test before upgrade */
|
||||
const migrations = Migrations.getMigrations().filter(m => isNewerVersion(m.version, currentVersion));
|
||||
if (migrations.length > 0) {
|
||||
migrations.sort((a, b) => this.compareVersions(a, b));
|
||||
|
@ -36,6 +36,7 @@ import { RdDActorVehiculeSheet } from "./actor-vehicule-sheet.js";
|
||||
import { RdDActorEntiteSheet } from "./actor-entite-sheet.js";
|
||||
|
||||
import { RdDItem } from "./item.js";
|
||||
import { RdDItemBlessure } from "./item/blessure.js";
|
||||
import { RdDItemService } from "./item/service.js";
|
||||
import { RdDItemMaladie } from "./item/maladie.js";
|
||||
import { RdDItemPoison } from "./item/poison.js";
|
||||
@ -46,6 +47,7 @@ import { RdDItemSouffle } from "./item/souffle.js";
|
||||
import { RdDRencontre } from "./item/rencontre.js";
|
||||
|
||||
import { RdDItemSheet } from "./item-sheet.js";
|
||||
import { RdDBlessureItemSheet } from "./item/sheet-blessure.js";
|
||||
import { RdDServiceItemSheet } from "./item/sheet-service.js";
|
||||
import { RdDRencontreItemSheet } from "./item/sheet-rencontre.js";
|
||||
import { RdDHerbeItemSheet } from "./item/sheet-herbe.js";
|
||||
@ -74,6 +76,7 @@ export class SystemReveDeDragon {
|
||||
this.RdDUtility = RdDUtility;
|
||||
this.RdDHotbar = RdDHotbar;
|
||||
this.itemClasses = {
|
||||
blessure: RdDItemBlessure,
|
||||
service: RdDItemService,
|
||||
maladie: RdDItemMaladie,
|
||||
poison: RdDItemPoison,
|
||||
@ -157,6 +160,7 @@ export class SystemReveDeDragon {
|
||||
RdDItemSheet.register(RdDPlanteItemSheet);
|
||||
RdDItemSheet.register(RdDIngredientItemSheet);
|
||||
RdDItemSheet.register(RdDServiceItemSheet);
|
||||
RdDItemSheet.register(RdDBlessureItemSheet);
|
||||
|
||||
Items.registerSheet(SYSTEM_RDD, RdDItemInventaireSheet, {
|
||||
types: [
|
||||
@ -276,7 +280,6 @@ export class SystemReveDeDragon {
|
||||
let sidebar = document.getElementById("sidebar");
|
||||
sidebar.style.width = "min-content";
|
||||
}
|
||||
|
||||
if (Misc.isUniqueConnectedGM()) {
|
||||
game.system.rdd.calendrier = new RdDCalendrier();
|
||||
new Migrations().migrate();
|
||||
|
@ -140,6 +140,7 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor/combat.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor/blessures.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor/blessure.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor/blessure.hbs',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor/maladies-poisons.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor/possessions.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor/taches.html',
|
||||
|
Reference in New Issue
Block a user