improve conflict detection w restricted zones

This commit is contained in:
Matt Dunn-Rankin 2020-04-25 22:12:05 -07:00
parent 1ca61215be
commit e56bc2ec62

View file

@ -194,6 +194,10 @@ function findItemConflicts(itemIdToAdd, state, apolloClient) {
id
}
}
restrictedZones {
id
}
}
}
}
@ -208,7 +212,10 @@ function findItemConflicts(itemIdToAdd, state, apolloClient) {
if (!itemToAdd.appearanceOn) {
return [];
}
const itemToAddZoneIds = itemToAdd.appearanceOn.layers.map((l) => l.zone.id);
const itemToAddZoneIds = [
...itemToAdd.appearanceOn.layers.map((l) => l.zone.id),
...itemToAdd.appearanceOn.restrictedZones.map((z) => z.id),
];
const wornItems = Array.from(wornItemIds).map((id) =>
items.find((i) => i.id === id)
);
@ -218,7 +225,10 @@ function findItemConflicts(itemIdToAdd, state, apolloClient) {
if (!wornItem.appearanceOn) {
continue;
}
const wornItemZoneIds = wornItem.appearanceOn.layers.map((l) => l.zone.id);
const wornItemZoneIds = [
...wornItem.appearanceOn.layers.map((l) => l.zone.id),
...wornItem.appearanceOn.restrictedZones.map((z) => z.id),
];
const hasConflict = wornItemZoneIds.some((zid) =>
itemToAddZoneIds.includes(zid)