From e56bc2ec6293049a09fbdb5a41fc0d1ebc3223fc Mon Sep 17 00:00:00 2001 From: Matt Dunn-Rankin Date: Sat, 25 Apr 2020 22:12:05 -0700 Subject: [PATCH] improve conflict detection w restricted zones --- src/useOutfitState.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/useOutfitState.js b/src/useOutfitState.js index ef1a081..eea011f 100644 --- a/src/useOutfitState.js +++ b/src/useOutfitState.js @@ -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)