Buildings hold their own resource stock, and orders queue until supplied #16
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part 3 of #12. Depends on the fleet-cargo ticket.
#12: "anything produced needs resources to be transported" and "if no resources are available, the ship crafting is queued". So a building cannot simply deduct from the global pool at the moment of purchase - it needs a local stock that something has to deliver into.
Today
BuildControllerrefuses outright:GameState.spend(...)fails and it prints "Not enough rocks".Scope
Deliberately not here: how resources get to the building. Until the following tickets land, the queue can be fed by the manual fleet route.
Acceptance
Done in
3573ccf.BuildControllerdeducted the cost from the bank at the moment of purchase and refused outright with "Not enough rocks", so nothing ever had to be delivered anywhere. Each building now carries its ownstock, and an order it cannot pay for yet is QUEUED and completes by itself once ore arrives.Building records gained an
id, because a building has to be referable across the space <-> planet-surface scene swap, when every Building NODE has been destroyed and rebuilt. Position would nearly work and then fail on two buildings placed on the same spot.Production advances in the
GameStateautoload, the same way extractor haulers already do, so an order can complete while the player is down a gravity well. A finished vessel becomesships_owedrather than being handed straight to aFleetthat may not exist, and the fleet claims what it is owed when it next has room.The craft menu had to remember which crafter it was opened for:
_process()clearscurrent_buildingwhile any menu is open, so by the next frame the menu no longer knew. It shows the ore delivered HERE rather than the bank - showing the bank would promise something the crafter cannot actually build.Test
tests/test_building_stock_queue.gd. Four mutations caught: queueing deducting from the bank (the old behaviour), producing on a part-delivery, dropping the completed vessel instead of owing it, and stalling once the space scene is gone.A fifth mutation initially slipped through and is worth recording. The test claimed "one delivery clears all the orders it covers", but changing the
whileto anif- producing one order per frame - still passed, because a 0.4s wall-clock wait gives it plenty of frames to dribble them out. A timed check cannot tell "cleared at once" from "cleared eventually". It now queues three orders and allows two TICKS, so only clearing them together passes, and the mutation fails as it should.Full suite: 44/44.