Fix price calculation of stacks (#12645)
* stackprice is not compatible with static price * adjust prices * more price adjust * staticprice = 0 * add a test
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Cargo.Systems;
|
||||
using Content.Shared.Cargo.Prototypes;
|
||||
using NUnit.Framework;
|
||||
@@ -41,4 +43,43 @@ public sealed class CargoTest
|
||||
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task NoStaticPriceAndStackPrice()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var entManager = server.ResolveDependency<IEntityManager>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
var grid = mapManager.CreateGrid(mapId);
|
||||
var coord = new EntityCoordinates(grid.GridEntityId, 0, 0);
|
||||
|
||||
var protoIds = protoManager.EnumeratePrototypes<EntityPrototype>()
|
||||
.Where(p=>!p.Abstract)
|
||||
.Select(p => p.ID)
|
||||
.ToList();
|
||||
|
||||
foreach (var proto in protoIds)
|
||||
{
|
||||
var ent = entManager.SpawnEntity(proto, coord);
|
||||
|
||||
if (entManager.TryGetComponent<StackPriceComponent>(ent, out var stackpricecomp)
|
||||
&& stackpricecomp.Price > 0)
|
||||
{
|
||||
if (entManager.TryGetComponent<StaticPriceComponent>(ent, out var staticpricecomp))
|
||||
Assert.That(staticpricecomp.Price, Is.EqualTo(0),
|
||||
$"The prototype {proto} have a StackPriceComponent and StaticPriceComponent whose values are not compatible with each other.");
|
||||
}
|
||||
entManager.DeleteEntity(ent);
|
||||
}
|
||||
mapManager.DeleteMap(mapId);
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
sprite: Objects/Tools/cable-coils.rsi
|
||||
state: coillv-30
|
||||
product: CrateEngineeringCableLV
|
||||
cost: 300
|
||||
cost: 600
|
||||
category: Engineering
|
||||
group: market
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
sprite: Objects/Tools/cable-coils.rsi
|
||||
state: coilmv-30
|
||||
product: CrateEngineeringCableMV
|
||||
cost: 300
|
||||
cost: 600
|
||||
category: Engineering
|
||||
group: market
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
sprite: Objects/Tools/cable-coils.rsi
|
||||
state: coilhv-30
|
||||
product: CrateEngineeringCableHV
|
||||
cost: 300
|
||||
cost: 600
|
||||
category: Engineering
|
||||
group: market
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
sprite: Objects/Tools/cable-coils.rsi
|
||||
state: coilall-30
|
||||
product: CrateEngineeringCableBulk
|
||||
cost: 500
|
||||
cost: 1200
|
||||
category: Engineering
|
||||
group: market
|
||||
|
||||
@@ -66,4 +66,4 @@
|
||||
product: CrateEngineeringMiniJetpack
|
||||
cost: 750
|
||||
category: Engineering
|
||||
group: market
|
||||
group: market
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
- type: Stack
|
||||
count: 20
|
||||
stackType: Telecrystal
|
||||
- type: StaticPrice
|
||||
price: 0
|
||||
- type: StackPrice
|
||||
price: 200
|
||||
- type: Currency
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
sprite: Objects/Tools/cable-coils.rsi
|
||||
- type: CablePlacer
|
||||
- type: Clickable
|
||||
- type: StaticPrice
|
||||
price: 0
|
||||
- type: StackPrice
|
||||
price: 0.5
|
||||
price: 5
|
||||
|
||||
- type: entity
|
||||
id: CableHVStack
|
||||
|
||||
Reference in New Issue
Block a user