Gestion des entités

This commit is contained in:
sladecraven 2020-11-14 23:24:01 +01:00
parent 01fe858b8c
commit bb236ab012
9 changed files with 373 additions and 16 deletions

View File

@ -0,0 +1,130 @@
/**
* Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet}
*/
import { RdDUtility } from "./rdd-utility.js";
/* -------------------------------------------- */
export class RdDActorEntiteSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["rdd", "sheet", "actor"],
template: "systems/foundryvtt-reve-de-dragon/templates/actor-entite-sheet.html",
width: 640,
height: 720,
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac"}],
dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}]
});
}
/* -------------------------------------------- */
_checkNull(items) {
if (items && items.length) {
return items;
}
return [];
}
/* -------------------------------------------- */
getData() {
let data = super.getData();
data.itemsByType = {};
for (const item of data.items) {
let list = data.itemsByType[item.type];
if (!list) {
list = [];
data.itemsByType[item.type] = list;
}
list.push(item);
}
data.data.carac.taille.isTaille = true; // To avoid button link;
data.data.competencecreature = data.itemsByType["competencecreature"];
return data;
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
// Update Inventory Item
html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.actor.getOwnedItem(li.data("itemId"));
item.sheet.render(true);
});
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
this.actor.deleteOwnedItem(li.data("itemId"));
li.slideUp(200, () => this.render(false));
});
// Roll Carac
html.find('.carac-label a').click((event) => {
let caracName = event.currentTarget.attributes.name.value;
this.actor.rollCarac( caracName.toLowerCase() );
});
// On competence change
html.find('.creature-carac').change((event) => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "carac_value", parseInt(event.target.value) );
} );
html.find('.creature-niveau').change((event) => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "niveau", parseInt(event.target.value) );
} );
html.find('.creature-dommages').change((event) => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "dommages", parseInt(event.target.value) );
} );
// Roll Skill
html.find('.competence-label a').click((event) => {
let compName = event.currentTarget.text;
this.actor.rollCompetence( compName );
});
html.find('#endurance-plus').click((event) => {
this.actor.santeIncDec("endurance", 1);
this.render(true);
});
html.find('#endurance-moins').click((event) => {
this.actor.santeIncDec("endurance", -1);
this.render(true);
});
}
/* -------------------------------------------- */
/** @override */
setPosition(options={}) {
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
return position;
}
/* -------------------------------------------- */
/** @override */
_updateObject(event, formData) {
// Update the Actor
return this.object.update(formData);
}
}

View File

