Add Items on Character Sheet

Changes:
 + add button to add all different kind of items directly onto the character sheet
 + fix #1 by correctly updating the item
This commit is contained in:
2024-01-20 12:37:05 +01:00
parent c13fef5103
commit 9d72b31d5f
7 changed files with 137 additions and 16 deletions
+13 -1
View File
@@ -1,5 +1,5 @@
import { M5Item } from "../items/M5Item";
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ModOperation, M5ModResult, M5RollData, M5Skill, M5SkillCalculated, M5SkillLearned } from "../M5Base";
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ItemType, M5ModOperation, M5ModResult, M5RollData, M5Skill, M5SkillCalculated, M5SkillLearned } from "../M5Base";
import M5ModAggregate from "./M5ModAggregate";
export class M5Character extends Actor {
// constructor(
@@ -522,6 +522,18 @@ export class M5Character extends Actor {
});
}
createItem(itemName: string, itemType: M5ItemType): Promise<M5Item> {
const itemData = {
name: itemName,
type: itemType,
};
return (this as any).createEmbeddedDocuments("Item", [itemData]).then((docs) => {
const item = docs[0];
return item;
});
}
getItem(itemId: string): any {
if (!(this as any).items) return null;
return (this as any).getEmbeddedDocument("Item", itemId);