Gestion des signes draconiques #455
110
module/item-signedraconique-sheet.js
Normal file
110
module/item-signedraconique-sheet.js
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
import { Misc } from "./misc.js";
|
||||||
|
import { TMRType } from "./tmr-utility.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item sheet pour signes draconiques
|
||||||
|
* @extends {ItemSheet}
|
||||||
|
*/
|
||||||
|
export class RdDSigneDraconiqueItemSheet extends ItemSheet {
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
static get defaultOptions() {
|
||||||
|
return mergeObject(super.defaultOptions, {
|
||||||
|
classes: ["foundryvtt-reve-de-dragon", "sheet", "item"],
|
||||||
|
template: "systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html",
|
||||||
|
width: 550,
|
||||||
|
height: 550
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
_getHeaderButtons() {
|
||||||
|
let buttons = super._getHeaderButtons();
|
||||||
|
buttons.unshift({ class: "post", icon: "fas fa-comment", onclick: ev => this.item.postItem() });
|
||||||
|
return buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
/** @override */
|
||||||
|
setPosition(options = {}) {
|
||||||
|
const position = super.setPosition(options);
|
||||||
|
const sheetHeader = this.element.find(".sheet-header");
|
||||||
|
const sheetBody = this.element.find(".sheet-body");
|
||||||
|
const bodyHeight = position.height - sheetHeader[0].clientHeight;
|
||||||
|
sheetBody.css("height", bodyHeight);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async getData() {
|
||||||
|
const formData = duplicate(Misc.data(this.object));
|
||||||
|
mergeObject(formData, {
|
||||||
|
title: formData.name,
|
||||||
|
isGM: game.user.isGM,
|
||||||
|
owner: this.document.isOwner,
|
||||||
|
isOwned: this.actor ? true : false,
|
||||||
|
actorId: this.actor?.id,
|
||||||
|
editable: this.isEditable,
|
||||||
|
cssClass: this.isEditable ? "editable" : "locked",
|
||||||
|
});
|
||||||
|
formData.tmrs = RdDSigneDraconiqueItemSheet.listTMRTypes(formData.data.typesTMR ?? []);
|
||||||
|
return formData;
|
||||||
|
}
|
||||||
|
|
||||||
|
static listTMRTypes(typesTMR) {
|
||||||
|
return Object.values(TMRType).map(value => Misc.upperFirst(value.name))
|
||||||
|
.sort()
|
||||||
|
.map(name => { return { name: name, selected: typesTMR.includes(name) } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
/** @override */
|
||||||
|
activateListeners(html) {
|
||||||
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
if (!this.options.editable) return;
|
||||||
|
|
||||||
|
html.find(".select-tmr").change((event) => this.onSelectTmr(event));
|
||||||
|
html.find(".valeur-xp-sort").change((event) => this.onValeurXpSort(event.currentTarget.attributes['data-typereussite']?.value, Number(event.currentTarget.value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
async onSelectTmr(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const selectedTMR = $(".select-tmr").val();
|
||||||
|
this.object.update({ 'data.typesTMR': selectedTMR });
|
||||||
|
}
|
||||||
|
|
||||||
|
async onValeurXpSort(qualite, valeur) {
|
||||||
|
let tplData = Misc.templateData(this.object);
|
||||||
|
if (valeur != tplData.valeur[qualite])
|
||||||
|
{
|
||||||
|
await this.object.update({ [`data.valeur.${qualite}`]: valeur });
|
||||||
|
|
||||||
|
tplData = Misc.templateData(this.object);
|
||||||
|
switch (qualite) {
|
||||||
|
case "norm":
|
||||||
|
if (valeur > tplData.valeur.sign) await this.object.update({ 'data.valeur.sign': valeur });
|
||||||
|
if (valeur > tplData.valeur.part) await this.object.update({ 'data.valeur.part': valeur });
|
||||||
|
break;
|
||||||
|
case "sign":
|
||||||
|
if (valeur < tplData.valeur.norm) await this.object.update({ 'data.valeur.norm': valeur });
|
||||||
|
if (valeur > tplData.valeur.part) await this.object.update({ 'data.valeur.part': valeur });
|
||||||
|
break;
|
||||||
|
case "part":
|
||||||
|
if (valeur < tplData.valeur.norm) await this.object.update({ 'data.valeur.norm': valeur });
|
||||||
|
if (valeur < tplData.valeur.sign) await this.object.update({ 'data.valeur.sign': valeur });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
get template() {
|
||||||
|
return `systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html`;
|
||||||
|
}
|
||||||
|
|
||||||
|
get title() {
|
||||||
|
return `Signe draconique: ${this.object.name}`;
|
||||||
|
}
|
||||||
|
}
|
37
module/item-signedraconique.js
Normal file
37
module/item-signedraconique.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { Misc } from "./misc.js";
|
||||||
|
|
||||||
|
export class RdDItemSigneDraconique {
|
||||||
|
|
||||||
|
static prepareSigneDraconiqueMeditation(meditation, rolled) {
|
||||||
|
if (rolled.isSuccess != undefined) {
|
||||||
|
meditation = Misc.data(meditation);
|
||||||
|
return {
|
||||||
|
name: "de la " + meditation.name,
|
||||||
|
type: "signedraconique",
|
||||||
|
img: meditation.img,
|
||||||
|
data: {
|
||||||
|
"typesTMR": [Misc.upperFirst(meditation.data.tmr)],
|
||||||
|
"difficulte": RdDItemSigneDraconique.getDiffSigneMeditation(rolled.code),
|
||||||
|
"ephemere": true,
|
||||||
|
"duree": "1 round",
|
||||||
|
"valeur": { "norm": 3, "sign": 5, "part": 10 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getDiffSigneMeditation(code) {
|
||||||
|
switch (code) {
|
||||||
|
case "norm": return -7;
|
||||||
|
case "sign": return -3;
|
||||||
|
case "part": return 0;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getXpSortSigneDraconique(code, signe) {
|
||||||
|
return Misc.data(signe).data.valeur[code] ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -31,6 +31,7 @@ import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
|
|||||||
import { RdDHerbes } from "./rdd-herbes.js";
|
import { RdDHerbes } from "./rdd-herbes.js";
|
||||||
import { RdDItem } from "./item.js";
|
import { RdDItem } from "./item.js";
|
||||||
import { RdDDice } from "./rdd-dice.js";
|
import { RdDDice } from "./rdd-dice.js";
|
||||||
|
import { RdDSigneDraconiqueItemSheet } from "./item-signedraconique-sheet.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Foundry VTT Initialization */
|
/* Foundry VTT Initialization */
|
||||||
@ -167,6 +168,11 @@ Hooks.once("init", async function () {
|
|||||||
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
|
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
|
||||||
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
|
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
|
||||||
Items.unregisterSheet("core", ItemSheet);
|
Items.unregisterSheet("core", ItemSheet);
|
||||||
|
Items.registerSheet("foundryvtt-reve-de-dragon", RdDSigneDraconiqueItemSheet, {
|
||||||
|
label: "Signe draconique",
|
||||||
|
types: ["signedraconique"],
|
||||||
|
makeDefault: true
|
||||||
|
});
|
||||||
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, { makeDefault: true });
|
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, { makeDefault: true });
|
||||||
CONFIG.Combat.documentClass = RdDCombatManager;
|
CONFIG.Combat.documentClass = RdDCombatManager;
|
||||||
|
|
||||||
|
@ -140,6 +140,7 @@ export class RdDUtility {
|
|||||||
'systems/foundryvtt-reve-de-dragon/templates/item-monnaie-sheet.html',
|
'systems/foundryvtt-reve-de-dragon/templates/item-monnaie-sheet.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/item-meditation-sheet.html',
|
'systems/foundryvtt-reve-de-dragon/templates/item-meditation-sheet.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/item-nourritureboisson-sheet.html',
|
'systems/foundryvtt-reve-de-dragon/templates/item-nourritureboisson-sheet.html',
|
||||||
|
'systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html',
|
'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/competence-base.html',
|
'systems/foundryvtt-reve-de-dragon/templates/competence-base.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html',
|
'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html',
|
||||||
@ -271,6 +272,7 @@ export class RdDUtility {
|
|||||||
formData.munitions = this.checkNull(formData.itemsByType['munition']);
|
formData.munitions = this.checkNull(formData.itemsByType['munition']);
|
||||||
formData.herbes = this.checkNull(formData.itemsByType['herbe']);
|
formData.herbes = this.checkNull(formData.itemsByType['herbe']);
|
||||||
formData.sorts = this.checkNull(formData.itemsByType['sort']);
|
formData.sorts = this.checkNull(formData.itemsByType['sort']);
|
||||||
|
formData.signesdraconiques = this.checkNull(formData.itemsByType['signedraconique']);
|
||||||
formData.queues = this.checkNull(formData.itemsByType['queue']);
|
formData.queues = this.checkNull(formData.itemsByType['queue']);
|
||||||
formData.souffles = this.checkNull(formData.itemsByType['souffle']);
|
formData.souffles = this.checkNull(formData.itemsByType['souffle']);
|
||||||
formData.ombres = this.checkNull(formData.itemsByType['ombre']);
|
formData.ombres = this.checkNull(formData.itemsByType['ombre']);
|
||||||
|
@ -577,7 +577,7 @@
|
|||||||
"Item": {
|
"Item": {
|
||||||
"types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle",
|
"types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle",
|
||||||
"tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique",
|
"tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique",
|
||||||
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson" ],
|
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson", "signedraconique" ],
|
||||||
"objet": {
|
"objet": {
|
||||||
"description": "",
|
"description": "",
|
||||||
"quantite": 1,
|
"quantite": 1,
|
||||||
@ -868,6 +868,18 @@
|
|||||||
"encombrement": 0,
|
"encombrement": 0,
|
||||||
"quantite": 1,
|
"quantite": 1,
|
||||||
"cout": 0
|
"cout": 0
|
||||||
|
},
|
||||||
|
"signedraconique": {
|
||||||
|
"typesTMR": [],
|
||||||
|
"ephemere": true,
|
||||||
|
"duree": "1 round",
|
||||||
|
"difficulte": 0,
|
||||||
|
"valeur": {
|
||||||
|
"norm": 3,
|
||||||
|
"sign": 5,
|
||||||
|
"part": 10
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,6 +432,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
{{#if data.attributs.hautrevant.value}}
|
{{#if data.attributs.hautrevant.value}}
|
||||||
|
{{#if options.isGM}}
|
||||||
|
<h3>Signes draconiques</h3>
|
||||||
|
<ul class="item-list alterne-list">
|
||||||
|
{{#each signesdraconiques as |signe key|}}
|
||||||
|
<li class="item list-item flexrow" data-item-id="{{signe._id}}" data-attribute="{{key}}">
|
||||||
|
<span class="display-label flex-grow"> <a data-item-id="{{signe._id}}">{{signe.name}}</a></span>
|
||||||
|
<span class="flex-shrink">{{signe.data.difficulte}}</span>
|
||||||
|
<div class="item-controls flex-shrink">
|
||||||
|
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
{{/if}}
|
||||||
<h3>Sorts:</h3>
|
<h3>Sorts:</h3>
|
||||||
<ul class="item-list alterne-list">
|
<ul class="item-list alterne-list">
|
||||||
{{#each sorts as |sort key|}}
|
{{#each sorts as |sort key|}}
|
||||||
|
55
templates/item-signedraconique-sheet.html
Normal file
55
templates/item-signedraconique-sheet.html
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<form class="{{cssClass}}" autocomplete="off">
|
||||||
|
<header class="sheet-header">
|
||||||
|
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
|
||||||
|
<div class="header-fields">
|
||||||
|
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{{!-- Sheet Body --}}
|
||||||
|
<section class="sheet-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="data.ephemere">Ephémère</label>
|
||||||
|
<input class="attribute-value" type="checkbox" name="data.ephemere" {{#if data.ephemere}}checked{{/if}} />
|
||||||
|
</div>
|
||||||
|
{{#if data.ephemere}}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="data.duree">Durée</label>
|
||||||
|
<input class="attribute-value" type="text" name="data.duree" value="{{data.duree}}" data-dtype="String" />
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="data.difficulte">Difficulte</label>
|
||||||
|
<input class="attribute-value" type="text" name="data.difficulte" value="{{data.difficulte}}"
|
||||||
|
data-dtype="Number" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="data.valeur.norm">Expérience en sorts</label>
|
||||||
|
<div class="flexrow">
|
||||||
|
<input class="valeur-xp-sort" type="number" name="data.valeur.norm" data-typereussite="norm" value="{{data.valeur.norm}}"
|
||||||
|
min="1" max="100" data-dtype="Number" />
|
||||||
|
<span>Sign.</span>
|
||||||
|
<input class="valeur-xp-sort" type="number" name="data.valeur.sign" data-typereussite="sign" value="{{data.valeur.sign}}"
|
||||||
|
min="1" max="100" data-dtype="Number" />
|
||||||
|
<span>Part.</span>
|
||||||
|
<input class="valeur-xp-sort" type="number" name="data.valeur.part" data-typereussite="part" value="{{data.valeur.part}}"
|
||||||
|
min="1" max="100" data-dtype="Number" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="tmrs">Terres médianes</label>
|
||||||
|
<select class="select-tmr attribute-value" name="tmrs" id="tmrs" size={{tmrs.length}} multiple />
|
||||||
|
{{#each tmrs as |tmr key|}}
|
||||||
|
<option class="option-tmr" value="{{tmr.name}}" {{#if tmr.selected}}selected{{/if}}>{{tmr.name}}</option>
|
||||||
|
{{/each}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="flexcol">
|
||||||
|
<span><label>Description : </label></span>
|
||||||
|
<div class="form-group editor">
|
||||||
|
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</form>
|
Loading…
Reference in New Issue
Block a user