@ -33,17 +33,14 @@ export class RdDActor extends Actor {
data.items = [];
let compendiumName = "";
if (data.type == "personnage")
{
if (data.type == "personnage") {
compendiumName = "foundryvtt-reve-de-dragon.competences";
}
if (data.type == "humanoide")
{
} else if (data.type == "humanoide") {
compendiumName = "foundryvtt-reve-de-dragon.competences-humanoides";
}
if (data.type == "creature")
{
} else if (data.type == "creature") {
compendiumName = "foundryvtt-reve-de-dragon.competences-creatures";
} else if (data.type == "entite") {
compendiumName = "foundryvtt-reve-de-dragon.competences-entites";
}
let competences = [];
const pack = game.packs.get(compendiumName);

View File

@ -13,6 +13,7 @@ import { RdDItemSheet } from "./item-sheet.js";
import { RdDActorSheet } from "./actor-sheet.js";
import { RdDActorCreatureSheet } from "./actor-creature-sheet.js";
import { RdDActorHumanoideSheet } from "./actor-humanoide-sheet.js";
import { RdDActorEntiteSheet } from "./actor-entite-sheet.js";
import { RdDUtility } from "./rdd-utility.js";
import { RdDCalendrier } from "./rdd-calendrier.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js";
@ -130,14 +131,18 @@ Hooks.once("init", async function() {
types: ["personnage"],
makeDefault: true }
);
Actors.registerSheet("wfrp4e", RdDActorCreatureSheet, {
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorCreatureSheet, {
types: ["creature"],
makeDefault: true
});
Actors.registerSheet("wfrp4e", RdDActorHumanoideSheet, {
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorHumanoideSheet, {
types: ["humanoide"],
makeDefault: true
});
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorEntiteSheet, {
types: ["entite"],
makeDefault: true
});
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, {makeDefault: true});

View File

@ -92,6 +92,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/actor-creature-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/actor-humanoide-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/actor-entite-sheet.html',
//Items
'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-competencecreature-sheet.html',
@ -127,7 +128,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html',
// Calendrier
'systems/foundryvtt-reve-de-dragon/templates/calendar_template.html',
'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html',
// Conteneur/item in Actor sheet
'systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html'
];

38
packs/animaux.db Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,17 @@
{"name":"Esquive","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"<p>Morsure de la créature</p>"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_esquive.png","effects":[],"_id":"0Ms9iKxqigNNpZEx"}
{"_id":"18wcei5hlEInsBFO","name":"Attaque","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-griffes.png","effects":[]}
{"_id":"3Crwg8cx2JOb697T","name":"Parade","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_saut.png","effects":[]}
{"_id":"QGULMUoC9JXFze0r","name":"Bouclier Lourd","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_bouclier.png","effects":[]}
{"_id":"WsYnwR8GcOxfuCI0","name":"Bras-Galet","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_course.png","effects":[]}
{"name":"Corps à Corps","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.png","effects":[],"_id":"c0I93Q53i4ZmxpyT"}
{"name":"Morsure","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"<p>Morsure de la créature</p>"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-morsure.png","effects":[],"_id":"j1xHCzfIeYKgXxoH"}
{"name":"Bec","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>"},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-creatures.os88Rsp7mBkahqmh"}},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-beak.png","effects":[],"_id":"d5SZ09sFaG3cL2Rg"}
{"name":"Griffes et Crocs","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>"},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-creatures.BjqRrGtHtTzuNpZB"}},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-griffes.png","effects":[],"_id":"9Y83OsQgeyR5oCdH"}
{"_id":"9Y83OsQgeyR5oCdH","name":"Griffes","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-creatures.BjqRrGtHtTzuNpZB"}},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-griffes.png","effects":[]}
{"_id":"3Crwg8cx2JOb697T","name":"Parade","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_saut.png","effects":[]}
{"name":"Epée Sorde","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>"},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-humanoides.YTKld5ggDsHqwYoR"}},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_epee_1_main.png","effects":[],"_id":"gPOQd9NI7AFH0whX"}
{"_id":"gPOQd9NI7AFH0whX","name":"Epée Bâtarde","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-humanoides.YTKld5ggDsHqwYoR"}},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_epee_1_main.png","effects":[]}
{"_id":"gPOQd9NI7AFH0whX","name":"Epée Bâtarde","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-humanoides.YTKld5ggDsHqwYoR"}},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_epee_1_main.png","effects":[]}
{"name":"Bras-bouches","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>"},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-creatures.NctG7suzvGE7ZZzj"}},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-brasbouche.png","effects":[],"_id":"db8E8HwROw1ZcwRR"}
{"_id":"db8E8HwROw1ZcwRR","name":"Crocs","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-creatures.NctG7suzvGE7ZZzj"}},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-brasbouche.png","effects":[]}
{"_id":"db8E8HwROw1ZcwRR","name":"Crocs","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"<p>Morsure de la créature</p>","carac-value":null},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.competences-creatures.NctG7suzvGE7ZZzj"}},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-brasbouche.png","effects":[]}

View File

@ -2,10 +2,10 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "0.9.42",
"version": "0.9.43",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6",
"templateVersion": 44,
"templateVersion": 45,
"author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"],
@ -26,7 +26,7 @@
"module": "foundryvtt-reve-de-dragon",
"path": "./packs/competences-creatures.db",
"entity": "Item",
"tags" : [ "item", "compétences" ]
"tags" : [ "item", "compétences", "créatures" ]
},
{
"name": "competences-humanoides",
@ -35,7 +35,16 @@
"module": "foundryvtt-reve-de-dragon",
"path": "./packs/competences-humanoides.db",
"entity": "Item",
"tags" : [ "item", "compétences" ]
"tags" : [ "item", "compétences", "humanoides" ]
},
{
"name": "competences-entites",
"label": "Compétences des Entités",
"system": "foundryvtt-reve-de-dragon",
"module": "foundryvtt-reve-de-dragon",
"path": "./packs/competences-entites.db",
"entity": "Item",
"tags" : [ "item", "compétences", "entités" ]
},
{
"name": "sorts",
@ -126,6 +135,15 @@
"path": "./packs/tables-diverses.db",
"entity": "RollTable",
"tags" : [ "table", "tables" ]
},
{
"name": "animaux",
"label": "Animaux",
"system": "foundryvtt-reve-de-dragon",
"module": "foundryvtt-reve-de-dragon",
"path": "./packs/animaux.db",
"entity": "Actor",
"tags" : [ "animaux", "creature" ]
}
],
"languages": [],

View File

@ -1,6 +1,6 @@
{
"Actor": {
"types": ["personnage", "humanoide", "creature"],
"types": ["personnage", "humanoide", "creature", "entite"],
"templates": {
"description": {
"description": "Description ..."
@ -17,6 +17,54 @@
"beaute": 10,
"main": "droitier"
},
"entite": {
"carac": {
"taille": {
"type": "number",
"value": 10,
"label": "Taille",
"xp": 0,
"derivee": false
},
"reve": {
"type": "number",
"value": 10,
"label": "Rêve",
"xp": 0,
"derivee": false
},
"niveau": {
"type": "number",
"value": 0,
"label": "Niveau",
"xp": 0,
"derivee": false
}
},
"sante": {
"endurance": {
"type": "number",
"max": 10,
"value": 10,
"label": "Endurance",
"derivee": false
}
},
"attributs": {
"plusdom": {
"type": "number",
"value": 0,
"label": "+dom",
"derivee": true
},
"vitesse": {
"type": "string",
"value": 0,
"label": "Vitesse",
"derivee": true
}
}
},
"creature": {
"carac": {
"taille": {
@ -448,6 +496,9 @@
},
"creature": {
"templates": [ "creature", "description" ]
},
"entite": {
"templates": [ "entite", "description" ]
}
},
"Item": {

View File

@ -0,0 +1,100 @@
<form class="{{cssClass}}" autocomplete="off">
{{!-- Sheet Header --}}
<header class="sheet-header">
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" />
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name" /></h1>
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="carac">Caractéristiques</a>
<a class="item" data-tab="competences">Compétences</a>
<a class="item" data-tab="description">Description</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
{{!-- Carac Tab --}}
<div class="tab items" data-group="primary" data-tab="carac">
<div class="grid grid-2col">
<div class="flex-group-left flexcol">
<ol class="carac-list">
{{#each data.carac as |carac key|}}
<li class="competence flexrow" data-attribute="{{key}}">
{{#if carac.isTaille}}
<span class="carac-label flexrow" name="data.carac.{{key}}.label">{{carac.label}}</span>
{{else}}
<span class="carac-label flexrow" name="data.carac.{{key}}.label"><a
name={{key}}>{{carac.label}}</a></span>
{{/if}}
<input class="competence-value flexrow" type="text" name="data.carac.{{key}}.value"
value="{{carac.value}}" data-dtype="{{carac.type}}" />
</li>
{{/each}}
</ol>
</div>
<div class="flex-group-left flexcol">
<ol class="carac-list">
{{#each data.attributs as |attr key|}}
<li class="competence flexrow" data-attribute="{{key}}">
<span class="carac-label flexrow" name="data.attributs.{{key}}.label">{{attr.label}} : </span>
<span><input class="attribut-value flexrow" type="text" name="data.attributs.{{key}}.value"
value="{{attr.value}}" data-dtype="{{attr.type}}" /></span>
</li>
{{/each}}
<li class="competence flexrow" data-attribute="endurance">
<span class="competence-label flexrow" name="data.sante.endurance.label">Endurance : </span>
<span><input class="sante-value flexrow" type="text" name="data.sante.endurance.value"
value="{{data.sante.endurance.value}}" data-dtype="Number" /></span><span>/ </span>
<span><input class="sante-value flexrow" type="text" name="data.sante.endurance.max"
value="{{data.sante.endurance.max}}" data-dtype="Number" /></span>
</li>
</ol>
</div>
</div>
</div>
{{!-- Compétences Tab --}}
<div class="tab competences" data-group="primary" data-tab="competences">
<div class="flexcol">
<div class="flex-group-left flexcol competence-column">
<ol class="item-list">
{{#each data.competencecreature as |comp key|}}
<li class="item flexrow" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}" />
<span class="competence-label" name="data.competencecreature[{{key}}].name"><a>{{comp.name}}</a></span>
<input class="competence-value creature-carac" type="text"
name="data.competencecreature[{{key}}].data.carac_value" compname="{{comp.name}}"
value="{{comp.data.carac_value}}" data-dtype="number" />
<input class="competence-value creature-niveau" type="text"
name="data.competencecreature[{{key}}].data.niveau" compname="{{comp.name}}"
value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" />
<input class="competence-value creature-dommages" type="text"
name="data.competencecreature[{{key}}]].data.dommages" compname="{{comp.name}}"
value="{{numberFormat comp.data.dommages decimals=0 sign=true}}" data-dtype="number" />
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ol>
</div>
</div>
</div>
{{!-- Biography Tab --}}
<div class="tab description" data-group="primary" data-tab="description">
<div class="form-group editor">
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
</div>
</div>
</div>
</section>
</form>