-Item embed items generate new ids on drop in actor
-Ignore the drop of already owned item in same sheet
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,3 +7,6 @@ node_modules
|
||||
|
||||
# lint
|
||||
.eslintcache
|
||||
|
||||
# Foundry Lock files
|
||||
system/l5r5e.lock
|
||||
|
||||
11
README.md
11
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
|
||||

|
||||

|
||||

|
||||
|
||||
@@ -169,31 +169,32 @@ 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);
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Item subtype specific
|
||||
@@ -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;
|
||||
|
||||
@@ -207,6 +207,23 @@ export class ItemL5r5e extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate new Ids for the embed items
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
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<void>}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user