Ajout item Blessure

This commit is contained in:
Vincent Vandemeulebrouck 2023-03-10 22:37:21 +01:00
parent 4f5fb63751
commit 2598ae3489
15 changed files with 181 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
icons/sante/blessure.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -9,6 +9,7 @@
"ITEM": {
"TypeArme": "Arme",
"TypeArmure": "Armure",
"TypeBlessure": "Blessure",
"TypeCasetmr": "TMR spéciale",
"TypeChant": "Chant",
"TypeCompetence": "Compétence",

View File

@ -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']);

View File

@ -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
View 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)
}
}
}

View 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);
}
}

View File

@ -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));

View File

@ -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();

View File

@ -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',

View File

@ -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);

View File

@ -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"],

View File

@ -0,0 +1,22 @@
<li class="item flexrow list-item blessure-active-{{system.gravite}}" data-item-id="{{_id}}">
<span class="blessure-control" title="{{name}}">
<i class="fas fa-skull-crossbones" name="blessure-{{_id}}-bones"></i>
{{name}}
</span>
<span class="blessure-soins flexrow">
<input type="checkbox" class="blessure-premierssoins-done" name="{{_id}}.system.premierssoins.done" {{#if system.premierssoins.done}}checked{{/if}}/>
<input type="text" class="blessure-premierssoins-bonus" name="{{_id}}.system.premierssoins.bonus" data-dtype="number" value="{{system.premierssoins.bonus}}"/>
</span>
<span class="blessure-soins flexrow">
<input type="checkbox" class="blessure-soinscomplets-done" name="{{_id}}.system.soinscomplets.done" {{#if system.soinscomplets.done}}checked{{/if}}/>
<input type="text" class="blessure-soinscomplets-bonus" name="{{_id}}.system.soinscomplets.bonus" data-dtype="number" value="{{system.soinscomplets.bonus}}"/>
</span>
<input type="text" class="blessure-jours" name="{{_id}}.system.jours" name="jours" data-dtype="number" value="{{system.jours}}"/>
<input type="text" class="blessure-localisation" name="{{_id}}.system.localisation" data-dtype="String" value="{{system.localisation}}"/>
<span class="item-controls">
<a class="item-edit" title="Editer"><i class="fas fa-edit"></i></a>
<a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
<a class="item-montrer" title="Montrer"><i class="fas fa-comment"></i></a>
</span>
</li>

View File

@ -5,6 +5,8 @@
<span>Soins complets</span>
<span>Age (jours)</span>
<span>Localisation</span>
<span>Actions</span>
</li>
{{#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}}
</ul>

View File

@ -0,0 +1,43 @@
<form class="{{cssClass}}" autocomplete="off">
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
<section class="sheet-body">
<div class="form-group">
<label for="system.gravite">Gravité</label>
<select name="system.gravite" class="gravite" data-dtype="Number">
{{#select system.gravite}}
<option value="0">Contusion / Eraflure</option>
<option value="2">Légère</option>
<option value="4">Grave</option>
<option value="6">Critique</option>
{{/select}}
</select>
</div>
<div class="form-group">
<label for="system.localisation">Localisation</label>
<input class="attribute-value" type="text" name="system.localisation" value="{{system.localisation}}" data-dtype="String"/>
</div>
<div class="form-group">
<label for="system.premierssoins.done">Premiers soins
<input class="attribute-value" type="checkbox" name="system.premierssoins.done" {{#if system.premierssoins.done}}checked{{/if}}/>
</label>
{{#if system.premierssoins.done}}
<input class="attribute-value" type="text" name="system.premierssoins.bonus" value="{{system.premierssoins.bonus}}" data-dtype="Number"/>
{{/if}}
</div>
<div class="form-group">
<label for="system.soinscomplets.done">Soins complets
<input class="attribute-value" type="checkbox" name="system.soinscomplets.done" {{#if system.soinscomplets.done}}checked{{/if}}/>
</label>
{{#if system.soinscomplets.done}}
<input class="attribute-value" type="text" name="system.soinscomplets.bonus" value="{{system.soinscomplets.bonus}}" data-dtype="Number"/>
{{/if}}
</div>
{{#if options.isOwned}}
{{>"systems/foundryvtt-reve-de-dragon/templates/item/temporel.hbs" this labeldebut="Obtenue" labelfin="Prochain jet"}}
{{/if}}
</section>
</form>