private void CalculateNextTurn() { if (doingTurn) { return; } ResourcesStorage.Reset(); foreach (ResourceDelta delta in upkeepDeltas) { ResourcesStorage.AddDelta(delta); } var rocket = new Rocket(); // TODO this needs to stick around, really, if only so that the rocket contents can be communicated to the player // Upkeep gets dibs on rocket capacity. EnsureUpkeepIsMet(rocket); // Fill any remaining space with materials for however many projects we can complete this turn. TryCompleteProjects(rocket); // TODO fill the rest of the rocket's capacity with some player-configurable default resource. // TODO or, possibly, include some subset of the resources for the next project, if any. OnChanged?.Invoke(); }
public void HappyCase() { var storages = new ResourcesStorage(); storages.AddDelta(new ResourceDelta(ResourceType.Air, 20)); storages.AddDelta(new ResourceDelta(ResourceType.Food, -20)); Assert.AreEqual(20, storages.NextAmount(ResourceType.Air)); Assert.AreEqual(-20, storages.NextAmount(ResourceType.Food)); storages.Tick(); Assert.AreEqual(20, storages.NextAmount(ResourceType.Air)); Assert.AreEqual(20, storages.ResourceStorages[ResourceType.Air].CurrentAmount); }
public void TestUpkeep() { var station = new Station(); ResourcesStorage storage = station.ResourcesStorage; storage.AddDelta(new ResourceDelta(ResourceType.Air, 20)); station.DoTurn(); station.AddUpkeepDelta(new ResourceDelta(ResourceType.Air, -10)); // upkeep depletes stored resource first Assert.AreEqual(10, storage.NextAmount(ResourceType.Air)); station.DoTurn(); Assert.AreEqual(0, storage.NextAmount(ResourceType.Air)); // and will launch resources via the rocket instead of going negative station.DoTurn(); Assert.AreEqual(0, storage.NextAmount(ResourceType.Air)); }