Pets and misc changes

This commit is contained in:
Oliver-Akins 2024-01-26 21:40:27 -07:00
parent 4a3523d6cf
commit b30aa18a27
15 changed files with 244 additions and 32 deletions

View file

@ -62,6 +62,26 @@ async function createCustomSpell() {
}]);
};
/** @this {Actor} */
async function createCustomPet() {
const body = new URLSearchParams({
number: 1,
animal: `Cat`,
"X-Requested-With": "fetch"
})
const r = await fetch(
`https://randommer.io/pet-names`,
{
method: "POST",
body
}
);
await createCustomItem.bind(this)([{
type: `pet`,
name: (await r.json())[0] ?? game.i18n.localize(`dotdungeon.defaults.pet.name`),
}]);
};
/** @this {Actor} */
async function atAspectLimit() {
let limit = game.settings.get(`dotdungeon`, `aspectLimit`);
@ -90,6 +110,7 @@ export default {
createCustomItem,
createCustomAspect,
createCustomSpell,
createCustomPet,
genericEmbeddedDelete,
preAspectEmbed,
};

View file

@ -2,6 +2,7 @@
import { AspectItemData } from "./models/Item/Aspect.mjs";
import { SpellItemData } from "./models/Item/Spell.mjs";
import { PlayerData } from "./models/Actor/Player.mjs";
import { PetItemData } from "./models/Item/Pet.mjs";
import { SyncData } from "./models/Actor/Sync.mjs";
// Main Documents
@ -13,6 +14,7 @@ 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";
import { PetSheet } from "./sheets/PetSheet.mjs";
// Utility imports
import * as hbs from "./handlebars.mjs";
@ -34,6 +36,7 @@ Hooks.once(`init`, () => {
CONFIG.Actor.dataModels.sync = SyncData;
CONFIG.Item.dataModels.aspect = AspectItemData;
CONFIG.Item.dataModels.spell = SpellItemData;
CONFIG.Item.dataModels.pet = PetItemData;
CONFIG.Actor.documentClass = ActorHandler;
CONFIG.Item.documentClass = ItemHandler;
@ -61,6 +64,11 @@ Hooks.once(`init`, () => {
types: ["spell"],
label: "dotdungeon.sheet-names.SpellSheet"
});
Items.registerSheet("dotdungeon", PetSheet, {
makeDefault: true,
types: ["pet"],
lable: "dotdungeon.sheet-names.PetSheet"
})
hbs.registerHandlebarsHelpers();
hbs.preloadHandlebarsTemplates();

View file

@ -15,7 +15,7 @@ export const partials = [
`actors/char-sheet-mvp/panels/roles.pc.hbs`,
`actors/char-sheet-mvp/panels/spells.pc.hbs`,
`actors/char-sheet-mvp/panels/storage.pc.hbs`,
`actors/char-sheet-mvp/panels/summons.pc.hbs`,
`actors/char-sheet-mvp/panels/pets.pc.hbs`,
`actors/char-sheet-mvp/panels/sync.pc.hbs`,
`actors/char-sheet-mvp/panels/weapons.pc.hbs`,
];

View file

@ -0,0 +1,32 @@
import { GenericItemSheet } from "./GenericItemSheet.mjs";
export class PetSheet extends GenericItemSheet {
static get defaultOptions() {
let opts = mergeObject(
super.defaultOptions,
{
template: `systems/dotdungeon/templates/items/pet.hbs`,
width: 280,
height: 340,
}
);
opts.classes.push(`dotdungeon`);
return opts;
};
activateListeners(html) {
super.activateListeners(html);
if (!this.isEditable) return;
console.debug(`.dungeon | Adding event listeners for Pet Item: ${this.id}`);
};
async getData() {
const ctx = await super.getData();
ctx.item = this.item;
ctx.system = this.item.system;
ctx.flags = this.item.flags;
return ctx;
};
};

View file

@ -27,7 +27,6 @@ export class SpellSheet extends GenericItemSheet {
ctx.item = this.item;
ctx.system = this.item.system;
ctx.flags = this.item.flags;
console.log(ctx)
return ctx;
};
};