--[[nef_20221122 UPKEEP_script This script will list cities together with the nett upkeep costs assuming Civ I despotism government. It runs directly when loaded. Requires FEATURED_TEXT and SUPPORT_basic. ]] do -- UPKEEP_script -- SOH local featured = setmetatable({},{ -- FEATURED_TEXT __index = function(t,k) local ft = log.featured return assert(ft and ft[k], 'Featured text not loaded.' ) end;}) local function bbcode(...) bbcode = featured.bbcode; return bbcode (...) end local SP = setmetatable({},{ -- SUPPORT_basic __index = function(t,k) local SP = game.SP return assert(SP and SP[k], 'Support package not loaded.') end;}) local function user (...) user = SP.user; return user (...) end local function colored_link(...) colored_link = SP.colored_link; return colored_link(...) end -- STX local report = function(tile,...) if chat then chat.msg(...) log.normal(...) else notify.event(user(),tile,E.BROADCAST_REPORT,...) end end local home = setmetatable( {},{__call=function(t,k) if k then t[k]=t[k]+1 end end;} ) local function comp (c1, c2) return home[c1] > home[c2] end local nuk = {["Caravan"] = true, ["Diplomat"] = true} local MF = math.floor local cities, c = {}, 0 for city in (user()):cities_iterate() do home[city] = - MF(city.size); c= c+1; cities[c] = city end for unit in (user()):units_iterate() do home(not nuk[unit.utype:rule_name()] and unit:get_homecity()) end table.sort(cities, comp) local function p_report(...); p_report = report; p_report(nil, bbcode ("b","Unit upkeep costs")); p_report(...) end for c, city in ipairs(cities) do p_report(city.tile, "%3s".. (city:is_happy() and "+" or city:is_celebrating() and "*" or city:is_unhappy() and "-" or " ").. colored_link(city," "..city.name..(city:is_capital() and "* " or " ")), home[city], nil) end; if p_report ~= report then report(nil, "No cities") end --ETX end -- end UPKEEP_script