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