Add setting to limit how many Aspects a character can have equipped
This commit is contained in:
parent
2fff1b84b5
commit
3e40d0f8c5
6 changed files with 77 additions and 11 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import PlayerActor from "./Player.mjs";
|
||||
|
||||
export class ActorHandler extends Actor {
|
||||
actorTypes = {
|
||||
proxyTargets = {
|
||||
player: PlayerActor,
|
||||
};
|
||||
|
||||
|
|
@ -11,7 +11,12 @@ export class ActorHandler extends Actor {
|
|||
|
||||
/** @type {class|undefined} */
|
||||
get fn() {
|
||||
return this.actorTypes[this.type];
|
||||
return this.proxyTargets[this.type];
|
||||
};
|
||||
|
||||
async proxyFunction(funcName, ...args) {
|
||||
if (!this.fn?.[funcName]) return;
|
||||
return await this.fn?.[funcName].bind(this)(...args);
|
||||
};
|
||||
|
||||
async openEmbeddedSheet($event) {
|
||||
|
|
|
|||
|
|
@ -70,17 +70,23 @@ async function createCustomSpell() {
|
|||
}]);
|
||||
};
|
||||
|
||||
/** @this {Actor} */
|
||||
async function atAspectLimit() {
|
||||
let limit = game.settings.get(`dotdungeon`, `aspectLimit`);
|
||||
console.log(this.itemTypes.aspect.length, `>=`, limit, `-->`, this.itemTypes.aspect.length >= limit)
|
||||
return this.itemTypes.aspect.length >= limit;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ItemHandler} item
|
||||
* @this {Actor}
|
||||
*/
|
||||
async function preAspectEmbed(item) {
|
||||
let limit = 1
|
||||
if (this.itemTypes.aspect.length >= limit) {
|
||||
if (await atAspectLimit.bind(this)()) {
|
||||
ui.notifications.error(
|
||||
game.i18n.format(
|
||||
`dotdungeon.notification.error.aspect-limit-reached`,
|
||||
{ limit }
|
||||
{ limit: game.settings.get(`dotdungeon`, `aspectLimit`) }
|
||||
),
|
||||
{ console: false }
|
||||
);
|
||||
|
|
@ -89,10 +95,11 @@ async function preAspectEmbed(item) {
|
|||
};
|
||||
|
||||
export default {
|
||||
genericEmbeddedDelete,
|
||||
genericEmbeddedUpdate,
|
||||
atAspectLimit,
|
||||
createCustomItem,
|
||||
createCustomAspect,
|
||||
createCustomSpell,
|
||||
genericEmbeddedDelete,
|
||||
genericEmbeddedUpdate,
|
||||
preAspectEmbed,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue