@@ -42,25 +42,30 @@ async function prepareData(context, sheet) {
4242
4343/**
4444 * @description Helper function to find the appropriate update configuration
45+ * @param {FUActor } sourceActor
4546 * @param type
4647 * @param subtype
4748 * @returns {{types: string[], subtypes: string[], update: ((function(*, *): Promise<void>)|*)} | {types: string[], update: ((function(*): Promise<void>)|*)} }
4849 */
49- function findItemConfig ( type , subtype ) {
50+ function findItemConfig ( sourceActor , type , subtype ) {
5051 const itemTypeConfigs = [
5152 {
5253 types : [ 'treasure' ] ,
5354 subtypes : [ 'artifact' , 'material' , 'treasure' ] ,
5455 update : async ( itemData , item ) => {
56+ // Do not duplicate if on self
57+ if ( item . parent === sourceActor ) {
58+ return ;
59+ }
5560 const incrementValue = itemData . system . quantity ?. value || 1 ;
5661 const newQuantity = ( item . system . quantity . value || 0 ) + incrementValue ;
5762 await item . update ( { 'system.quantity.value' : newQuantity } ) ;
5863 } ,
5964 } ,
6065 {
66+ // Effects are handled separately
6167 types : [ 'effect' ] ,
6268 update : async ( itemData ) => {
63- // Effects are handled separately
6469 return ;
6570 } ,
6671 } ,
@@ -279,7 +284,7 @@ async function handleStashDrop(actor, item) {
279284 const existingItem = actor . items . find ( ( i ) => i . name === item . name && i . type === item . type ) ;
280285 if ( existingItem ) {
281286 const subtype = item . system . subtype ?. value ;
282- const config = findItemConfig ( item . type , subtype ) ;
287+ const config = findItemConfig ( actor , item . type , subtype ) ;
283288 if ( config ) {
284289 await config . update ( item , existingItem ) ;
285290 console . debug ( `${ item . name } was appended onto ${ actor . name } ` ) ;
0 commit comments