Working on the spells panel, which resulted in a lot of weird structural changes that aren't *really* functional yet
This commit is contained in:
parent
227029ffcd
commit
dfc51a5899
31 changed files with 499 additions and 84 deletions
|
|
@ -1,9 +1,22 @@
|
|||
export const DOTDUNGEON = {};
|
||||
const statDice = [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
|
||||
|
||||
DOTDUNGEON.statDice = [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
|
||||
const trainingLevels = [``, `locked`, `+2`, `+4`];
|
||||
|
||||
DOTDUNGEON.trainingLevels = [``, `locked`, `+2`, `+4`];
|
||||
const damageTypes = [ `slashing`, `piercing`, `smashing`, `gun`, `neon`, `shadow`, `solar` ];
|
||||
|
||||
DOTDUNGEON.damageTypes = [ `slashing`, `piercing`, `smashing`, `gun`, `neon`, `shadow`, `solar` ];
|
||||
const ammoTypes = [`quivers`, `mags`, `cells`];
|
||||
|
||||
DOTDUNGEON.ammoTypes = [`quivers`, `mags`, `cells`];
|
||||
const skills = {
|
||||
build: [ "defense", "magic", "melee", "platforming", "strength", ],
|
||||
meta: [ "alchemy", "arcanum", "dreams", "lore", "navigation", ],
|
||||
presence: [ "animal_handling", "perception", "sneak", "speech", "vibes", ],
|
||||
hands: [ "accuracy", "crafting", "engineering", "explosives", "piloting", ]
|
||||
};
|
||||
|
||||
export default {
|
||||
statDice,
|
||||
trainingLevels,
|
||||
damageTypes,
|
||||
ammoTypes,
|
||||
skills,
|
||||
};
|
||||
|
|
@ -14,6 +14,11 @@ export class ActorHandler extends Actor {
|
|||
return this.actorTypes[this.type];
|
||||
};
|
||||
|
||||
updateEmbeddedDocument($event) {
|
||||
if (!this.fn?.updateEmbeddedDocument) return;
|
||||
this.fn.updateEmbeddedDocument.bind(this)($event);
|
||||
};
|
||||
|
||||
createCustomSpell() {
|
||||
if (!this.fn?.createCustomSpell) return;
|
||||
this.fn.createCustomSpell.bind(this)();
|
||||
|
|
|
|||
|
|
@ -7,4 +7,10 @@ export class PlayerActor {
|
|||
description: ``,
|
||||
};
|
||||
};
|
||||
|
||||
static async updateEmbeddedDocument($event) {
|
||||
let data = $event.target.dataset;
|
||||
let item = await fromUuid(data.embeddedId);
|
||||
item?.update({ [data.embeddedUpdate]: $event.target.value });
|
||||
};
|
||||
};
|
||||
|
|
|
|||
80
module/dotdungeon.mjs
Normal file
80
module/dotdungeon.mjs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// Data Models
|
||||
import { AspectItemData } from "./models/AspectItemData.mjs";
|
||||
import { SpellItemData } from "./models/Item/Spell.mjs";
|
||||
import { PlayerData } from "./models/PlayerData.mjs";
|
||||
import { SyncData } from "./models/SyncData.mjs";
|
||||
|
||||
// Main Documents
|
||||
import { ActorHandler } from "./documents/Actor/Handler.mjs";
|
||||
|
||||
// Character Sheets
|
||||
import { SpellSheet } from "./sheets/SpellSheet.mjs";
|
||||
import { AspectSheet } from "./sheets/AspectSheet.mjs";
|
||||
import { PlayerSheet } from "./sheets/PlayerSheet.mjs";
|
||||
import { BasicSyncSheet } from "./sheets/SyncVariations/BasicSyncSheet.mjs";
|
||||
|
||||
// Utility imports
|
||||
import * as hbs from "./handlebars.mjs";
|
||||
|
||||
// Non-Setup hooks
|
||||
import "./hooks/hotReload.mjs";
|
||||
|
||||
// Misc Imports
|
||||
import loadSettings from "./settings/index.mjs";
|
||||
import DOTDUNGEON from "./config.mjs";
|
||||
|
||||
|
||||
Hooks.once(`init`, () => {
|
||||
console.debug(`.dungeon | Initializing`);
|
||||
|
||||
loadSettings();
|
||||
|
||||
CONFIG.Actor.dataModels.player = PlayerData;
|
||||
CONFIG.Actor.dataModels.sync = SyncData;
|
||||
CONFIG.Item.dataModels.aspect = AspectItemData;
|
||||
CONFIG.Item.dataModels.spell = SpellItemData;
|
||||
CONFIG.Actor.documentClass = ActorHandler;
|
||||
|
||||
CONFIG.DOTDUNGEON = DOTDUNGEON;
|
||||
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("dotdungeon", PlayerSheet, {
|
||||
makeDefault: true,
|
||||
types: ["player"],
|
||||
label: "dotdungeon.sheet-names.PlayerSheet"
|
||||
});
|
||||
Actors.registerSheet("dotdungeon", BasicSyncSheet, {
|
||||
makeDefault: true,
|
||||
types: ["sync"],
|
||||
label: "dotdungeon.sheet-names.SyncSheet.basic"
|
||||
});
|
||||
|
||||
Items.registerSheet("dotdungeon", AspectSheet, {
|
||||
makeDefault: true,
|
||||
types: ["aspect"],
|
||||
label: "dotdungeon.sheet-names.AspectSheet"
|
||||
});
|
||||
Items.registerSheet("dotdungeon", SpellSheet, {
|
||||
makeDefault: true,
|
||||
types: ["spell"],
|
||||
label: "dotdungeon.sheet-names.SpellSheet"
|
||||
});
|
||||
|
||||
hbs.registerHandlebarsHelpers();
|
||||
hbs.preloadHandlebarsTemplates();
|
||||
});
|
||||
|
||||
|
||||
Hooks.once(`ready`, () => {
|
||||
console.debug(".dungeon | Ready");
|
||||
|
||||
if (game.settings.get(`dotdungeon`, `devMode`)) {
|
||||
let tab = game.settings.get(`dotdungeon`, `defaultTab`);
|
||||
if (!ui.sidebar?.tabs?.[tab]) {
|
||||
console.error(`Couldn't find a sidebar tab with ID:`, tab);
|
||||
} else {
|
||||
console.debug(`Switching sidebar tab to:`, tab);
|
||||
ui.sidebar.tabs[tab].activate();
|
||||
};
|
||||
};
|
||||
});
|
||||
|
|
@ -7,5 +7,6 @@
|
|||
* @returns {"open"|null} The HTML insertion indicating the details is expanded
|
||||
*/
|
||||
export function detailsExpanded(expanded, collapseId) {
|
||||
console.log(`.dungeon |`, collapseId, expanded)
|
||||
return expanded.has(collapseId) ? "open" : null;
|
||||
};
|
||||
|
|
@ -1 +1,10 @@
|
|||
export function schemaOptions() {};
|
||||
export function schemaOptions(document, schemaPath) {
|
||||
let splitPath = schemaPath.split(`.`);
|
||||
|
||||
let tempLocation = document.schema.fields.system;
|
||||
for (const part of splitPath) {
|
||||
tempLocation = tempLocation[part].fields
|
||||
}
|
||||
|
||||
return CONFIG.Actor.dataModels.player.schema.fields.weapon.fields.mainHand.fields.damage.options.options;
|
||||
};
|
||||
|
|
@ -2,11 +2,6 @@ export class CommonItemData extends foundry.abstract.DataModel {
|
|||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
name: new fields.StringField({
|
||||
initial: ``,
|
||||
blank: true,
|
||||
trim: true,
|
||||
}),
|
||||
cost: new fields.NumberField({
|
||||
initial: null,
|
||||
nullable: true,
|
||||
|
|
|
|||
22
module/models/Item/Spell.mjs
Normal file
22
module/models/Item/Spell.mjs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { DescribedItemData } from "./DescribedItemData.mjs";
|
||||
import DOTDUNGEON from "../../config.mjs";
|
||||
|
||||
export class SpellItemData extends DescribedItemData {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return mergeObject(super.defineSchema(), {
|
||||
skill: new fields.StringField({
|
||||
initial: ``,
|
||||
blank: true,
|
||||
trim: true,
|
||||
options() {
|
||||
let skills = [ `` ];
|
||||
for (const group in DOTDUNGEON.skills) {
|
||||
skills.push(...skills[group]);
|
||||
};
|
||||
return skills;
|
||||
},
|
||||
}),
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
@ -20,7 +20,7 @@ export class AspectSheet extends ItemSheet {
|
|||
console.debug(`.dungeon | Adding event listeners for Item: ${this.id}`);
|
||||
};
|
||||
|
||||
getData() {
|
||||
async getData() {
|
||||
const ctx = {};
|
||||
const item = this.item.toObject(false);
|
||||
|
||||
|
|
@ -29,10 +29,6 @@ export class AspectSheet extends ItemSheet {
|
|||
ctx.system = item.system;
|
||||
ctx.flags = item.flags;
|
||||
|
||||
console.groupCollapsed(`AspectSheet.getData`);
|
||||
console.log(`ctx`, ctx);
|
||||
console.log(`item`, item);
|
||||
console.groupEnd();
|
||||
return ctx;
|
||||
};
|
||||
};
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
import DOTDUNGEON from "../config.mjs";
|
||||
import { preloadIcons } from "../handlebars.mjs";
|
||||
|
||||
export class GenericActorSheet extends ActorSheet {
|
||||
_expanded = new Set();
|
||||
|
||||
|
|
@ -8,8 +11,8 @@ export class GenericActorSheet extends ActorSheet {
|
|||
`resourcesOrSupplies`,
|
||||
];
|
||||
|
||||
getData() {
|
||||
const ctx = super.getData();
|
||||
async getData() {
|
||||
const ctx = {};
|
||||
|
||||
// Send all of the settings that sheets need into their context
|
||||
ctx.settings = {};
|
||||
|
|
@ -24,6 +27,10 @@ export class GenericActorSheet extends ActorSheet {
|
|||
idp: this.actor.uuid,
|
||||
};
|
||||
|
||||
ctx.actor = this.actor;
|
||||
ctx.config = DOTDUNGEON;
|
||||
ctx.icons = await preloadIcons();
|
||||
|
||||
return ctx;
|
||||
};
|
||||
|
||||
|
|
|
|||
42
module/sheets/GenericItemSheet.mjs
Normal file
42
module/sheets/GenericItemSheet.mjs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { preloadIcons } from "../handlebars.mjs";
|
||||
|
||||
export class GenericItemSheet extends ItemSheet {
|
||||
_expanded = new Set();
|
||||
|
||||
#propogatedSettings = [
|
||||
`devMode`,
|
||||
`showAvatarOnSheet`,
|
||||
`playersCanChangeGroup`,
|
||||
`resourcesOrSupplies`,
|
||||
];
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
if (this.document.isEmbedded) return;
|
||||
if (!this.isEditable) return;
|
||||
console.debug(`.dungeon | Adding event listeners for Generic Item: ${this.id}`);
|
||||
};
|
||||
|
||||
async getData() {
|
||||
const ctx = {};
|
||||
const item = this.item.toObject(false);
|
||||
|
||||
// Send all of the settings that sheets need into their context
|
||||
ctx.settings = {};
|
||||
for (const setting of this.#propogatedSettings) {
|
||||
ctx.settings[setting] = game.settings.get(`dotdungeon`, setting);
|
||||
};
|
||||
|
||||
ctx.isGM = game.users.current.hasRole(CONST.USER_ROLES.ASSISTANT);
|
||||
|
||||
ctx.meta = {
|
||||
expanded: this._expanded,
|
||||
idp: this.actor.uuid,
|
||||
};
|
||||
|
||||
ctx.icons = await preloadIcons();
|
||||
|
||||
return ctx;
|
||||
};
|
||||
};
|
||||
|
|
@ -20,23 +20,23 @@ export class PlayerSheet extends GenericActorSheet {
|
|||
console.debug(`.dungeon | Adding event listeners for Actor: ${this.id}`);
|
||||
|
||||
html.find(`.add-spell`).on(`click`, this.actor.createCustomSpell.bind(this.actor));
|
||||
html.find(`[data-embedded-update]`)
|
||||
.on(`change`, this.actor.updateEmbeddedDocument.bind(this.actor));
|
||||
};
|
||||
|
||||
getData() {
|
||||
const ctx = super.getData();
|
||||
async getData() {
|
||||
const ctx = await super.getData();
|
||||
const actor = this.actor.toObject(false);
|
||||
|
||||
ctx.system = actor.system;
|
||||
ctx.flags = actor.flags;
|
||||
ctx.items = this.actor.itemTypes;
|
||||
|
||||
ctx.computed = {
|
||||
canChangeGroup: ctx.settings.playersCanChangeGroup || ctx.isGM,
|
||||
};
|
||||
|
||||
console.groupCollapsed(`PlayerSheet.getData`);
|
||||
console.log(`ctx`, ctx);
|
||||
console.log(`actor`, actor);
|
||||
console.groupEnd();
|
||||
console.log(ctx)
|
||||
return ctx;
|
||||
};
|
||||
};
|
||||
36
module/sheets/SpellSheet.mjs
Normal file
36
module/sheets/SpellSheet.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { GenericItemSheet } from "./GenericItemSheet.mjs";
|
||||
|
||||
export class SpellSheet extends GenericItemSheet {
|
||||
static get defaultOptions() {
|
||||
let opts = mergeObject(
|
||||
super.defaultOptions,
|
||||
{
|
||||
template: `systems/dotdungeon/templates/items/spell.hbs`,
|
||||
width: 280,
|
||||
height: 340,
|
||||
}
|
||||
);
|
||||
opts.classes.push(`dotdungeon`);
|
||||
return opts;
|
||||
};
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
if (this.document.isEmbedded) return;
|
||||
if (!this.isEditable) return;
|
||||
console.debug(`.dungeon | Adding event listeners for Generic Item: ${this.id}`);
|
||||
};
|
||||
|
||||
async getData() {
|
||||
const ctx = {};
|
||||
const item = this.item.toObject(false);
|
||||
|
||||
ctx.name = super.name;
|
||||
ctx.item = item;
|
||||
ctx.system = item.system;
|
||||
ctx.flags = item.flags;
|
||||
|
||||
return ctx;
|
||||
};
|
||||
};
|
||||
|
|
@ -16,8 +16,8 @@ export class AbstractSyncSheet extends GenericActorSheet {
|
|||
return opts;
|
||||
};
|
||||
|
||||
getData() {
|
||||
const ctx = super.getData();
|
||||
async getData() {
|
||||
const ctx = await super.getData();
|
||||
const actor = this.actor.toObject(false);
|
||||
|
||||
ctx.system = actor.system;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue