Working on 0.8.x

- Advancement bonus management for onDrop and delete
This commit is contained in:
Vlyan
2021-05-22 23:33:24 +02:00
parent f8afea9513
commit 286ee72c9f
2 changed files with 27 additions and 4 deletions

View File

@@ -215,6 +215,15 @@ export class BaseSheetL5r5e extends ActorSheet {
await this.actor.addBonus(item); await this.actor.addBonus(item);
break; break;
case "title":
// Add embed advancements bonus
for (let [embedId, embedItem] of item.data.data.items) {
if (embedItem.data.type === "advancement") {
await this.actor.addBonus(embedItem);
}
}
break;
case "technique": case "technique":
// School_ability and mastery_ability, allow only 1 per type // School_ability and mastery_ability, allow only 1 per type
if (CONFIG.l5r5e.techniques.get(item.data.data.technique_type)?.type === "school") { if (CONFIG.l5r5e.techniques.get(item.data.data.technique_type)?.type === "school") {
@@ -258,7 +267,7 @@ export class BaseSheetL5r5e extends ActorSheet {
return; return;
} }
return this._onDropItemCreate(item.data.toObject(false)); return this._onDropItemCreate(item.data.toJSON());
} }
/** /**
@@ -487,9 +496,20 @@ export class BaseSheetL5r5e extends ActorSheet {
} }
const callback = async () => { const callback = async () => {
// Specific advancements, remove 1 to selected ring/skill switch (tmpItem.type) {
if (tmpItem.type === "advancement") { case "advancement":
await this.actor.removeBonus(tmpItem); // Remove advancements bonus (1 to selected ring/skill)
await this.actor.removeBonus(tmpItem);
break;
case "title":
// Remove embed advancements bonus
for (let [embedId, embedItem] of tmpItem.data.data.items) {
if (embedItem.data.type === "advancement") {
await this.actor.removeBonus(embedItem);
}
}
break;
} }
return this.actor.deleteEmbeddedDocuments("Item", [itemId]); return this.actor.deleteEmbeddedDocuments("Item", [itemId]);
}; };

View File

@@ -106,6 +106,9 @@ export class TitleSheetL5r5e extends ItemSheetL5r5e {
async _addSubItem(event) { async _addSubItem(event) {
// Show Dialog // Show Dialog
const selectedType = await game.l5r5e.HelpersL5r5e.showSubItemDialog(["advancement", "technique"]); const selectedType = await game.l5r5e.HelpersL5r5e.showSubItemDialog(["advancement", "technique"]);
if (!selectedType) {
return;
}
// Create the new Item // Create the new Item
const itemId = await this.document.addEmbedItem( const itemId = await this.document.addEmbedItem(