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
|
|
@ -22,4 +22,41 @@ export default function() {
|
|||
default: "supplies",
|
||||
requiresReload: false,
|
||||
});
|
||||
|
||||
/*
|
||||
These two settings are used in coordination in order to prevent the Aspect
|
||||
Limit from being set to a value that just absolutely stupid (i.e. negative
|
||||
values, non-integer values). The preSaveAspectLimit is the one that's actually
|
||||
displayed in the settings dialogue, while the aspectLimit is the one that's
|
||||
used by all of the code.
|
||||
*/
|
||||
game.settings.register(`dotdungeon`, `aspectLimit`, {
|
||||
scope: `world`,
|
||||
default: 1,
|
||||
type: Number,
|
||||
});
|
||||
game.settings.register(`dotdungeon`, `preSaveAspectLimit`, {
|
||||
name: `dotdungeon.settings.aspectLimit.name`,
|
||||
hint: `dotdungeon.settings.aspectLimit.description`,
|
||||
scope: `world`,
|
||||
config: true,
|
||||
default: 1,
|
||||
type: Number,
|
||||
onChange(value) {
|
||||
const current = game.settings.get(`dotdungeon`, `aspectLimit`);
|
||||
if (current == value) return;
|
||||
|
||||
if (value < 0) {
|
||||
ui.notifications.warn(
|
||||
`dotdungeon.notification.warn.negative-aspect-limit`,
|
||||
{ localize: true, console: false }
|
||||
);
|
||||
game.settings.set(`dotdungeon`, `preSaveAspectLimit`, current);
|
||||
return;
|
||||
};
|
||||
let floored = Math.floor(value);
|
||||
game.settings.set(`dotdungeon`, `aspectLimit`, floored);
|
||||
game.settings.set(`dotdungeon`, `preSaveAspectLimit`, floored);
|
||||
},
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue