diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 73663473..a400baa9 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -18,6 +18,43 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */
+ 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.competenceByCategory = {};
+ if (data.itemsByType.competence) {
+ for (const item of data.itemsByType.competence) {
+ console.log("Push...", item, item.data.categorie);
+ let list = data.competenceByCategory[item.data.categorie];
+ if (!list) {
+ list = [];
+ data.competenceByCategory[item.data.categorie] = list;
+ }
+ list.push(item);
+ }
+ }
+
+ data.data.materiel = this._checkNull(data.itemsByType['objet']);
+ data.data.armes = this._checkNull(data.itemsByType['arme']);
+ data.data.armures = this._checkNull(data.itemsByType['armure']);
+ data.data.livres = this._checkNull(data.itemsByType['livre']);
+ data.data.potions = this._checkNull(data.itemsByType['potions']);
+ data.data.competenceByCategory = data.competenceByCategory;
+
+ return data;
+ }
+
+ /* -------------------------------------------- */
+
/** @override */
activateListeners(html) {
super.activateListeners(html);
diff --git a/module/actor.js b/module/actor.js
index b1d31c91..2428398d 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -9,14 +9,7 @@ export class RdDActor extends Actor {
const actorData = this.data;
const data = actorData.data;
const flags = actorData.flags;
- const comp = { "base": [],
- "mêlée": [],
- "tir": [],
- "particulières": [],
- "spécialisées": [],
- "connaissances": [],
- "draconic": []
- }
+
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
@@ -27,12 +20,6 @@ export class RdDActor extends Actor {
*/
_prepareCharacterData(actorData) {
- for (let i of actorData.items)
- {
- if (i.type === "compétence") {
- comp[i.catégorie].push( i );
- }
- }
}
/** @override */
diff --git a/module/item-sheet.js b/module/item-sheet.js
index 6ab42b44..cdcfdf6a 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -7,28 +7,16 @@ export class RdDItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
- classes: ["worldbuilding", "sheet", "item"],
- template: "systems/worldbuilding/templates/item-sheet.html",
+ classes: ["foundryvtt-reve-de-dragon", "sheet", "item"],
+ template: "systems/foundryvtt-reve-de-dragon/templates/item-sheet.html",
width: 520,
- height: 480,
- tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
+ height: 480
+ //tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
});
}
/* -------------------------------------------- */
- /** @override */
- getData() {
- const data = super.getData();
- data.dtypes = ["String", "Number", "Boolean"];
- for ( let attr of Object.values(data.data.attributes) ) {
- attr.isCheckbox = attr.dtype === "Boolean";
- }
- return data;
- }
-
- /* -------------------------------------------- */
-
/** @override */
setPosition(options={}) {
const position = super.setPosition(options);
@@ -46,41 +34,28 @@ export class RdDItemSheet extends ItemSheet {
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
+
+ // Select competence categorie
+ html.find("#categorie").on("click", this._onClickSelectCategorie.bind(this) );
+ }
+
+ /* -------------------------------------------- */
- // Add or Remove Attribute
- html.find(".attributes").on("click", ".attribute-control", this._onClickAttributeControl.bind(this));
+ async _onClickSelectCategorie(event) {
+ event.preventDefault();
+
+ const category = event.currentTarget.value;
+ let level = CONFIG.RDD.level_category[category];
+ this.object.data.data.base = level;
+ $("#base").val( level );
}
/* -------------------------------------------- */
- /**
- * Listen for click events on an attribute control to modify the composition of attributes in the sheet
- * @param {MouseEvent} event The originating left click event
- * @private
- */
- async _onClickAttributeControl(event) {
- event.preventDefault();
- const a = event.currentTarget;
- const action = a.dataset.action;
- const attrs = this.object.data.data.attributes;
- const form = this.form;
-
- // Add new attribute
- if ( action === "create" ) {
- const nk = Object.keys(attrs).length + 1;
- let newKey = document.createElement("div");
- newKey.innerHTML = ``;
- newKey = newKey.children[0];
- form.appendChild(newKey);
- await this._onSubmit(event);
- }
-
- // Remove existing attribute
- else if ( action === "delete" ) {
- const li = a.closest(".attribute");
- li.parentElement.removeChild(li);
- await this._onSubmit(event);
- }
+ get template()
+ {
+ let type = this.item.type;
+ return `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html`;
}
/* -------------------------------------------- */
@@ -88,28 +63,6 @@ export class RdDItemSheet extends ItemSheet {
/** @override */
_updateObject(event, formData) {
- // Handle the free-form attributes list
- const formAttrs = expandObject(formData).data.attributes || {};
- const attributes = Object.values(formAttrs).reduce((obj, v) => {
- let k = v["key"].trim();
- if ( /[\s\.]/.test(k) ) return ui.notifications.error("Attribute keys may not contain spaces or periods");
- delete v["key"];
- obj[k] = v;
- return obj;
- }, {});
-
- // Remove attributes which are no longer used
- for ( let k of Object.keys(this.object.data.data.attributes) ) {
- if ( !attributes.hasOwnProperty(k) ) attributes[`-=${k}`] = null;
- }
-
- // Re-combine formData
- formData = Object.entries(formData).filter(e => !e[0].startsWith("data.attributes")).reduce((obj, e) => {
- obj[e[0]] = e[1];
- return obj;
- }, {_id: this.object._id, "data.attributes": attributes});
-
- // Update the Item
return this.object.update(formData);
}
}
diff --git a/module/simple.js b/module/simple.js
index 5aeb8423..e7712714 100644
--- a/module/simple.js
+++ b/module/simple.js
@@ -1,21 +1,54 @@
/**
- * A simple and flexible system for world-building using an arbitrary collection of character and item attributes
- * Author: Atropos
+ * RdD system
+ * Author: LeRatierBretonnien
* Software License: GNU GPLv3
*/
+/* -------------------------------------------- */
+const RDD = {}
+RDD.level_category = {
+ "generale": "-4",
+ "particuliere": "-8",
+ "speciale": "-11",
+ "connaissance": "-11",
+ "draconic": "-11",
+ "melee": "-6",
+ "tir": "-8",
+ "lancer": "-8"
+}
+
+/* -------------------------------------------- */
// Import Modules
import { RdDActor } from "./actor.js";
import { RdDItemSheet } from "./item-sheet.js";
import { RdDActorSheet } from "./actor-sheet.js";
+
+/* -------------------------------------------- */
+// Handlers management
+const preloadHandlebarsTemplates = async function () {
+ const templatePaths = [
+ //Character Sheets
+ 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html',
+ //Items
+ 'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/competence-base.html'
+ ];
+
+ return loadTemplates(templatePaths);
+}
+
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("init", async function() {
console.log(`Initializing Reve de Dragon System`);
-
+ // preload handlebars templates
+ preloadHandlebarsTemplates();
+
/**
* Set an initiative formula for the system
* @type {String}
@@ -27,7 +60,8 @@ Hooks.once("init", async function() {
// Define custom Entity classes
CONFIG.Actor.entityClass = RdDActor;
-
+ CONFIG.RDD = RDD;
+
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorSheet, { makeDefault: true });
diff --git a/styles/simple.css b/styles/simple.css
index f4090e12..485b976a 100644
--- a/styles/simple.css
+++ b/styles/simple.css
@@ -1,14 +1,14 @@
-.worldbuilding {
+.foundryvtt-reve-de-dragon {
/* Sheet Tabs */
/* Items List */
/* Attributes */
}
-.worldbuilding .window-content {
+.foundryvtt-reve-de-dragon .window-content {
height: 100%;
padding: 5px;
overflow-y: hidden;
}
-.worldbuilding .sheet-header {
+.foundryvtt-reve-de-dragon .sheet-header {
height: 100px;
overflow: hidden;
display: flex;
@@ -17,84 +17,84 @@
justify-content: flex-start;
margin-bottom: 10px;
}
-.worldbuilding .sheet-header .profile-img {
+.foundryvtt-reve-de-dragon .sheet-header .profile-img {
flex: 0 0 100px;
height: 100px;
margin-right: 10px;
}
-.worldbuilding .sheet-header .header-fields {
+.foundryvtt-reve-de-dragon .sheet-header .header-fields {
flex: 1;
height: 100px;
}
-.worldbuilding .sheet-header h1.charname {
+.foundryvtt-reve-de-dragon .sheet-header h1.charname {
height: 50px;
padding: 0px;
margin: 5px 0;
border-bottom: 0;
}
-.worldbuilding .sheet-header h1.charname input {
+.foundryvtt-reve-de-dragon .sheet-header h1.charname input {
width: 100%;
height: 100%;
margin: 0;
}
-.worldbuilding .resource {
+.foundryvtt-reve-de-dragon .resource {
width: 50%;
height: 40px;
margin-top: 10px;
float: left;
text-align: center;
}
-.worldbuilding .resource input {
+.foundryvtt-reve-de-dragon .resource input {
width: 100px;
height: 28px;
}
-.worldbuilding .tabs {
+.foundryvtt-reve-de-dragon .tabs {
height: 40px;
border-top: 1px solid #AAA;
border-bottom: 1px solid #AAA;
}
-.worldbuilding .tabs .item {
+.foundryvtt-reve-de-dragon .tabs .item {
line-height: 40px;
font-weight: bold;
}
-.worldbuilding .tabs .item.active {
+.foundryvtt-reve-de-dragon .tabs .item.active {
text-decoration: underline;
text-shadow: none;
}
-.worldbuilding .sheet-body {
+.foundryvtt-reve-de-dragon .sheet-body {
overflow: hidden;
}
-.worldbuilding .sheet-body .tab {
+.foundryvtt-reve-de-dragon .sheet-body .tab {
height: 100%;
overflow-y: auto;
}
-.worldbuilding .editor,
-.worldbuilding .editor-content {
+.foundryvtt-reve-de-dragon .editor,
+.foundryvtt-reve-de-dragon .editor-content {
height: 100%;
}
-.worldbuilding .item-list {
+.foundryvtt-reve-de-dragon .item-list {
list-style: none;
margin: 7px 0;
padding: 0;
overflow-y: auto;
}
-.worldbuilding .item-list .item {
+.foundryvtt-reve-de-dragon .item-list .item {
height: 30px;
line-height: 24px;
padding: 3px 0;
border-bottom: 1px solid #BBB;
}
-.worldbuilding .item-list .item img {
+.foundryvtt-reve-de-dragon .item-list .item img {
flex: 0 0 24px;
margin-right: 5px;
}
-.worldbuilding .item-list .item-name {
+.foundryvtt-reve-de-dragon .item-list .item-name {
margin: 0;
}
-.worldbuilding .item-list .item-controls {
+.foundryvtt-reve-de-dragon .item-list .item-controls {
flex: 0 0 36px;
}
-.worldbuilding .attributes-header {
+.foundryvtt-reve-de-dragon .attributes-header {
padding: 5px;
margin: 5px 0;
background: rgba(0, 0, 0, 0.05);
@@ -103,18 +103,18 @@
text-align: center;
font-weight: bold;
}
-.worldbuilding .attributes-header .attribute-label {
+.foundryvtt-reve-de-dragon .attributes-header .attribute-label {
flex: 1.5;
}
-.worldbuilding .attributes-header .attribute-control {
+.foundryvtt-reve-de-dragon .attributes-header .attribute-control {
flex: 0 0 20px;
}
-.worldbuilding .attributes-list {
+.foundryvtt-reve-de-dragon .attributes-list {
list-style: none;
margin: 0;
padding: 0;
}
-.worldbuilding .attributes-list li > * {
+.foundryvtt-reve-de-dragon .attributes-list li > * {
margin: 0 3px;
height: 28px;
line-height: 24px;
@@ -123,17 +123,24 @@
border-radius: 0;
border-bottom: 1px solid #AAA;
}
-.worldbuilding .attributes-list a.attribute-control {
+.foundryvtt-reve-de-dragon .attributes-list a.attribute-control {
flex: 0 0 20px;
text-align: center;
line-height: 28px;
border: none;
}
-.worldbuilding.sheet.actor {
+.foundryvtt-reve-de-dragon.sheet.actor {
min-width: 560px;
min-height: 420px;
}
-.worldbuilding.sheet.item {
+.foundryvtt-reve-de-dragon.sheet.item {
min-width: 460px;
min-height: 400px;
}
+
+//Editor
+.editor {
+ border: $section-border;
+ height: 300px;
+ width: 100%;
+}
diff --git a/styles/simple.less b/styles/simple.less
deleted file mode 100644
index ba89e194..00000000
--- a/styles/simple.less
+++ /dev/null
@@ -1,162 +0,0 @@
-.worldbuilding {
- .window-content {
- height: 100%;
- padding: 5px;
- overflow-y: hidden;
- }
-
- .sheet-header {
- height: 100px;
- overflow: hidden;
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: flex-start;
- margin-bottom: 10px;
-
- .profile-img {
- flex: 0 0 100px;
- height: 100px;
- margin-right: 10px;
- }
-
- .header-fields {
- flex: 1;
- height: 100px;
- }
-
- h1.charname {
- height: 50px;
- padding: 0px;
- margin: 5px 0;
- border-bottom: 0;
- input {
- width: 100%;
- height: 100%;
- margin: 0;
- }
- }
- }
-
- .resource {
- width: 50%;
- height: 40px;
- margin-top: 10px;
- float: left;
- text-align: center;
- input {
- width: 100px;
- height: 28px;
- }
- }
-
- /* Sheet Tabs */
- .tabs {
- height: 40px;
- border-top: 1px solid #AAA;
- border-bottom: 1px solid #AAA;
-
- .item {
- line-height: 40px;
- font-weight: bold;
- }
-
- .item.active {
- text-decoration: underline;
- text-shadow: none;
- }
- }
-
- .sheet-body {
- overflow: hidden;
- .tab {
- height: 100%;
- overflow-y: auto;
- }
- }
-
- .editor, .editor-content {
- height: 100%;
- }
-
- /* Items List */
- .item-list {
- list-style: none;
- margin: 7px 0;
- padding: 0;
- overflow-y: auto;
-
- .item {
- height: 30px;
- line-height: 24px;
- padding: 3px 0;
- border-bottom: 1px solid #BBB;
-
- img {
- flex: 0 0 24px;
- margin-right: 5px;
- }
- }
-
- .item-name {
- margin: 0;
- }
-
- .item-controls {
- flex: 0 0 36px;
- }
- }
-
- /* Attributes */
- .attributes-header {
- padding: 5px;
- margin: 5px 0;
- background: rgba(0, 0, 0, 0.05);
- border: 1px solid #AAA;
- border-radius: 2px;
- text-align: center;
- font-weight: bold;
-
- .attribute-label {
- flex: 1.5;
- }
-
- .attribute-control {
- flex: 0 0 20px;
- }
- }
-
- .attributes-list {
- list-style: none;
- margin: 0;
- padding: 0;
-
- li > * {
- margin: 0 3px;
- height: 28px;
- line-height: 24px;
- background: transparent;
- border: none;
- border-radius: 0;
- border-bottom: 1px solid #AAA;
- }
-
- a.attribute-control {
- flex: 0 0 20px;
- text-align: center;
- line-height: 28px;
- border: none;
- }
- }
-}
-
-.worldbuilding.sheet.actor {
- min-width: 560px;
- min-height: 420px;
-}
-
-
-.worldbuilding.sheet.item {
- min-width: 460px;
- min-height: 400px;
-}
diff --git a/system.json b/system.json
index 5cd82bd9..4506b076 100644
--- a/system.json
+++ b/system.json
@@ -5,7 +5,7 @@
"version": 0.2,
"minimumCoreVersion": "0.5.7",
"compatibleCoreVersion": "0.5.7",
- "templateVersion": 3,
+ "templateVersion": 4,
"author": "LeRatierBretonnien",
"esmodules": ["module/simple.js"],
"styles": ["styles/simple.css"],
diff --git a/template.json b/template.json
index 860596f1..935c3c78 100644
--- a/template.json
+++ b/template.json
@@ -121,36 +121,45 @@
}
},
"Item": {
- "types": ["objet", "arme", "armure", "compétence", "sort", "herbe", "ingrédient", "livre", "potion"],
+ "types": ["objet", "arme", "armure", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition"],
"objet": {
"description": "",
- "quantité": 1,
- "poids": 0,
- "attributs": {}
+ "quantite": 1,
+ "encombrement": 0,
+ "equipe": false
},
"arme": {
"description": "",
- "quantité": 1,
- "poids": 0,
- "attributs": {}
+ "quantite": 1,
+ "encombrement": 0,
+ "equipe": false,
+ "dommages": 0
+ },
+ "munition": {
+ "description": "",
+ "quantite": 1,
+ "encombrement": 0,
+ "equipe": false
},
"armure": {
"description": "",
- "quantité": 1,
- "poids": 0,
- "attributs": {}
+ "quantite": 1,
+ "encombrement": 0,
+ "equipe": false,
+ "pa": 0,
},
- "compétence": {
+ "competence": {
"niveau": 0,
"base": 0,
- "catégorie": "",
+ "categorie": "",
"xp": 0,
- "description": ""
+ "description": "Compétence : ...",
+ "defaut_carac": ""
},
"sort": {
"description": "",
"draconic": "",
- "difficulté": 0,
+ "difficulte": 0,
"portée": 0
},
"herbe": {
@@ -161,15 +170,18 @@
"ingredient": {
"description": "",
"niveau": 0,
+ "encombrement": 0,
"base": 0
},
"livre": {
"description": "",
- "difficulté": 0,
- "taches": 0
+ "difficulte": 0,
+ "taches": 0,
+ "encombrement": 0
},
"potion": {
- "description": ""
+ "description": "",
+ "encombrement": 0
}
}
}
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index d8628d25..2c5eae6a 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -21,7 +21,7 @@
{{!-- Sheet Tab Navigation --}}