mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
remove debug logs
This commit is contained in:
parent
f78cf12f6e
commit
b96aab0142
5 changed files with 4 additions and 54 deletions
|
|
@ -110,8 +110,6 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
const item = await Item.implementation.fromDropData(data);
|
const item = await Item.implementation.fromDropData(data);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
console.log(`Dropping item ${item.name} (${item.uuid}) onto armor ${this.document.name}`);
|
|
||||||
|
|
||||||
// Get current attached UUIDs
|
// Get current attached UUIDs
|
||||||
const currentAttached = this.document.system.attached || [];
|
const currentAttached = this.document.system.attached || [];
|
||||||
const newUUID = item.uuid;
|
const newUUID = item.uuid;
|
||||||
|
|
@ -122,11 +120,7 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Current attached items:`, currentAttached);
|
|
||||||
console.log(`Adding new UUID:`, newUUID);
|
|
||||||
|
|
||||||
const updatedAttached = [...currentAttached, newUUID];
|
const updatedAttached = [...currentAttached, newUUID];
|
||||||
console.log(`Updating armor with attached items:`, updatedAttached);
|
|
||||||
|
|
||||||
await this.document.update({
|
await this.document.update({
|
||||||
'system.attached': updatedAttached
|
'system.attached': updatedAttached
|
||||||
|
|
@ -136,8 +130,6 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
// Both attachment-only and regular effects should be copied when attached
|
// Both attachment-only and regular effects should be copied when attached
|
||||||
const actor = this.document.parent;
|
const actor = this.document.parent;
|
||||||
if (actor && item.effects.size > 0 && this.document.system.equipped) {
|
if (actor && item.effects.size > 0 && this.document.system.equipped) {
|
||||||
console.log(`Checking ${item.effects.size} effects from attached item ${item.name}`);
|
|
||||||
|
|
||||||
const effectsToCreate = [];
|
const effectsToCreate = [];
|
||||||
for (const effect of item.effects) {
|
for (const effect of item.effects) {
|
||||||
// Copy ALL effects when item is attached - attachment-only flag only matters for non-attached items
|
// Copy ALL effects when item is attached - attachment-only flag only matters for non-attached items
|
||||||
|
|
@ -155,22 +147,12 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
effectsToCreate.push(effectData);
|
effectsToCreate.push(effectData);
|
||||||
|
|
||||||
const isAttachmentOnly = effect.flags?.daggerheart?.attachmentOnly === true;
|
|
||||||
console.log(`Effect ${effect.name} (attachment-only: ${isAttachmentOnly}) will be copied to actor`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effectsToCreate.length > 0) {
|
if (effectsToCreate.length > 0) {
|
||||||
const createdEffects = await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate);
|
await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate);
|
||||||
console.log(`Created ${createdEffects.length} effects on actor from attached item`);
|
|
||||||
} else {
|
|
||||||
console.log(`No effects found on ${item.name}, no effects copied to actor`);
|
|
||||||
}
|
}
|
||||||
} else if (item.effects.size > 0 && !this.document.system.equipped) {
|
|
||||||
console.log(`Armor ${this.document.name} is not equipped, attachment effects will be applied when equipped`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Armor updated successfully`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -198,7 +180,6 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (effectsToRemove.length > 0) {
|
if (effectsToRemove.length > 0) {
|
||||||
console.log(`Removing ${effectsToRemove.length} effects from actor that came from detached item ${uuid}`);
|
|
||||||
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,6 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
const item = await Item.implementation.fromDropData(data);
|
const item = await Item.implementation.fromDropData(data);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
console.log(`Dropping item ${item.name} (${item.uuid}) onto weapon ${this.document.name}`);
|
|
||||||
|
|
||||||
// Get current attached UUIDs
|
// Get current attached UUIDs
|
||||||
const currentAttached = this.document.system.attached || [];
|
const currentAttached = this.document.system.attached || [];
|
||||||
const newUUID = item.uuid;
|
const newUUID = item.uuid;
|
||||||
|
|
@ -121,11 +119,7 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Current attached items:`, currentAttached);
|
|
||||||
console.log(`Adding new UUID:`, newUUID);
|
|
||||||
|
|
||||||
const updatedAttached = [...currentAttached, newUUID];
|
const updatedAttached = [...currentAttached, newUUID];
|
||||||
console.log(`Updating weapon with attached items:`, updatedAttached);
|
|
||||||
|
|
||||||
await this.document.update({
|
await this.document.update({
|
||||||
'system.attached': updatedAttached
|
'system.attached': updatedAttached
|
||||||
|
|
@ -135,8 +129,6 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
// Both attachment-only and regular effects should be copied when attached
|
// Both attachment-only and regular effects should be copied when attached
|
||||||
const actor = this.document.parent;
|
const actor = this.document.parent;
|
||||||
if (actor && item.effects.size > 0 && this.document.system.equipped) {
|
if (actor && item.effects.size > 0 && this.document.system.equipped) {
|
||||||
console.log(`Checking ${item.effects.size} effects from attached item ${item.name}`);
|
|
||||||
|
|
||||||
const effectsToCreate = [];
|
const effectsToCreate = [];
|
||||||
for (const effect of item.effects) {
|
for (const effect of item.effects) {
|
||||||
// Copy ALL effects when item is attached - attachment-only flag only matters for non-attached items
|
// Copy ALL effects when item is attached - attachment-only flag only matters for non-attached items
|
||||||
|
|
@ -154,22 +146,12 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
effectsToCreate.push(effectData);
|
effectsToCreate.push(effectData);
|
||||||
|
|
||||||
const isAttachmentOnly = effect.flags?.daggerheart?.attachmentOnly === true;
|
|
||||||
console.log(`Effect ${effect.name} (attachment-only: ${isAttachmentOnly}) will be copied to actor`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effectsToCreate.length > 0) {
|
if (effectsToCreate.length > 0) {
|
||||||
const createdEffects = await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate);
|
await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate);
|
||||||
console.log(`Created ${createdEffects.length} effects on actor from attached item`);
|
|
||||||
} else {
|
|
||||||
console.log(`No effects found on ${item.name}, no effects copied to actor`);
|
|
||||||
}
|
}
|
||||||
} else if (item.effects.size > 0 && !this.document.system.equipped) {
|
|
||||||
console.log(`Weapon ${this.document.name} is not equipped, attachment effects will be applied when equipped`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Weapon updated successfully`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -197,7 +179,6 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (effectsToRemove.length > 0) {
|
if (effectsToRemove.length > 0) {
|
||||||
console.log(`Removing ${effectsToRemove.length} effects from actor that came from detached item ${uuid}`);
|
|
||||||
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,6 @@ export default class DHArmor extends BaseDataItem {
|
||||||
|
|
||||||
if (newEquippedStatus) {
|
if (newEquippedStatus) {
|
||||||
// Armor is being equipped - add attachment effects
|
// Armor is being equipped - add attachment effects
|
||||||
console.log(`Armor ${this.parent.name} being equipped, adding attachment effects`);
|
|
||||||
|
|
||||||
const effectsToCreate = [];
|
const effectsToCreate = [];
|
||||||
for (const attachedUuid of this.attached) {
|
for (const attachedUuid of this.attached) {
|
||||||
const attachedItem = await fromUuid(attachedUuid);
|
const attachedItem = await fromUuid(attachedUuid);
|
||||||
|
|
@ -136,12 +134,9 @@ export default class DHArmor extends BaseDataItem {
|
||||||
|
|
||||||
if (effectsToCreate.length > 0) {
|
if (effectsToCreate.length > 0) {
|
||||||
await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate);
|
await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate);
|
||||||
console.log(`Created ${effectsToCreate.length} attachment effects on actor`);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Armor is being unequipped - remove attachment effects
|
// Armor is being unequipped - remove attachment effects
|
||||||
console.log(`Armor ${this.parent.name} being unequipped, removing attachment effects`);
|
|
||||||
|
|
||||||
const effectsToRemove = actor.effects.filter(effect => {
|
const effectsToRemove = actor.effects.filter(effect => {
|
||||||
const attachmentSource = effect.flags?.daggerheart?.attachmentSource;
|
const attachmentSource = effect.flags?.daggerheart?.attachmentSource;
|
||||||
return attachmentSource && attachmentSource.armorUuid === this.parent.uuid;
|
return attachmentSource && attachmentSource.armorUuid === this.parent.uuid;
|
||||||
|
|
@ -149,7 +144,6 @@ export default class DHArmor extends BaseDataItem {
|
||||||
|
|
||||||
if (effectsToRemove.length > 0) {
|
if (effectsToRemove.length > 0) {
|
||||||
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
||||||
console.log(`Removed ${effectsToRemove.length} attachment effects from actor`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,8 +133,6 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
|
|
||||||
if (newEquippedStatus) {
|
if (newEquippedStatus) {
|
||||||
// Weapon is being equipped - add attachment effects
|
// Weapon is being equipped - add attachment effects
|
||||||
console.log(`Weapon ${this.parent.name} being equipped, adding attachment effects`);
|
|
||||||
|
|
||||||
const effectsToCreate = [];
|
const effectsToCreate = [];
|
||||||
for (const attachedUuid of this.attached) {
|
for (const attachedUuid of this.attached) {
|
||||||
const attachedItem = await fromUuid(attachedUuid);
|
const attachedItem = await fromUuid(attachedUuid);
|
||||||
|
|
@ -161,12 +159,9 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
|
|
||||||
if (effectsToCreate.length > 0) {
|
if (effectsToCreate.length > 0) {
|
||||||
await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate);
|
await actor.createEmbeddedDocuments('ActiveEffect', effectsToCreate);
|
||||||
console.log(`Created ${effectsToCreate.length} attachment effects on actor`);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Weapon is being unequipped - remove attachment effects
|
// Weapon is being unequipped - remove attachment effects
|
||||||
console.log(`Weapon ${this.parent.name} being unequipped, removing attachment effects`);
|
|
||||||
|
|
||||||
const effectsToRemove = actor.effects.filter(effect => {
|
const effectsToRemove = actor.effects.filter(effect => {
|
||||||
const attachmentSource = effect.flags?.daggerheart?.attachmentSource;
|
const attachmentSource = effect.flags?.daggerheart?.attachmentSource;
|
||||||
return attachmentSource && attachmentSource.weaponUuid === this.parent.uuid;
|
return attachmentSource && attachmentSource.weaponUuid === this.parent.uuid;
|
||||||
|
|
@ -174,7 +169,6 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
|
|
||||||
if (effectsToRemove.length > 0) {
|
if (effectsToRemove.length > 0) {
|
||||||
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
await actor.deleteEmbeddedDocuments('ActiveEffect', effectsToRemove.map(e => e.id));
|
||||||
console.log(`Removed ${effectsToRemove.length} attachment effects from actor`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,13 @@ export default class DhActiveEffect extends ActiveEffect {
|
||||||
get isAttached() {
|
get isAttached() {
|
||||||
if (!this.parent || !this.parent.parent) return false;
|
if (!this.parent || !this.parent.parent) return false;
|
||||||
|
|
||||||
// Check if this item's UUID is in any actor's armor attachment lists
|
// Check if this item's UUID is in any actor's armor or weapon attachment lists
|
||||||
const actor = this.parent.parent;
|
const actor = this.parent.parent;
|
||||||
if (!actor || !actor.items) return false;
|
if (!actor || !actor.items) return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return actor.items.some(item => {
|
return actor.items.some(item => {
|
||||||
return item.type === 'armor' &&
|
return (item.type === 'armor' || item.type === 'weapon') &&
|
||||||
item.system?.attached &&
|
item.system?.attached &&
|
||||||
Array.isArray(item.system.attached) &&
|
Array.isArray(item.system.attached) &&
|
||||||
item.system.attached.includes(this.parent.uuid);
|
item.system.attached.includes(this.parent.uuid);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue