mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
Fix removal when de-leveling
This commit is contained in:
parent
13bcadf142
commit
f95e511a4d
1 changed files with 7 additions and 6 deletions
|
|
@ -233,16 +233,14 @@ export default class DhpActor extends Actor {
|
||||||
|
|
||||||
if (multiclass) {
|
if (multiclass) {
|
||||||
const multiclassItem = this.items.find(x => x.uuid === multiclass.itemUuid);
|
const multiclassItem = this.items.find(x => x.uuid === multiclass.itemUuid);
|
||||||
const multiclassFeatures = this.items.filter(
|
const multiclassRelatedFeatures = this.items.filter(
|
||||||
x => x.system.originItemType === 'class' && x.system.multiclassOrigin
|
x => ['class', 'subclass'].includes(x.system.originItemType) && x.system.multiclassOrigin
|
||||||
);
|
|
||||||
const subclassFeatures = this.items.filter(
|
|
||||||
x => x.system.originItemType === 'subclass' && x.system.multiclassOrigin
|
|
||||||
);
|
);
|
||||||
|
if (!multiclassItem) console.error('Unexpected missing multiclass item to remove');
|
||||||
|
|
||||||
this.deleteEmbeddedDocuments(
|
this.deleteEmbeddedDocuments(
|
||||||
'Item',
|
'Item',
|
||||||
[multiclassItem, ...multiclassFeatures, ...subclassFeatures].map(x => x.id)
|
[multiclassItem, ...multiclassRelatedFeatures].filter(i => !!i).map(x => x.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.update({
|
this.update({
|
||||||
|
|
@ -394,6 +392,7 @@ export default class DhpActor extends Actor {
|
||||||
const embeddedItem = await this.createEmbeddedDocuments('Item', [
|
const embeddedItem = await this.createEmbeddedDocuments('Item', [
|
||||||
{
|
{
|
||||||
...multiclassData,
|
...multiclassData,
|
||||||
|
uuid: multiclassItem.uuid, // todo: replace with setting an id and using keepId
|
||||||
_stats: getStatsWithSource(multiclassItem),
|
_stats: getStatsWithSource(multiclassItem),
|
||||||
system: {
|
system: {
|
||||||
...multiclassData.system,
|
...multiclassData.system,
|
||||||
|
|
@ -407,6 +406,7 @@ export default class DhpActor extends Actor {
|
||||||
await this.createEmbeddedDocuments('Item', [
|
await this.createEmbeddedDocuments('Item', [
|
||||||
{
|
{
|
||||||
...subclassData,
|
...subclassData,
|
||||||
|
uuid: subclassItem.uuid, // todo: replace with setting an id and using keepId
|
||||||
_stats: getStatsWithSource(subclassItem),
|
_stats: getStatsWithSource(subclassItem),
|
||||||
system: {
|
system: {
|
||||||
...subclassData.system,
|
...subclassData.system,
|
||||||
|
|
@ -427,6 +427,7 @@ export default class DhpActor extends Actor {
|
||||||
const embeddedItem = await this.createEmbeddedDocuments('Item', [
|
const embeddedItem = await this.createEmbeddedDocuments('Item', [
|
||||||
{
|
{
|
||||||
...cardData,
|
...cardData,
|
||||||
|
uuid: cardItem.uuid, // todo: replace with setting an id and using keepId
|
||||||
_stats: getStatsWithSource(cardItem),
|
_stats: getStatsWithSource(cardItem),
|
||||||
system: {
|
system: {
|
||||||
...cardData.system,
|
...cardData.system,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue