Page 1 of 1

Sell all buildings in a single turn

Posted: Thu Nov 26, 2020 11:29 am
by jpsm
Now you can only sell one building/city improvement per turn. Sometimes you want to disband the city if the city is not viable but sell the city improvements before disband to not lose the value of the buildings. Sell all city improvements in a single turn would make it easier and faster.

Re: Sell all buildings in a single turn

Posted: Thu Nov 26, 2020 12:49 pm
by Wahazar
It is disabled to sell all buildings in 1 turn due to obvious reasons - attacking player should get some loot.

Re: Sell all buildings in a single turn

Posted: Thu Nov 26, 2020 1:53 pm
by Ignatus
We can attach a script that provides a player with all the cost of the buildings of a disbanded city.

Re: Sell all buildings in a single turn

Posted: Thu Nov 26, 2020 7:17 pm
by jpsm
Ignatus wrote:We can attach a script that provides a player with all the cost of the buildings of a disbanded city.
Excellent idea!

Re: Sell all buildings in a single turn

Posted: Sun Dec 13, 2020 9:08 pm
by Ignatus
Something like this (not tested), put in your_ruleset_dir/script.lua (don't apply to a pre-installed ruleset, make a copy to play with it):

Code: Select all

--Destroying city by a non-military action, return buildings cost to the owner
function sell_city_buildings(c,owner,oplayer)
if not oplayer then
 local cost = 0;
 for b in buildings_iterate() do
  if c:has_building(b) and not b:is_wonder() then
   cost = cost + b.build_cost -- * game.info.shieldbox / 100 and rounded if needed
  end
 end
 if c > 0 then
  owner:change_gold(cost)
  notify.event(owner, c.tile, E.IMP_SOLD, _("Improvements of %s sold for %d gold"), c.name, gold)
 end
end
signal.connect("city_destroyed", "sell_city_buildings")