Swap goods between two towns only if both can pay and both have room
A trade offer between two players can fail in four ways: one is short of goods, the other has a full storehouse, both at once, or the trade quietly changes only one side. This entry checks both sides first, completes the swap in one piece, and lists every reason when it says no.
Why this works
A trade is one act between two people, so either both sides change or neither does. Checking both sides fully before changing anything, and counting what each gives away before asking about room, avoids a swap that quietly helps one side only.
When not to use it
Skip it when one side gives a gift and the other needs nothing in return, or when trades are spread out over time, such as a caravan that delivers later. Then record a promise and settle each leg on arrival.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- 30 lines of example code with 3 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Swap goods between two towns only if both can pay and both have room" (read_entry atomic-swap-between-two-towns) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP