refactoring module structure
parent
db1b60fb19
commit
ea436f3e4a
16
src/main.mjs
16
src/main.mjs
|
|
@ -1,14 +1,14 @@
|
||||||
import { PlayerCharacterDataModel } from "./module/character/character.mjs";
|
import { PlayerCharacterDataModel } from "./module/character/character.mjs";
|
||||||
import { DsaActor } from "./module/Actors/dsa-actor.mjs";
|
import { SkillSheet } from "./module/sheets/skillSheet.mjs";
|
||||||
import { Skill } from "./module/Items/skill.mjs"
|
import { SpellSheet } from "./module/sheets/spellSheet.mjs";
|
||||||
import { SkillSheet } from "./module/Items/skillSheet.mjs";
|
import { SkillDataModel } from "./module/data/skill.mjs";
|
||||||
import { Spell } from "./module/Items/spell.mjs";
|
import { SpellDataModel } from "./module/data/spell.mjs";
|
||||||
import { SpellSheet } from "./module/Items/spellSheet.mjs";
|
import { Character } from "./module/documents/character.mjs";
|
||||||
|
|
||||||
Hooks.once("init", () => {
|
Hooks.once("init", () => {
|
||||||
|
|
||||||
// Configure custom Document implementations.
|
// Configure custom Document implementations.
|
||||||
CONFIG.Actor.documentClass = DsaActor;
|
CONFIG.Actor.documentClass = Character;
|
||||||
|
|
||||||
// Configure System Data Models.
|
// Configure System Data Models.
|
||||||
CONFIG.Actor.dataModels = {
|
CONFIG.Actor.dataModels = {
|
||||||
|
|
@ -16,8 +16,8 @@ Hooks.once("init", () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
CONFIG.Item.dataModels = {
|
CONFIG.Item.dataModels = {
|
||||||
skills: Skill,
|
skill: SkillDataModel,
|
||||||
spells: Spell
|
spell: SpellDataModel
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("DSA 4.1 is ready for development!")
|
console.log("DSA 4.1 is ready for development!")
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export class DsaActor extends Actor {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
export default class BaseItem extends foundry.abstract.TypeDataModel {
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
async importFromCompendium(pack, id, updateData={}, options={}) {
|
||||||
|
console.log(`called ${pack} ${id} `);
|
||||||
|
const created = await super.importFromCompendium(pack, id, updateData, options);
|
||||||
|
|
||||||
|
const item = await pack.getDocument(id);
|
||||||
|
const contents = await item.system.contents;
|
||||||
|
if ( contents ) {
|
||||||
|
const fromOptions = foundry.utils.mergeObject({ clearSort: false }, options);
|
||||||
|
const toCreate = await BaseItem.createWithContents(contents, {
|
||||||
|
container: created, keepId: options.keepId, transformAll: item => this.fromCompendium(item, fromOptions)
|
||||||
|
});
|
||||||
|
await BaseItem.createDocuments(toCreate, {fromCompendium: true, keepId: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { Skill } from "../Items/skill.mjs";
|
import { Skill } from "./Items/skill.mjs";
|
||||||
import { Spell } from "../Items/spell.mjs";
|
import { Spell } from "./Items/spell.mjs";
|
||||||
|
|
||||||
const {
|
const {
|
||||||
SchemaField, NumberField, StringField, ArrayField, BooleanField, EmbeddedCollectionField,
|
SchemaField, NumberField, StringField, ArrayField, BooleanField, EmbeddedCollectionField,
|
||||||
} = foundry.data.fields;
|
} = foundry.data.fields;
|
||||||
|
|
||||||
export class PlayerCharacterDataModel extends Actor {
|
export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel {
|
||||||
|
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
import BaseItem from "./base-item.mjs";
|
||||||
|
|
||||||
const { BooleanField, ArrayField, NumberField, SchemaField, StringField, HTMLField } = foundry.data.fields;
|
const { BooleanField, ArrayField, NumberField, SchemaField, StringField, HTMLField } = foundry.data.fields;
|
||||||
|
|
||||||
export class Skill extends Item {
|
export class SkillDataModel extends BaseItem {
|
||||||
|
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -8,12 +10,12 @@ export class Skill extends Item {
|
||||||
gruppe: new StringField({ required: true }),
|
gruppe: new StringField({ required: true }),
|
||||||
probe: new ArrayField(new StringField(), { exact: 3 }), // References one of the eight attributes by name
|
probe: new ArrayField(new StringField(), { exact: 3 }), // References one of the eight attributes by name
|
||||||
voraussetzung: new SchemaField({
|
voraussetzung: new SchemaField({
|
||||||
talent: new StringField({ model: Skill }),
|
talent: new StringField({ model: SkillDataModel }),
|
||||||
wert: new NumberField(),
|
wert: new NumberField({}),
|
||||||
}), // Required skills at a given level
|
}), // Required skills at a given level
|
||||||
talent: new HTMLField(),
|
talent: new HTMLField({ required: true }),
|
||||||
behinderung: new NumberField(), // BE-X
|
behinderung: new NumberField({ required: false}), // BE-X
|
||||||
komplexität: new NumberField(), // In case of languages
|
komplexität: new NumberField({ required: false }), // In case of languages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,4 +35,5 @@ export class Skill extends Item {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async roll() { }
|
async roll() { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +1,20 @@
|
||||||
|
import BaseItem from "./base-item.mjs";
|
||||||
|
|
||||||
const { BooleanField, NumberField, SchemaField, ArrayField, StringField, HTMLField } = foundry.data.fields;
|
const { BooleanField, NumberField, SchemaField, ArrayField, StringField, HTMLField } = foundry.data.fields;
|
||||||
|
|
||||||
export class Spell extends Item {
|
export class SpellDataModel extends BaseItem {
|
||||||
|
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
return {
|
return {
|
||||||
seite: new NumberField(),
|
seite: new NumberField(),
|
||||||
name: new StringField({ required: true }),
|
name: new StringField({ required: true }),
|
||||||
probe: new ArrayField({ required: true, exact: 3 }),
|
probe: new ArrayField( new StringField(), { required: true, exact: 3 }),
|
||||||
probeMod: new StringField(),
|
probeMod: new StringField(),
|
||||||
technik: new StringField(),
|
technik: new StringField(),
|
||||||
zauberdauer: new StringField(),
|
zauberdauer: new StringField(),
|
||||||
wirkung: new StringField(),
|
wirkung: new StringField(),
|
||||||
kosten: new StringField(),
|
kosten: new StringField(),
|
||||||
|
zielobjekt: new StringField(),
|
||||||
reichweite: new StringField({ required: true }),
|
reichweite: new StringField({ required: true }),
|
||||||
wirkungsdauer: new StringField({ required: true }),
|
wirkungsdauer: new StringField({ required: true }),
|
||||||
modifikationen: new StringField({ required: true }),
|
modifikationen: new StringField({ required: true }),
|
||||||
|
|
@ -42,4 +45,5 @@ export class Spell extends Item {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async roll() { }
|
async roll() { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
export class Character extends Item {
|
||||||
|
/**
|
||||||
|
* Augment the basic Item data model with additional dynamic data.
|
||||||
|
*/
|
||||||
|
prepareData() {
|
||||||
|
super.prepareData();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { BaseItem } from "./base-item.mjs";
|
||||||
|
|
||||||
|
export class Skill extends BaseItem {
|
||||||
|
/**
|
||||||
|
* Augment the basic Item data model with additional dynamic data.
|
||||||
|
*/
|
||||||
|
prepareData() {
|
||||||
|
super.prepareData();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { BaseItem } from "./base-item.mjs";
|
||||||
|
|
||||||
|
export class Spell extends BaseItem {
|
||||||
|
/**
|
||||||
|
* Augment the basic Item data model with additional dynamic data.
|
||||||
|
*/
|
||||||
|
prepareData() {
|
||||||
|
super.prepareData();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export class SkillSheet extends ItemSheet {
|
export class SkillSheet extends foundry.appv1.sheets.ItemSheet {
|
||||||
/**@override */
|
/**@override */
|
||||||
static get defaultOptions() {
|
static get defaultOptions() {
|
||||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export class SpellSheet extends ItemSheet {
|
export class SpellSheet extends foundry.appv1.sheets.ItemSheet {
|
||||||
/**@override */
|
/**@override */
|
||||||
static get defaultOptions() {
|
static get defaultOptions() {
|
||||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
],
|
],
|
||||||
"packs": [
|
"packs": [
|
||||||
{
|
{
|
||||||
"name": "Skill",
|
"name": "skills",
|
||||||
"label": "Basistalente",
|
"label": "Basistalente",
|
||||||
"system": "DSA_4-1",
|
"system": "DSA_4-1",
|
||||||
"type": "Item",
|
"type": "Item",
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
"private": false
|
"private": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Spells",
|
"name": "spells",
|
||||||
"label": "Basiszauber",
|
"label": "Basiszauber",
|
||||||
"system": "DSA_4-1",
|
"system": "DSA_4-1",
|
||||||
"type": "Item",
|
"type": "Item",
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
"color": "#801020",
|
"color": "#801020",
|
||||||
"sorting": "m",
|
"sorting": "m",
|
||||||
"packs": [
|
"packs": [
|
||||||
"Spells"
|
"spells"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -79,18 +79,19 @@
|
||||||
"Skill": {
|
"Skill": {
|
||||||
"stringFields": [
|
"stringFields": [
|
||||||
"name",
|
"name",
|
||||||
"gruppe",
|
"gruppe"
|
||||||
"probe",
|
],
|
||||||
"voraussetzung"
|
"arrayFields": [
|
||||||
|
"probe"
|
||||||
],
|
],
|
||||||
"numberFields": [
|
"numberFields": [
|
||||||
"handicapValue",
|
"behinderung",
|
||||||
"complexity"
|
"komplexität"
|
||||||
],
|
],
|
||||||
"htmlFields": [
|
"htmlFields": [
|
||||||
"text"
|
"talent"
|
||||||
],
|
],
|
||||||
"foreignDocumentField": [
|
"schemaFields": [
|
||||||
"voraussetzung"
|
"voraussetzung"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -102,6 +103,7 @@
|
||||||
"zauberdauer",
|
"zauberdauer",
|
||||||
"wirkung",
|
"wirkung",
|
||||||
"kosten",
|
"kosten",
|
||||||
|
"zielobjekt",
|
||||||
"reichweite",
|
"reichweite",
|
||||||
"wirkungsdauer",
|
"wirkungsdauer",
|
||||||
"modifikationen",
|
"modifikationen",
|
||||||
|
|
@ -115,6 +117,9 @@
|
||||||
"numberFields": [
|
"numberFields": [
|
||||||
"seite"
|
"seite"
|
||||||
],
|
],
|
||||||
|
"schemaFields": [
|
||||||
|
"varianten"
|
||||||
|
],
|
||||||
"arrayFields": [
|
"arrayFields": [
|
||||||
"probe"
|
"probe"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue