diff --git a/BondageClub/Screens/Inventory/ItemMisc/HighSecurityPadlock/HighSecurityPadlock.js b/BondageClub/Screens/Inventory/ItemMisc/HighSecurityPadlock/HighSecurityPadlock.js index 0755210710..397a3e2c77 100644 --- a/BondageClub/Screens/Inventory/ItemMisc/HighSecurityPadlock/HighSecurityPadlock.js +++ b/BondageClub/Screens/Inventory/ItemMisc/HighSecurityPadlock/HighSecurityPadlock.js @@ -56,16 +56,19 @@ function InventoryItemMiscHighSecurityPadlockPlayerHasKeys(C, Item) { if (LogQuery("KeyDeposit", "Cell")) return false; let UnlockName = "Unlock" + Item.Asset.Name; if ((Item != null) && (Item.Property != null) && (Item.Property.LockedBy != null)) UnlockName = "Unlock" + Item.Property.LockedBy; - for (let I = 0; I < Player.Inventory.length; I++) - if (InventoryItemHasEffect(Player.Inventory[I], /** @type {EffectName} */ (UnlockName))) { - var Lock = InventoryGetLock(Item); - if (Lock != null) { - if (Lock.Asset.LoverOnly && !C.IsLoverOfPlayer()) return false; - if (Lock.Asset.OwnerOnly && !C.IsOwnedByPlayer()) return false; - if (Lock.Asset.FamilyOnly && !C.IsFamilyOfPlayer()) return false; - return true; - } else return true; + + const key = Asset.find(a => InventoryItemHasEffect({ Asset: a }, /** @type {EffectName} */ (UnlockName))); + if (key && InventoryAvailable(Player, key.Name, key.Group.Name)) { + var Lock = InventoryGetLock(Item); + if (Lock != null) { + if (Lock.Asset.LoverOnly && !C.IsLoverOfPlayer()) return false; + if (Lock.Asset.OwnerOnly && !C.IsOwnedByPlayer()) return false; + if (Lock.Asset.FamilyOnly && !C.IsFamilyOfPlayer()) return false; + return true; + } else { + return true; } + } return true; } diff --git a/BondageClub/Scripts/Dialog.js b/BondageClub/Scripts/Dialog.js index 6b3cbb3eef..8baf8ca1df 100644 --- a/BondageClub/Scripts/Dialog.js +++ b/BondageClub/Scripts/Dialog.js @@ -682,15 +682,18 @@ function DialogHasKey(C, Item) { let UnlockName = /** @type {EffectName} */("Unlock" + Item.Asset.Name); if ((Item.Property != null) && (Item.Property.LockedBy != null)) UnlockName = /** @type {EffectName} */("Unlock" + Item.Property.LockedBy); - for (let I = 0; I < Player.Inventory.length; I++) - if (InventoryItemHasEffect(Player.Inventory[I], UnlockName)) { - if (lock != null) { - if (lock.Asset.LoverOnly && !C.IsLoverOfPlayer()) return false; - if (lock.Asset.OwnerOnly && !C.IsOwnedByPlayer()) return false; - if (lock.Asset.FamilyOnly && !C.IsFamilyOfPlayer()) return false; - return true; - } else return true; + + const key = Asset.find(a => InventoryItemHasEffect({ Asset: a }, UnlockName)); + if (key && InventoryAvailable(Player, key.Name, key.Group.Name)) { + if (lock != null) { + if (lock.Asset.LoverOnly && !C.IsLoverOfPlayer()) return false; + if (lock.Asset.OwnerOnly && !C.IsOwnedByPlayer()) return false; + if (lock.Asset.FamilyOnly && !C.IsFamilyOfPlayer()) return false; + return true; + } else { + return true; } + } return false; } @@ -1612,11 +1615,7 @@ function DialogInventoryBuild(C, resetOffset=false, locks=false, reload=true) { if (C.FocusGroup == null) return; if (locks) { - for (const item of Player.Inventory) { - if (item.Asset != null && item.Asset.IsLock) { - DialogInventoryAdd(C, item, false); - } - } + Asset.filter(a => a.IsLock && InventoryAvailable(Player, a.Name, a.Group.Name)).forEach(a => DialogInventoryAdd(C, { Asset: a }, false)); DialogInventoryOffset = Math.max(0, Math.min(DialogInventory.length, DialogInventoryOffset)); DialogInventorySort(); return;