Toni Förster has proposed merging
lp:~widelands-dev/widelands/territorial_unify_notifications into lp:widelands
with lp:~widelands-dev/widelands/collectors_notification as a prerequisite.
Commit message:
- Notifications for Territorial are unified.
- Notifications are properly formatted (hour and minute)
- remaining time notifications and winning/losing status
notifications are not mixed up any more
- new string added to territorial_lord
- string removed from territorial_time
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/territorial_unify_notifications/+merge/362502
Further details are here: https://wl.widelands.org/forum/post/26905/
--
Your team Widelands Developers is requested to review the proposed merge of
lp:~widelands-dev/widelands/territorial_unify_notifications into lp:widelands.
=== modified file 'data/scripting/win_conditions/collectors.lua'
--- data/scripting/win_conditions/collectors.lua 2019-01-30 23:12:08 +
+++ data/scripting/win_conditions/collectors.lua 2019-01-30 23:12:09 +
@@ -170,7 +170,7 @@
.. h2(ngettext("Team Total: %i point", "Team Total: %i points", points)):format(points)
msg = msg .. vspace(8) .. message
end
-
+
broadcast(plrs, game_status.title, msg, {popup = show_popup})
end
=== modified file 'data/scripting/win_conditions/territorial_functions.lua'
--- data/scripting/win_conditions/territorial_functions.lua 2018-12-03 20:30:01 +
+++ data/scripting/win_conditions/territorial_functions.lua 2019-01-30 23:12:09 +
@@ -103,7 +103,7 @@
-- We record the last winning player name here to prevent crashes with retrieving
-- the player name when the player was just defeated a few ms ago
last_winning_player_name = "",
- remaining_time = 10,
+ remaining_time = 1201,
all_player_points = {},
points = {}
}
@@ -167,10 +167,15 @@
-- Set the remaining time according to whether the winner is still the same
if territory_was_kept then
-- Still the same winner
- territory_points.remaining_time = territory_points.remaining_time - 30
+ territory_points.remaining_time = territory_points.remaining_time - 1
elseif winning_points == -1 then
-- No winner. This value is used to calculate whether to send a report to players.
- territory_points.remaining_time = 10
+ if territory_points.remaining_time == 1800 then
+ territory_points.remaining_time = 1201
+ elseif territory_points.remaining_time ~= 1201 then
+ territory_points.remaining_time = 1800
+ end
+
else
-- Winner changed
territory_points.remaining_time = 20 * 60 -- 20 minutes
=== modified file 'data/scripting/win_conditions/territorial_lord.lua'
--- data/scripting/win_conditions/territorial_lord.lua 2018-12-03 20:30:01 +
+++ data/scripting/win_conditions/territorial_lord.lua 2019-01-30 23:12:09 +
@@ -39,25 +39,30 @@
-- Get all valueable fields of the map
local fields = get_buildable_fields()
- local function _send_state()
+ local function _send_state(show_popup)
set_textdomain("win_conditions")
for idx, player in ipairs(plrs) do
local msg = ""
-if territory_points.last_winning_team == player.team or territory_points.last_winning_player == player.number then
- msg = msg .. winning_status_header() .. vspace(8)
+if (territory_points.last_winning_team >= 0 or territory_points.last_winning_player >= 0) then
+ if territory_points.last_winning_team == player.team or territory_points.last_winning_player == player.number then
+ msg = msg .. winning_status_header()
+ else
+ msg = msg .. losing_status_header(plrs)
+ end
else
- msg = msg .. losing_status_header(plrs) .. vspace(8)
-end
-msg = msg .. vspace(8) .. game_status.body .. territory_status(fields, "has")
- send_message(player, game_status.title, msg, {popup = true})
+ msg = p(_"Currently no faction owns more than half of the map’s area.")
+end
+ msg = msg .. vspace(8) .. game_status.body .. territory_status(fields, "has")
+ player:send_message(game_status.title, msg, {popup = show_popup})
+end
end
end
-- here is the main loop!!!
- while true do
- -- Sleep 30 seconds == STATISTICS_SAMPLE_TIME
- sleep(3)
+ while count_factions(plrs) > 1 or territory_points.remaining_time > 0 do
+ -- Sleep 1 second
+ sleep(1000)
-- A player might have been defeated since the last calculation
check_player_defeated(plrs, lost_game.title, lost_game.body)
@@ -65,16 +70,15 @@
-- Check if a player or team is a candidate and update variables