Index: binaries/data/mods/public/simulation/components/Barter.js =================================================================== --- binaries/data/mods/public/simulation/components/Barter.js +++ binaries/data/mods/public/simulation/components/Barter.js @@ -94,7 +94,7 @@ { var amountToAdd = Math.round(prices["sell"][resourceToSell] / prices["buy"][resourceToBuy] * amount); cmpPlayer.AddResource(resourceToBuy, amountToAdd); - var numberOfDeals = Math.round(amount / 100); + var numberOfDeals = Math.ceil(amount / 100); // Display chat message to observers var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); Index: binaries/data/mods/public/simulation/components/tests/test_Barter.js =================================================================== --- binaries/data/mods/public/simulation/components/tests/test_Barter.js +++ binaries/data/mods/public/simulation/components/tests/test_Barter.js @@ -94,12 +94,12 @@ TS_ASSERT_EQUALS(sold, 100); TS_ASSERT_EQUALS(bought, Math.round(100 * (100 - cmpBarter.CONSTANT_DIFFERENCE + 0) / (100 + cmpBarter.CONSTANT_DIFFERENCE + 0))); -// With an amount which is not a multiple of 100, price differences are not updated. That sounds wrong. +// If the amount is not a multiple of 100. cmpBarter.priceDifferences = { "wood": 0, "stone": 0, "metal": 0 }; cmpBarter.ExchangeResources(11, "wood", "stone", 40); TS_ASSERT_EQUALS(cmpBarter.restoreTimer, 7); TS_ASSERT(timerActivated); -TS_ASSERT_UNEVAL_EQUALS(cmpBarter.priceDifferences, { "wood": 0, "stone": 0, "metal": 0 }); +TS_ASSERT_UNEVAL_EQUALS(cmpBarter.priceDifferences, { "wood": -cmpBarter.DIFFERENCE_PER_DEAL, "stone": cmpBarter.DIFFERENCE_PER_DEAL, "metal": 0 }); TS_ASSERT_EQUALS(sold, 40); TS_ASSERT_EQUALS(bought, Math.round(40 * (100 - cmpBarter.CONSTANT_DIFFERENCE + 0) / (100 + cmpBarter.CONSTANT_DIFFERENCE + 0)));