1 -- Freeciv - Copyright (C) 2007 - The Freeciv Project
2 -- This program is free software; you can redistribute it and/or modify
3 -- it under the terms of the GNU General Public License as published by
4 -- the Free Software Foundation; either version 2, or (at your option)
7 -- This program is distributed in the hope that it will be useful,
8 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
9 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 -- GNU General Public License for more details.
12 -- This file is for lua-functionality that is specific to a given
13 -- ruleset. When freeciv loads a ruleset, it also loads script
14 -- file called 'default.lua'. The one loaded if your ruleset
15 -- does not provide an override is default/default.lua.
18 -- Place Ruins at the location of the destroyed city.
19 function city_destroyed_callback(city
, loser
, destroyer
)
20 city
.tile
:create_extra("Ruins", NIL
)
21 -- continue processing
25 signal
.connect("city_destroyed", "city_destroyed_callback")
27 -- Add random labels to the map.
28 function place_map_labels()
33 local selected_mountain
= 0
34 local selected_ocean
= 0
35 local selected_desert
= 0
36 local selected_glacier
= 0
38 -- Count the tiles that has a terrain type that may get a label.
39 for place
in whole_map_iterate() do
40 local terr
= place
.terrain
41 local tname
= terr
:rule_name()
42 if tname
== "Mountains" then
43 mountains
= mountains
+ 1
44 elseif tname
== "Deep Ocean" then
45 deep_oceans
= deep_oceans
+ 1
46 elseif tname
== "Desert" then
48 elseif tname
== "Glacier" then
49 glaciers
= glaciers
+ 1
53 -- Decide if a label should be included and, in case it should, where.
54 if random(1, 100) <= 75 then
55 selected_mountain
= random(1, mountains
)
57 if random(1, 100) <= 75 then
58 selected_ocean
= random(1, deep_oceans
)
60 if random(1, 100) <= 75 then
61 selected_desert
= random(1, deserts
)
63 if random(1, 100) <= 75 then
64 selected_glacier
= random(1, glaciers
)
67 -- Place the included labels at the location determined above.
68 for place
in whole_map_iterate() do
69 local terr
= place
.terrain
70 local tname
= terr
:rule_name()
72 if tname
== "Mountains" then
73 selected_mountain
= selected_mountain
- 1
74 if selected_mountain
== 0 then
75 place
:set_label(_("Highest Peak"))
77 elseif tname
== "Deep Ocean" then
78 selected_ocean
= selected_ocean
- 1
79 if selected_ocean
== 0 then
80 place
:set_label(_("Deep Trench"))
82 elseif tname
== "Desert" then
83 selected_desert
= selected_desert
- 1
84 if selected_desert
== 0 then
85 place
:set_label(_("Scorched Spot"))
87 elseif tname
== "Glacier" then
88 selected_glacier
= selected_glacier
- 1
89 if selected_glacier
== 0 then
90 place
:set_label(_("Frozen Lake"))
98 signal
.connect("map_generated", "place_map_labels")