Skip to content

Commit

Permalink
Resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
nexus4880 committed Jan 28, 2025
1 parent 5da3fa5 commit 150b330
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 38 deletions.
6 changes: 4 additions & 2 deletions Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Fuyu.Backend.BSG.Models.Items;
using Fuyu.Backend.BSG.Services;
using Fuyu.Common.Hashing;
using Fuyu.Common.IO;

namespace Fuyu.Backend.BSG.Models.Profiles;

Expand Down Expand Up @@ -45,9 +46,10 @@ private void OnDeserialized(StreamingContext _)
{
item.InitializeMatrices(props.Grids, items);
}
catch (Exception)
catch (Exception ex)
{
// ignored, this fails on bot gifter (and maybe others)
// this fails on bot gifter (and maybe others)
Terminal.WriteLine($"Failed to initialize matrices: {ex}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,41 +129,7 @@ public override Task RunAsync(EftHttpContext context, RagfairFindRequest body)

if (body.ConditionFrom > 0 || body.ConditionTo < 100)
{
selectedOffers.RemoveAll(o =>
{
var repairable = o.RootItem.Updatable.Repairable;

if (repairable != null)
{
var percentage = repairable.Durability / repairable.MaxDurability * 100f;

if (percentage > body.ConditionTo || percentage < body.ConditionFrom)
{
return true;
}
}

var repairKit = o.RootItem.Updatable.RepairKit;

if (repairKit != null)
{
var properties = _itemFactoryService.GetItemProperties<RepairKitsItemProperties>(o.RootItem.TemplateId);

if (properties == null)
{
return true;
}

var percentage = repairKit.Resource / properties.MaxRepairResource * 100f;

if (percentage > body.ConditionTo || percentage < body.ConditionFrom)
{
return true;
}
}

return false;
});
selectedOffers.RemoveAll(o => !MeetsConditions(o, body.ConditionTo, body.ConditionFrom));
}

if (body.PriceFrom > 0)
Expand Down Expand Up @@ -341,4 +307,40 @@ private List<Offer> RequiredSearch(HandbookTemplates handbook, MongoId neededSea

return result;
}

private bool MeetsConditions(Offer offer, int conditionFrom, int conditionTo)
{
var repairable = offer.RootItem.Updatable.Repairable;

if (repairable != null)
{
var percentage = repairable.Durability / repairable.MaxDurability * 100f;

if (percentage > conditionTo || percentage < conditionFrom)
{
return false;
}
}

var repairKit = offer.RootItem.Updatable.RepairKit;

if (repairKit != null)
{
var properties = _itemFactoryService.GetItemProperties<RepairKitsItemProperties>(offer.RootItem.TemplateId);

if (properties == null)
{
return false;
}

var percentage = repairKit.Resource / properties.MaxRepairResource * 100f;

if (percentage > conditionTo || percentage < conditionFrom)
{
return false;
}
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void UtilizeSameMatrix(EftProfile profile, ApplyInventoryChangesEvent re
{
var itemAndChildren = profile.Pmc.Inventory.GetItemAndChildren(ItemService.Instance, changedItem);

// Store sorted Location (MUST BE A VALUE1)
// Store sorted Location (MUST BE AN UNION.VALUE1)
var previousLocation = changedItem.Location.Value1;

// Free all items previous positions
Expand Down

0 comments on commit 150b330

Please sign in to comment.