BUG: More C.Inventory fixups

This commit is contained in:
bananarama92 2025-03-27 18:22:00 +01:00
parent 36d5bb532f
commit 29ce9ec031
No known key found for this signature in database
GPG key ID: E83C7D3B5DA36248
2 changed files with 24 additions and 22 deletions
BondageClub
Screens/Inventory/ItemMisc/HighSecurityPadlock
Scripts

View file

@ -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;
}

View file

@ -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;