diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index 3f7ee1110..7625f9b0f 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -156,7 +156,7 @@ public class LoadoutGenerator { var instance = ItemManager.CreateInstance(entry.product); var cells = entry.design.Shape.Coordinates.Length; - if (cells > StationServices.StockRoom(entity)) continue; + if (cells > StationServices.GearCellsLeft(entity)) continue; stockBays.Any(bay => bay.TryStore(instance)); } diff --git a/Assets/Scripts/ServerShared/StationServices.cs b/Assets/Scripts/ServerShared/StationServices.cs index f8e81361e..9465f4f01 100644 --- a/Assets/Scripts/ServerShared/StationServices.cs +++ b/Assets/Scripts/ServerShared/StationServices.cs @@ -110,7 +110,7 @@ public static class StationServices if (item is ICommodityStack) throw new ArgumentException("A commodity stack sells through TrySellPart, which says how many units sold.", nameof(item)); var price = SellPrice(station.ItemManager, item); - if (station.ItemManager.GetData(item).Shape.Coordinates.Length > StockRoom(station)) return false; + if (station.ItemManager.GetData(item).Shape.Coordinates.Length > GearCellsLeft(station)) return false; if (!station.CargoBays.Any(bay => from.TryTransferItem(bay, item, 1))) return false; credits += price; return true; @@ -118,7 +118,7 @@ public static class StationServices // The cells of gear the Stock bays may still take: StationStockShare of their cells together, less the cells occupied, generated // and pawned gear alike (ruling pawn-stock-in-stock-bay-share). Role bays refuse gear, so the Stock bays are the only bays gear lands in. - public static int StockRoom(Entity station) + public static int GearCellsLeft(Entity station) { var bays = StationWants.RoleBays(station, BayRole.Stock).ToArray(); var cap = (int) (bays.Sum(bay => bay.Data.InteriorShape.Coordinates.Length) * LoadoutGenerator.StationStockShare); diff --git a/tests/Aetheria.Shared.Tests/StationServicesTests.cs b/tests/Aetheria.Shared.Tests/StationServicesTests.cs index bee471ad1..df3ddff91 100644 --- a/tests/Aetheria.Shared.Tests/StationServicesTests.cs +++ b/tests/Aetheria.Shared.Tests/StationServicesTests.cs @@ -195,7 +195,7 @@ public sealed class StationServicesTests : IDisposable Assert.Equal(5, pawned); Assert.Equal(5 * StationServices.SellPrice(_items, Mint("Gun")), credits); - Assert.Equal(0, StationServices.StockRoom(station)); + Assert.Equal(0, StationServices.GearCellsLeft(station)); Assert.Equal(8, stock.Occupancy.Cast().Count(held => held != null)); Assert.Contains(held[pawned], from.Cargo.Keys); } @@ -253,7 +253,7 @@ public sealed class StationServicesTests : IDisposable var others = StationWants.RoleBays(station, BayRole.Stock).Skip(1).ToArray(); while (full.TryStore(Mint("Gun"))) { } // Three Crates, 48 cells: the stock share is 24, and the full bay spends 16 of it, so the sale lands in another Crate. - Assert.Equal(8, StationServices.StockRoom(station)); + Assert.Equal(8, StationServices.GearCellsLeft(station)); var credits = 0; Assert.True(StationServices.TrySell(from, station, gun, ref credits));