Sell all buildings in a single turn

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
jpsm
Veteran
Posts: 97
Joined: Sun Nov 01, 2020 8:14 pm

Sell all buildings in a single turn

Post 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.
Wahazar
Elite
Posts: 362
Joined: Mon Jul 02, 2018 1:49 pm

Re: Sell all buildings in a single turn

Post by Wahazar »

It is disabled to sell all buildings in 1 turn due to obvious reasons - attacking player should get some loot.
Augmented2 ruleset/modpack for freeciv2.6: http://forum.freeciv.org/f/viewtopic.php?f=11&t=91047
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Sell all buildings in a single turn

Post by Ignatus »

We can attach a script that provides a player with all the cost of the buildings of a disbanded city.
jpsm
Veteran
Posts: 97
Joined: Sun Nov 01, 2020 8:14 pm

Re: Sell all buildings in a single turn

Post 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!
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Sell all buildings in a single turn

Post 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")
Post Reply