Push initial structure
This commit is contained in:
parent
b385993422
commit
29054cd395
@ -2,13 +2,13 @@
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
export class SimpleActorSheet extends ActorSheet {
|
||||
export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["worldbuilding", "sheet", "actor"],
|
||||
template: "systems/worldbuilding/templates/actor-sheet.html",
|
||||
classes: ["rdd", "sheet", "actor"],
|
||||
template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html",
|
||||
width: 600,
|
||||
height: 600,
|
||||
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}],
|
||||
@ -18,18 +18,6 @@ export class SimpleActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @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 */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
@ -51,8 +39,6 @@ export class SimpleActorSheet extends ActorSheet {
|
||||
li.slideUp(200, () => this.render(false));
|
||||
});
|
||||
|
||||
// Add or Remove Attribute
|
||||
html.find(".attributes").on("click", ".attribute-control", this._onClickAttributeControl.bind(this));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -66,64 +52,12 @@ export class SimpleActorSheet extends ActorSheet {
|
||||
return position;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* 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 = `<input type="text" name="data.attributes.attr${nk}.key" value="attr${nk}"/>`;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @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 Actor
|
||||
return this.object.update(formData);
|
||||
}
|
||||
|
@ -2,12 +2,43 @@
|
||||
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
|
||||
* @extends {Actor}
|
||||
*/
|
||||
export class SimpleActor extends Actor {
|
||||
export class RdDActor extends Actor {
|
||||
prepareData() {
|
||||
super.prepareData();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Character type specific data
|
||||
*/
|
||||
_prepareCharacterData(actorData) {
|
||||
|
||||
for (let i of actorData.items)
|
||||
{
|
||||
if (i.type === "compétence") {
|
||||
comp[i.catégorie].push( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @override */
|
||||
getRollData() {
|
||||
const data = super.getRollData();
|
||||
const shorthand = game.settings.get("worldbuilding", "macroShorthand");
|
||||
const shorthand = game.settings.get("foundryvtt-reve-de-dragon", "macroShorthand");
|
||||
|
||||
// Re-map all attributes onto the base roll data
|
||||
if ( !!shorthand ) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class SimpleItemSheet extends ItemSheet {
|
||||
export class RdDItemSheet extends ItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
@ -5,16 +5,16 @@
|
||||
*/
|
||||
|
||||
// Import Modules
|
||||
import { SimpleActor } from "./actor.js";
|
||||
import { SimpleItemSheet } from "./item-sheet.js";
|
||||
import { SimpleActorSheet } from "./actor-sheet.js";
|
||||
import { RdDActor } from "./actor.js";
|
||||
import { RdDItemSheet } from "./item-sheet.js";
|
||||
import { RdDActorSheet } from "./actor-sheet.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Foundry VTT Initialization */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
Hooks.once("init", async function() {
|
||||
console.log(`Initializing Simple Worldbuilding System`);
|
||||
console.log(`Initializing Reve de Dragon System`);
|
||||
|
||||
/**
|
||||
* Set an initiative formula for the system
|
||||
@ -26,16 +26,16 @@ Hooks.once("init", async function() {
|
||||
};
|
||||
|
||||
// Define custom Entity classes
|
||||
CONFIG.Actor.entityClass = SimpleActor;
|
||||
CONFIG.Actor.entityClass = RdDActor;
|
||||
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("dnd5e", SimpleActorSheet, { makeDefault: true });
|
||||
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorSheet, { makeDefault: true });
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("dnd5e", SimpleItemSheet, {makeDefault: true});
|
||||
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, {makeDefault: true});
|
||||
|
||||
// Register system settings
|
||||
game.settings.register("worldbuilding", "macroShorthand", {
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "macroShorthand", {
|
||||
name: "Shortened Macro Syntax",
|
||||
hint: "Enable a shortened macro syntax which allows referencing attributes directly, for example @str instead of @attributes.str.value. Disable this setting if you need the ability to reference the full attribute model, for example @attributes.str.label.",
|
||||
scope: "world",
|
||||
|
@ -2,10 +2,10 @@
|
||||
"name": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"description": "L'implémentation de Rêve de Dragon pour FoundryVTT",
|
||||
"version": 0.1,
|
||||
"version": 0.2,
|
||||
"minimumCoreVersion": "0.5.7",
|
||||
"compatibleCoreVersion": "0.5.7",
|
||||
"templateVersion": 1,
|
||||
"templateVersion": 3,
|
||||
"author": "LeRatierBretonnien",
|
||||
"esmodules": ["module/simple.js"],
|
||||
"styles": ["styles/simple.css"],
|
||||
|
@ -3,106 +3,173 @@
|
||||
"types": ["personnage"],
|
||||
"templates": {
|
||||
"background": {
|
||||
"biographie": "",
|
||||
"biographie": "Histoire personnelle...",
|
||||
"yeux": "",
|
||||
"cheveux": ""
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
"carac": {
|
||||
"taille": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Taille",
|
||||
"xp": 0
|
||||
},
|
||||
"apparence": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Apparence",
|
||||
"xp": 0
|
||||
},
|
||||
"constitution": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Constitution",
|
||||
"xp": 0
|
||||
},
|
||||
"force": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Force",
|
||||
"xp": 0
|
||||
},
|
||||
"agilité": {
|
||||
"agilite": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Agilité",
|
||||
"xp": 0
|
||||
},
|
||||
"dexterité": {
|
||||
"dexterite": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Dexterité",
|
||||
"xp": 0
|
||||
},
|
||||
"vue": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Vue",
|
||||
"xp": 0
|
||||
},
|
||||
"ouïe": {
|
||||
"ouie": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Ouïe",
|
||||
"xp": 0
|
||||
},
|
||||
"odoratgout": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Odorat-Goût",
|
||||
"xp": 0
|
||||
},
|
||||
"volonté": {
|
||||
"volonte": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Volonté",
|
||||
"xp": 0
|
||||
},
|
||||
"intellect": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Intellect",
|
||||
"xp": 0
|
||||
},
|
||||
"empathie": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Empathie",
|
||||
"xp": 0
|
||||
},
|
||||
"rêve": {
|
||||
"reve": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Rêve",
|
||||
"xp": 0
|
||||
},
|
||||
"chance": {
|
||||
"type": "number",
|
||||
"value": 10,
|
||||
"label": "Chance",
|
||||
"xp": 0
|
||||
}
|
||||
},
|
||||
"secondaires": {
|
||||
"sante": {
|
||||
"vie": {
|
||||
"type": "number",
|
||||
"max": 10,
|
||||
"current": 10,
|
||||
"value": 10,
|
||||
"label": "Points de Vie"
|
||||
},
|
||||
"endurance": {
|
||||
"type": "number",
|
||||
"max": 10,
|
||||
"value": 10,
|
||||
"label": "Points d'Endurance"
|
||||
},
|
||||
"fatigue": {
|
||||
"type": "number",
|
||||
"max": 40,
|
||||
"current": 10,
|
||||
"value": 10,
|
||||
"label": "Points de Fatigue"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"personnage": {
|
||||
"template": [ "background", "carac", "secondaires"]
|
||||
"templates": [ "background", "common"]
|
||||
}
|
||||
},
|
||||
"Item": {
|
||||
"types": ["item"],
|
||||
"item": {
|
||||
"types": ["objet", "arme", "armure", "compétence", "sort", "herbe", "ingrédient", "livre", "potion"],
|
||||
"objet": {
|
||||
"description": "",
|
||||
"quantité": 1,
|
||||
"poids": 0,
|
||||
"attributs": {}
|
||||
},
|
||||
"arme": {
|
||||
"description": "",
|
||||
"quantité": 1,
|
||||
"poids": 0,
|
||||
"attributs": {}
|
||||
},
|
||||
"armure": {
|
||||
"description": "",
|
||||
"quantité": 1,
|
||||
"poids": 0,
|
||||
"attributs": {}
|
||||
},
|
||||
"compétence": {
|
||||
"niveau": 0,
|
||||
"base": 0,
|
||||
"catégorie": "",
|
||||
"xp": 0
|
||||
"description": ""
|
||||
},
|
||||
"sort": {
|
||||
"description": "",
|
||||
"draconic": "",
|
||||
"difficulté": 0,
|
||||
"portée": 0
|
||||
},
|
||||
"herbe": {
|
||||
"description": "",
|
||||
"niveau": 0,
|
||||
"base": 0
|
||||
},
|
||||
"ingredient": {
|
||||
"description": "",
|
||||
"niveau": 0,
|
||||
"base": 0
|
||||
},
|
||||
"livre": {
|
||||
"description": "",
|
||||
"difficulté": 0,
|
||||
"taches": 0
|
||||
},
|
||||
"potion": {
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,20 +6,22 @@
|
||||
<div class="header-fields">
|
||||
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name"/></h1>
|
||||
<div class="resource">
|
||||
<input type="text" name="data.health.value" value="{{data.health.value}}" data-dtype="Number"/>
|
||||
<input type="text" name="data.sante.vie.value" value="{{data.sante.vie.value}}" data-dtype="Number"/>
|
||||
<span> / </span>
|
||||
<input type="text" name="data.health.max" value="{{data.health.max}}" data-dtype="Number"/>
|
||||
<input type="text" name="data.sante.vie.max" value="{{data.sante.vie.max}}" data-dtype="Number"/>
|
||||
</div>
|
||||
<div class="resource">
|
||||
<input type="text" name="data.power.value" value="{{data.power.value}}" data-dtype="Number"/>
|
||||
<input type="text" name="data.sante.fatigue.value" value="{{data.sante.fatigue.value}}" data-dtype="Number"/>
|
||||
<span> / </span>
|
||||
<input type="text" name="data.power.max" value="{{data.power.max}}" data-dtype="Number"/>
|
||||
<input type="text" name="data.sante.fatigue.max" value="{{data.sante.fatigue.max}}" data-dtype="Number"/>
|
||||
</div>
|
||||
</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="compétences">Compétences</a>
|
||||
<a class="item" data-tab="description">Description</a>
|
||||
<a class="item" data-tab="items">Items</a>
|
||||
<a class="item" data-tab="attributes">Attributes</a>
|
||||
@ -28,9 +30,45 @@
|
||||
{{!-- Sheet Body --}}
|
||||
<section class="sheet-body">
|
||||
|
||||
{{!-- Carac Tab --}}
|
||||
<div class="tab carac" data-group="primary" data-tab="carac">
|
||||
<header class="carac-header flexrow">
|
||||
<span class="carac-key">Nom</span>
|
||||
<span class="carac-value">Valeur</span>
|
||||
<span class="carac-label">XP</span>
|
||||
</header>
|
||||
<ol class="attributes-list">
|
||||
{{#each data.carac as |carac key|}}
|
||||
<li class="attribute flexrow" data-attribute="{{key}}">
|
||||
<span class="attribute-label" name="data.carac.{{key}}.label">{{carac.label}}</span>
|
||||
<input class="attribute-value" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}"/>
|
||||
<input class="attribute-xp" type="text" name="data.carac.{{key}}.xp" value="{{carac.xp}}" data-dtype="number"/>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
{{!-- Compétences Tab --}}
|
||||
<div class="tab compétences" data-group="primary" data-tab="compétences">
|
||||
<header class="compétences-header flexrow">
|
||||
<span class="compétences-key">Nom</span>
|
||||
<span class="compétences-value">Valeur</span>
|
||||
<span class="compétences-label">XP</span>
|
||||
</header>
|
||||
<ol class="compétences-list">
|
||||
{{#each data.items as |com key|}}
|
||||
<li class="attribute flexrow" data-attribute="{{key}}">
|
||||
<span class="attribute-label" name="data.carac.{{key}}.label">{{carac.label}}</span>
|
||||
<input class="attribute-value" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}"/>
|
||||
<input class="attribute-xp" type="text" name="data.carac.{{key}}.xp" value="{{carac.xp}}" data-dtype="number"/>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
{{!-- Biography Tab --}}
|
||||
<div class="tab biography" data-group="primary" data-tab="description">
|
||||
{{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}}
|
||||
{{editor content=data.biographie target="data.biographie" button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
|
||||
{{!-- Owned Items Tab --}}
|
||||
@ -49,38 +87,6 @@
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
{{!-- Attributes Tab --}}
|
||||
<div class="tab attributes" data-group="primary" data-tab="attributes">
|
||||
<header class="attributes-header flexrow">
|
||||
<span class="attribute-key">Attribute Key</span>
|
||||
<span class="attribute-value">Value</span>
|
||||
<span class="attribute-label">Label</span>
|
||||
<span class="attribute-dtype">Data Type</span>
|
||||
<a class="attribute-control" data-action="create"><i class="fas fa-plus"></i></a>
|
||||
</header>
|
||||
|
||||
<ol class="attributes-list">
|
||||
{{#each data.attributes as |attr key|}}
|
||||
<li class="attribute flexrow" data-attribute="{{key}}">
|
||||
<input class="attribute-key" type="text" name="data.attributes.{{key}}.key" value="{{key}}"/>
|
||||
{{#if attr.isCheckbox}}
|
||||
<label class="attribute-value checkbox"><input type="checkbox" name="data.attributes.{{key}}.value" {{checked attr.value}}/></label>
|
||||
{{else}}
|
||||
<input class="attribute-value" type="text" name="data.attributes.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.dtype}}"/>
|
||||
{{/if}}
|
||||
<input class="attribute-label" type="text" name="data.attributes.{{key}}.label" value="{{attr.label}}"/>
|
||||
<select class="attribute-dtype" name="data.attributes.{{key}}.dtype">
|
||||
{{#select attr.dtype}}
|
||||
{{#each ../dtypes as |t|}}
|
||||
<option value="{{t}}">{{t}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
<a class="attribute-control" data-action="delete"><i class="fas fa-trash"></i></a>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user