Finish the Inventory item improvements
This commit is contained in:
parent
83039c6144
commit
2f8ec1b79c
9 changed files with 107 additions and 13 deletions
|
|
@ -84,6 +84,7 @@ export class ActorHandler extends Actor {
|
|||
*/
|
||||
async preItemEmbed(item) {
|
||||
let type = item.type[0].toUpperCase() + item.type.slice(1);
|
||||
console.log(`preEmbed type =`, type)
|
||||
if (this.fn?.[`pre${type}Embed`]) {
|
||||
return await this.fn?.[`pre${type}Embed`].bind(this)(item);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ async function createCustomItem(defaults, opts = {}) {
|
|||
};
|
||||
};
|
||||
|
||||
/** @this {Actor} */
|
||||
async function createCustomUntyped() {
|
||||
await createCustomItem.bind(this)([{
|
||||
type: `untyped`,
|
||||
name: game.i18n.format(`dotdungeon.defaults.untyped.name`),
|
||||
}]);
|
||||
};
|
||||
|
||||
/** @this {Actor} */
|
||||
async function createCustomAspect() {
|
||||
await createCustomItem.bind(this)([{
|
||||
|
|
@ -105,12 +113,33 @@ async function preAspectEmbed(item) {
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ItemHandler} item
|
||||
* @this {Actor}
|
||||
*/
|
||||
async function preUntypedEmbed(item) {
|
||||
let inventoryItem = this.itemTypes.untyped.find(i => i.name === item.name);
|
||||
if (inventoryItem) {
|
||||
inventoryItem.update({"system.quantity": inventoryItem.system.quantity + 1});
|
||||
ui.notifications.info(
|
||||
game.i18n.format(
|
||||
`dotdungeon.notification.info.increased-item-quantity`,
|
||||
{ name: inventoryItem.name }
|
||||
),
|
||||
{ console: false }
|
||||
);
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
export default {
|
||||
atAspectLimit,
|
||||
createCustomItem,
|
||||
createCustomUntyped,
|
||||
createCustomAspect,
|
||||
createCustomSpell,
|
||||
createCustomPet,
|
||||
genericEmbeddedDelete,
|
||||
preAspectEmbed,
|
||||
preUntypedEmbed,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue