diff --git a/.gitignore b/.gitignore index 0af63f5..11cbafd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ node_modules .vscode # lint -.eslintcache \ No newline at end of file +.eslintcache + +# Foundry Lock files +system/l5r5e.lock diff --git a/README.md b/README.md index 6d1a1f4..eedad24 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,9 @@ This version is authorized by Edge Studio, all texts, images and copyrights are > https://gitlab.com/teaml5r/l5r5e/-/raw/master/system/system.json ### Recommended modules -- Dice so Nice, for 3D dices : https://gitlab.com/riccisi/foundryvtt-dice-so-nice -- Search Anywhere : https://gitlab.com/riccisi/foundryvtt-search-anywhere (don't spent too much time searching the right technique) +- `Babele` required for non english compendium translation: https://gitlab.com/riccisi/foundryvtt-babele +- `Dice so Nice` for 3D dices : https://gitlab.com/riccisi/foundryvtt-dice-so-nice +- `Search Anywhere` https://gitlab.com/riccisi/foundryvtt-search-anywhere (don't spent too much time searching the right technique) ## Current L5R team (alphabetical order) - Carter (compendiums, adventure adaptation) @@ -54,8 +55,8 @@ La traduction du système fonctionne directement, cependant les compendiums néc > https://gitlab.com/riccisi/foundryvtt-babele ### Modules recommandés -- Dice so Nice, pour avoir des dés 3D : https://gitlab.com/riccisi/foundryvtt-dice-so-nice -- Search Anywhere : https://gitlab.com/riccisi/foundryvtt-search-anywhere (pour ne pas perdre top de temps à chercher une technique) +- `Dice so Nice` pour avoir des dés 3D : https://gitlab.com/riccisi/foundryvtt-dice-so-nice +- `Search Anywhere` pour ne pas perdre top de temps à chercher une technique : https://gitlab.com/riccisi/foundryvtt-search-anywhere ## Nous rejoindre @@ -81,7 +82,7 @@ Vous êtes libre de contribuer et proposer après fork des corrections, modifica 3. Limitez-vous si possible à une Feature par demande de Merge pour ne pas bloquer le processus. -Screens +# Screenshots ![FoundryVTT Connection](https://cdn.discordapp.com/attachments/659430710146498583/798684216551407666/unknown.png) ![FoundryVTT L5r5e Character and Roll](https://cdn.discordapp.com/attachments/659430710146498583/798686668361039882/unknown.png) ![FoundryVTT L5r5e Sheets](https://cdn.discordapp.com/attachments/659430710146498583/798686880974503946/unknown.png) diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index aff2421..f6054f3 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -169,29 +169,30 @@ export class BaseSheetL5r5e extends ActorSheet { // Check item type and subtype let item = await game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event); - if ( - !item || - item.documentName !== "Item" || - ![ - "item", - "armor", - "weapon", - "technique", - "peculiarity", - "advancement", - "title", - "bond", - "signature_scroll", - "item_pattern", - ].includes(item.data.type) - ) { + if (!item || item.documentName !== "Item" || item.data.type === "property") { return; } - // Dropped a item with same "id" as one owned, add qte instead - if (item.data.data.quantity && this.actor.data.items) { - const tmpItem = this.actor.data.items.find((e) => e.name === item.data.name && e.type === item.data.type); - if (tmpItem && this._modifyQuantity(tmpItem.id, 1)) { + // Dropped a item with same "id" as one owned + if (this.actor.data.items) { + if (item.data.data.quantity) { + // Add quantity instead if they have (id is different so use type and name) + const tmpItem = this.actor.data.items.find( + (embedItem) => embedItem.name === item.data.name && embedItem.type === item.data.type + ); + if (tmpItem && this._modifyQuantity(tmpItem.id, 1)) { + return; + } + } else if ( + this.actor.data.items.some((embedItem) => { + // Search in children + if (embedItem.items?.has(item.data._id)) { + return true; + } + return embedItem.data._id === item.data._id; + }) + ) { + // Exit if we already owned exactly this id (drag a personal item on our own sheet) return; } } @@ -219,6 +220,9 @@ export class BaseSheetL5r5e extends ActorSheet { break; case "title": + // Generate new Ids for the embed items + await item.generateNewIdsForAllEmbedItems(); + // Add embed advancements bonus for (let [embedId, embedItem] of item.data.data.items) { if (embedItem.data.type === "advancement") { @@ -231,10 +235,11 @@ export class BaseSheetL5r5e extends ActorSheet { // School_ability and mastery_ability, allow only 1 per type if (CONFIG.l5r5e.techniques.get(item.data.data.technique_type)?.type === "school") { if ( - Array.from(this.actor.items).some( - (e) => + Array.from(this.actor.items).some((e) => { + return ( e.type === "technique" && e.data.data.technique_type === item.data.data.technique_type - ) + ); + }) ) { ui.notifications.info(game.i18n.localize("l5r5e.techniques.only_one")); return; diff --git a/system/scripts/item.js b/system/scripts/item.js index 6931c26..3bedee6 100644 --- a/system/scripts/item.js +++ b/system/scripts/item.js @@ -207,6 +207,23 @@ export class ItemL5r5e extends Item { } } + /** + * Generate new Ids for the embed items + * @return {Promise} + */ + async generateNewIdsForAllEmbedItems() { + // Clear olds ids + const oldItems = Array.from(this.data.data.items); + this.data.data.items = new Map(); + + // Re-add with new ids + oldItems.forEach(([id, item]) => { + this.addEmbedItem(item, { save: false, newId: true, addBonusToActor: false }); + }); + + return this.saveEmbedItems(); + } + /** * Save all the Embed Items * @return {Promise} diff --git a/system/system.json b/system/system.json index 8302445..cc2a426 100644 --- a/system/system.json +++ b/system/system.json @@ -7,7 +7,7 @@ "download": "https://gitlab.com/teaml5r/l5r5e/-/jobs/artifacts/v1.3.0/raw/l5r5e.zip?job=build", "version": "1.3.0", "minimumCoreVersion": "0.8.5", - "compatibleCoreVersion": "0.8.5", + "compatibleCoreVersion": "0.8.6", "manifestPlusVersion": "1.0.0", "socket": true, "author": "Team L5R",