fix ShopStorage.Sell
This commit is contained in:
parent
b81bb26b41
commit
81b4335193
@ -87,15 +87,16 @@ namespace AutoWorkshopFileImplement.Implements
|
||||
if (Model == null || !Model.RepairId.HasValue || !Model.Count.HasValue)
|
||||
return false;
|
||||
|
||||
int RemainingSpace = _source.Shops
|
||||
int TotalRepairsNum = _source.Shops
|
||||
.Select(x => x.Repairs.ContainsKey(Model.RepairId.Value) ? x.Repairs[Model.RepairId.Value] : 0)
|
||||
.Sum();
|
||||
if (RemainingSpace < Model.Count)
|
||||
if (TotalRepairsNum < Model.Count)
|
||||
return false;
|
||||
|
||||
var ShopsWithDesiredRepair = _source.Shops
|
||||
.Where(x => x.Repairs.ContainsKey(Model.RepairId.Value))
|
||||
.OrderByDescending(x => x.Repairs[Model.RepairId.Value]).ToList();
|
||||
.OrderByDescending(x => x.Repairs[Model.RepairId.Value])
|
||||
.ToList();
|
||||
|
||||
foreach (var Shop in ShopsWithDesiredRepair)
|
||||
{
|
||||
@ -128,7 +129,13 @@ namespace AutoWorkshopFileImplement.Implements
|
||||
|
||||
public bool RestockingShops(SupplyBindingModel Model)
|
||||
{
|
||||
if (Model == null || _source.Shops.Select(x => x.RepairsMaxCount - x.ShopRepairs.Select(y => y.Value.Item2).Sum()).Sum() < Model.Count)
|
||||
int TotalFreeSpaceNum = _source.Shops
|
||||
.Select(x => x.RepairsMaxCount - x.ShopRepairs
|
||||
.Select(y => y.Value.Item2)
|
||||
.Sum())
|
||||
.Sum();
|
||||
|
||||
if (TotalFreeSpaceNum < Model.Count)
|
||||
return false;
|
||||
|
||||
foreach (Shop Shop in _source.Shops)
|
||||
@ -137,7 +144,7 @@ namespace AutoWorkshopFileImplement.Implements
|
||||
|
||||
if (FreeSpaceNum <= 0)
|
||||
continue;
|
||||
|
||||
|
||||
FreeSpaceNum = Math.Min(FreeSpaceNum, Model.Count);
|
||||
Model.Count -= FreeSpaceNum;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user