Begin working on Aspect items

This commit is contained in:
Oliver-Akins 2023-11-29 22:41:43 -07:00
parent 58facf1490
commit 25e3fa1bb8
14 changed files with 204 additions and 80 deletions

View file

@ -1,5 +1,6 @@
{ {
"dotdungeon.CharacterSheet": "PC Sheet", "dotdungeon.sheet.PlayerSheet": "PC Sheet",
"dotdungeon.sheet.AspectSheet": "Aspect Sheet",
"dotdungeon.panel.avatar": "Avatar", "dotdungeon.panel.avatar": "Avatar",
"dotdungeon.panel.statistics": "Statistics", "dotdungeon.panel.statistics": "Statistics",

View file

@ -0,0 +1,11 @@
export class AspectItem extends Item {
prepareData() {
super.prepareData();
};
prepareDerivedData() {};
_preparePCData() {};
_prepareNPCData() {};
};

View file

@ -1,32 +1,42 @@
// Class imports // Data Models
import { PlayerActor } from "./documents/PlayerActor.js"; import { AspectItemData } from "./models/AspectItemData.mjs";
import { PlayerData } from "./models/PlayerData.mjs";
// Main Documents
import { PlayerActor } from "./documents/PlayerActor.mjs";
import { AspectItem } from "./documents/AspectItem.mjs";
// Character Sheets
import { AspectSheet } from "./sheets/AspectSheet.mjs";
import { PlayerSheet } from "./sheets/PlayerSheet.mjs"; import { PlayerSheet } from "./sheets/PlayerSheet.mjs";
import { PlayerData } from "./models/PlayerData.js";
// Utility imports // Utility imports
import * as hbs from "./handlebars.js"; import * as hbs from "./handlebars.mjs";
// Non-Setup hooks // Non-Setup hooks
import "./hooks/hotReload.js"; import "./hooks/hotReload.mjs";
Hooks.once(`init`, () => { Hooks.once(`init`, () => {
console.log(`.dungeon | Init hook started`) console.debug(`.dungeon | Initializing`);
game.boilerplate = { game.boilerplate = {
PlayerActor, PlayerActor,
AspectItem,
}; };
CONFIG.Actor.systemDataModels.player = PlayerData; CONFIG.Actor.dataModels.player = PlayerData;
CONFIG.Item.dataModels.aspect = AspectItemData;
Actors.unregisterSheet("core", ActorSheet); Actors.unregisterSheet("core", ActorSheet);
// Actors.registerSheet("dotdungeon", CharacterSheet, { makeDefault: true, }); Actors.registerSheet("dotdungeon.sheet", PlayerSheet, { makeDefault: true });
Actors.registerSheet("dotdungeon.player", PlayerSheet, { makeDefault: true });
Items.registerSheet("dotdungeon.sheet", AspectSheet, { makeDefault: true });
hbs.registerHandlebarsHelpers(); hbs.registerHandlebarsHelpers();
hbs.preloadHandlebarsTemplates(); hbs.preloadHandlebarsTemplates();
console.info(`.dungeon | Dot Dungeon has been initialized fully`);
}); });
Hooks.once(`ready`, () => { Hooks.once(`ready`, () => {
console.info(".dungeon | Ready"); console.debug(".dungeon | Ready");
}); });

View file

@ -1,10 +1,11 @@
export const partials = [ export const partials = [
"actors/char-sheet-mvp/partials/dice_choice.hbs", `actors/char-sheet-mvp/partials/dice_choice.hbs`,
"actors/char-sheet-mvp/partials/stat.hbs", `actors/char-sheet-mvp/partials/stat.hbs`,
"actors/char-sheet-mvp/partials/skill.hbs", `actors/char-sheet-mvp/partials/skill.hbs`,
"actors/char-sheet-mvp/partials/panel.hbs", `actors/char-sheet-mvp/partials/panel.hbs`,
"actors/char-sheet-mvp/partials/panels/skills.hbs", `actors/char-sheet-mvp/partials/panels/skills.hbs`,
] `items/aspect.hbs`,
];
export async function registerHandlebarsHelpers() { export async function registerHandlebarsHelpers() {
Handlebars.registerHelper({ Handlebars.registerHelper({
@ -21,7 +22,7 @@ export async function preloadHandlebarsTemplates() {
for ( const partial of partials ) { for ( const partial of partials ) {
console.debug(`Loading partial: ${partial}`); console.debug(`Loading partial: ${partial}`);
const path = `${pathPrefix}${partial}`; const path = `${pathPrefix}${partial}`;
paths[`dotdungeon.${partial.split("/").pop().replace(".hbs", "")}`] = path; paths[`dotdungeon.${partial.split(`/`).pop().replace(`.hbs`, ``)}`] = path;
} }
console.debug(`Loaded ${partials.length} partials`); console.debug(`Loaded ${partials.length} partials`);

View file

@ -1,4 +1,4 @@
import * as hbs from "../handlebars.js"; import * as hbs from "../handlebars.mjs";
Hooks.on(`hotReload`, async (data) => { Hooks.on(`hotReload`, async (data) => {
if (data.extension !== 'hbs') { if (data.extension !== 'hbs') {

View file

@ -0,0 +1,12 @@
export class AspectItemData extends foundry.abstract.DataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
name: new fields.HTMLField({ nullable: true, blank: false, trim: true }),
used: new fields.BooleanField(),
/** The number of seconds that the effect of the aspect stays */
deactivateAfter: new fields.NumberField({ nullable: true }),
info: new fields.HTMLField({ nullable: true, blank: false, trim: true }),
};
};
};

View file

@ -0,0 +1,14 @@
export class CommonItemData extends foundry.abstract.DataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
name: fields.HTMLField({
blank: true,
trim: true,
}),
cost: fields.NumberField({
nullable: true,
})
};
};
};

View file

@ -1,57 +0,0 @@
export class PlayerData extends foundry.abstract.DataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
stats: new fields.SchemaField({
build: new fields.StringField({
blank: true,
trim: true,
options(...args) {
console.log(`build args`, args);
return [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
},
}),
meta: new fields.StringField({
blank: true,
trim: true,
options(...args) {
console.log(args);
return [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
},
}),
presence: new fields.StringField({
blank: true,
trim: true,
options(...args) {
console.log(args);
return [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
},
}),
hands: new fields.StringField({
blank: true,
trim: true,
options(...args) {
console.log(args);
return [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
},
}),
tilt: new fields.StringField({
blank: true,
trim: true,
options(...args) {
console.log(args);
return [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
},
}),
rng: new fields.StringField({
blank: true,
trim: true,
options(...args) {
console.log(args);
return [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
},
}),
}),
};
};
};

View file

@ -0,0 +1,99 @@
function diceChoiceField() {
return new foundry.data.fields.StringField({
blank: true,
trim: true,
options() {
return [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
},
});
};
function trainingLevelField() {
return new foundry.data.fields.StringField({
blank: true,
trim: true,
options: [ ``, `locked`, `+2`, `+4` ],
});
};
export class PlayerData extends foundry.abstract.DataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
bytes: new fields.NumberField({
integer: true,
positive: true,
}),
stats: new fields.SchemaField({
build: diceChoiceField(),
meta: diceChoiceField(),
presence: diceChoiceField(),
hands: diceChoiceField(),
tilt: diceChoiceField(),
rng: diceChoiceField(),
}),
skills: new fields.SchemaField({
build: new fields.SchemaField({
defense: trainingLevelField(),
magic: trainingLevelField(),
melee: trainingLevelField(),
platforming: trainingLevelField(),
strength: trainingLevelField(),
}),
meta: new fields.SchemaField({
alchemy: trainingLevelField(),
arcanum: trainingLevelField(),
dreams: trainingLevelField(),
lore: trainingLevelField(),
navigation: trainingLevelField(),
}),
presence: new fields.SchemaField({
animal_handling: trainingLevelField(),
perception: trainingLevelField(),
sneak: trainingLevelField(),
speech: trainingLevelField(),
vibe: trainingLevelField(),
}),
hands: new fields.SchemaField({
accuracy: trainingLevelField(),
crafting: trainingLevelField(),
engineering: trainingLevelField(),
explosives: trainingLevelField(),
piloting: trainingLevelField(),
})
}),
aspect: new fields.StringField({
blank: true,
trim: true,
}),
roles: new fields.ArrayField(new fields.HTMLField()),
weapon: new fields.SchemaField({
name: new fields.HTMLField(),
damage: new fields.HTMLField(),
ammo: new fields.SchemaField({
quivers: new fields.NumberField({ min: 0, max: 5, integer: true }),
mags: new fields.NumberField({ min: 0, max: 5, integer: true }),
cells: new fields.NumberField({ min: 0, max: 5, integer: true }),
}),
}),
supplies: new fields.NumberField({ min: 0, max: 5, integer: true }),
materials: new fields.NumberField({ min: 0, max: 5, integer: true }),
pet: new fields.SchemaField({
name: new fields.HTMLField(),
info: new fields.HTMLField(),
}),
transport: new fields.SchemaField({
name: new fields.HTMLField(),
upkeep: new fields.NumberField({ min: 0, integer: true }),
info: new fields.HTMLField(),
}),
spells: new fields.ArrayField(
new fields.SchemaField({
name: new fields.HTMLField(),
cost: new fields.NumberField(),
info: new fields.HTMLField(),
})
),
};
};
};

View file

@ -0,0 +1,28 @@
export class AspectSheet extends ItemSheet {
static get defaultOptions() {
let opts = mergeObject(
super.defaultOptions,
{
template: `systems/dotdungeon/templates/items/aspect.hbs`,
width: 280,
height: 340,
}
);
opts.classes.push(`dotdungeon`);
return opts;
};
getData() {
const ctx = super.getData();
const item = this.item.toObject(false);
ctx.system = item.system;
ctx.flags = item.flags;
console.groupCollapsed(`AspectSheet.getData`);
console.log(`ctx`, ctx);
console.log(`item`, item);
console.groupEnd();
return ctx;
};
};

View file

@ -3,10 +3,10 @@ export class PlayerSheet extends ActorSheet {
let opts = mergeObject( let opts = mergeObject(
super.defaultOptions, super.defaultOptions,
{ {
template: "systems/dotdungeon/templates/actors/char-sheet-mvp/sheet.hbs" template: `systems/dotdungeon/templates/actors/char-sheet-mvp/sheet.hbs`
} }
); );
opts.classes.push("dotdungeon"); opts.classes.push(`dotdungeon`);
return opts; return opts;
}; };
@ -27,7 +27,7 @@ export class PlayerSheet extends ActorSheet {
ctx.system = actor.system; ctx.system = actor.system;
ctx.flags = actor.flags; ctx.flags = actor.flags;
console.group(`PlayerSheet.getData`); console.groupCollapsed(`PlayerSheet.getData`);
console.log(`ctx`, ctx); console.log(`ctx`, ctx);
console.log(`actor`, actor); console.log(`actor`, actor);
console.groupEnd(); console.groupEnd();

View file

@ -6,6 +6,7 @@
}, },
"Item": { "Item": {
"types": [ "types": [
"aspect",
"weapon", "weapon",
"armour", "armour",
"equipment", "equipment",

View file

@ -0,0 +1,4 @@
<form autocomplete="off" class="item--aspect">
{{log system}}
<h2>I'm an Item :')</h2>
</form>