diff --git a/icons/sante/blessure-soins.webp b/icons/sante/blessure-soins.webp new file mode 100644 index 00000000..a8c317d7 Binary files /dev/null and b/icons/sante/blessure-soins.webp differ diff --git a/icons/sante/blessure.webp b/icons/sante/blessure.webp new file mode 100644 index 00000000..f3901608 Binary files /dev/null and b/icons/sante/blessure.webp differ diff --git a/lang/fr.json b/lang/fr.json index 435aeb04..a671f680 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -9,6 +9,7 @@ "ITEM": { "TypeArme": "Arme", "TypeArmure": "Armure", + "TypeBlessure": "Blessure", "TypeCasetmr": "TMR spéciale", "TypeChant": "Chant", "TypeCompetence": "Compétence", diff --git a/module/actor/base-actor-sheet.js b/module/actor/base-actor-sheet.js index 9ac21339..11429c01 100644 --- a/module/actor/base-actor-sheet.js +++ b/module/actor/base-actor-sheet.js @@ -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']); diff --git a/module/item.js b/module/item.js index 74b59594..9195b29f 100644 --- a/module/item.js +++ b/module/item.js @@ -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 diff --git a/module/item/blessure.js b/module/item/blessure.js new file mode 100644 index 00000000..7b445bc0 --- /dev/null +++ b/module/item/blessure.js @@ -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) + } + } + +} \ No newline at end of file diff --git a/module/item/sheet-blessure.js b/module/item/sheet-blessure.js new file mode 100644 index 00000000..3d5e7ebf --- /dev/null +++ b/module/item/sheet-blessure.js @@ -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); + } +} diff --git a/module/migrations.js b/module/migrations.js index 8b97047c..b1d3513f 100644 --- a/module/migrations.js +++ b/module/migrations.js @@ -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)); diff --git a/module/rdd-main.js b/module/rdd-main.js index d25d622e..849a7a48 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -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(); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 460b96bb..68f0f232 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -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', diff --git a/styles/simple.css b/styles/simple.css index 01c3c55b..c4adf335 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -426,6 +426,7 @@ span.equipement-detail-buttons { justify-content: center; text-align: left; } + .blessure-control { flex-grow: 1; flex-direction: row; @@ -457,14 +458,17 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) { .blessure-inactive { color:rgba(150, 150, 150, 0.4); } +.blessure-active-2, .blessure-active-legere { color:rgba(60, 60, 60, 0.9); text-shadow: 1px 1px 4px rgba(60, 60, 60, 1); } +.blessure-active-4, .blessure-active-grave { color: rgba(218, 126, 21, 0.9); text-shadow: 1px 1px 4px rgba(60, 60, 60, 1); } +.blessure-active-6, .blessure-active-critique { color: rgba(173, 36, 26, 0.9); text-shadow: 1px 1px 4px rgba(60, 60, 60, 1); diff --git a/template.json b/template.json index 52543e5f..a861e523 100644 --- a/template.json +++ b/template.json @@ -567,7 +567,7 @@ "monnaie", "nourritureboisson", "gemme", "service", "meditation", "rencontre", "queue", "ombre", "souffle", "tete", "casetmr", "signedraconique", "sort", "sortreserve", - "nombreastral", "tache", "maladie", "poison", "possession", + "nombreastral", "tache", "blessure", "maladie", "poison", "possession", "tarot", "extraitpoetique" ], "templates": { @@ -636,6 +636,22 @@ "compteur": 0, "date": 0 }, + "blessure": { + "templates": ["temporel"], + "gravite": 0, + "difficulte": 0, + "premierssoins": { + "tache": 0, + "done": false, + "bonus": 0 + }, + "soinscomplets": { + "done": false, + "bonus": 0 + }, + "localisation": "", + "jours": 0 + }, "maladie": { "templates": ["description", "temporel"], "identifie": false, @@ -833,7 +849,8 @@ "points_de_tache_courant": 0, "nb_jet_echec": 0, "nb_jet_succes": 0, - "cacher_points_de_tache": false + "cacher_points_de_tache": false, + "itemId": "" }, "sort": { "templates": ["description"], diff --git a/templates/actor/blessure.hbs b/templates/actor/blessure.hbs new file mode 100644 index 00000000..a2b9666c --- /dev/null +++ b/templates/actor/blessure.hbs @@ -0,0 +1,22 @@ +
  • + + + {{name}} + + + + + + + + + + + + + + + + + +
  • diff --git a/templates/actor/blessures.html b/templates/actor/blessures.html index fa7705c6..88f185f0 100644 --- a/templates/actor/blessures.html +++ b/templates/actor/blessures.html @@ -5,6 +5,8 @@ Soins complets Age (jours) Localisation + Actions + {{#each system.blessures.legeres.liste as |blessure key|}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/blessure.html" blessure=blessure key=key gravite="legere" title="Légère"}} @@ -15,4 +17,7 @@ {{#each system.blessures.critiques.liste as |blessure key|}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/blessure.html" blessure=blessure key=key gravite="critique" title="Critique"}} {{/each}} + {{#each blessures as |blessure|}} + {{> "systems/foundryvtt-reve-de-dragon/templates/actor/blessure.hbs" blessure}} + {{/each}} diff --git a/templates/item-blessure-sheet.html b/templates/item-blessure-sheet.html new file mode 100644 index 00000000..ea8263bf --- /dev/null +++ b/templates/item-blessure-sheet.html @@ -0,0 +1,43 @@ +
    + {{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}} +
    +
    + + +
    + +
    + + +
    + +
    + + {{#if system.premierssoins.done}} + + {{/if}} +
    + +
    + + {{#if system.soinscomplets.done}} + + {{/if}} +
    + + {{#if options.isOwned}} + {{>"systems/foundryvtt-reve-de-dragon/templates/item/temporel.hbs" this labeldebut="Obtenue" labelfin="Prochain jet"}} + {{/if}} +
    +