Merge lp:~widelands-dev/widelands/bug-1622199-win-condition-markup into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8097
Proposed branch: lp:~widelands-dev/widelands/bug-1622199-win-condition-markup
Merge into: lp:widelands
Diff against target: 276 lines (+53/-56)
6 files modified
data/scripting/win_conditions/artifacts.lua (+29/-29)
data/scripting/win_conditions/collectors.lua (+2/-2)
data/scripting/win_conditions/territorial_lord.lua (+2/-2)
data/scripting/win_conditions/territorial_time.lua (+3/-3)
data/scripting/win_conditions/win_condition_texts.lua (+3/-3)
data/scripting/win_conditions/wood_gnome.lua (+14/-17)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1622199-win-condition-markup
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+305456@code.launchpad.net

Commit message

Fixed RT markup for win condition messages.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1317. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/159282324.
Appveyor build 1159. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1622199_win_condition_markup-1159.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Launchpad failed updating the branch... diff is available on Github:

https://github.com/widelands/widelands/commit/ab0d608f22b91b8d52285748f2584fdb1680b551

Revision history for this message
SirVer (sirver) wrote :

The github diff is actually way easier to read.... And leaving comments is better there too. We should really get us over there :/.

code lgtm.

@bunnybot merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/scripting/win_conditions/artifacts.lua'
2--- data/scripting/win_conditions/artifacts.lua 2016-03-15 08:42:41 +0000
3+++ data/scripting/win_conditions/artifacts.lua 2016-09-14 18:27:18 +0000
4@@ -24,12 +24,12 @@
5 -- set the objective with the game type for all players
6 broadcast_objective("win_condition", wc_descname, wc_desc)
7
8- local function _getkey(p)
9- if p.team == 0 then
10+ local function _getkey(plr)
11+ if plr.team == 0 then
12 -- Players without a team have team number 0. To distinguish between them, we use a special key.
13- return "player" .. p.number
14+ return "player" .. plr.number
15 else
16- return p.team
17+ return plr.team
18 end
19 end
20
21@@ -74,9 +74,9 @@
22 if player.team == 0 then
23 player:send_message(msg.title, msg.body, {msg, field = f})
24 else
25- for idx, p in ipairs(plrs) do
26- if p.team == player.team then
27- p:send_message(msg.title, msg.body, {msg, field = f})
28+ for idx, plr in ipairs(plrs) do
29+ if plr.team == player.team then
30+ plr:send_message(msg.title, msg.body, {msg, field = f})
31 end
32 end
33 end
34@@ -111,12 +111,12 @@
35
36 -- All artifacts are found, the game is over.
37 local artifacts_per_team = {}
38- for idx, p in ipairs(plrs) do
39- artifacts_per_team[_getkey(p)] = 0
40+ for idx, plr in ipairs(plrs) do
41+ artifacts_per_team[_getkey(plr)] = 0
42 end
43
44- for idx, p in pairs(artifacts_owner) do
45- local key = _getkey(p)
46+ for idx, plr in pairs(artifacts_owner) do
47+ local key = _getkey(plr)
48 artifacts_per_team[key] = artifacts_per_team[key] + 1
49 end
50
51@@ -132,29 +132,29 @@
52
53 local function _get_member_names(t)
54 local s = ""
55- for idx, p in ipairs(t) do
56+ for idx, plr in ipairs(t) do
57 if s == "" then
58- s = p.name
59+ s = plr.name
60 else
61 -- TRANSLATORS: This is used to seperate players’ names in a list, e.g. "Steve, Robert, David"
62- s = s .. _", " .. p.name
63+ s = s .. _", " .. plr.name
64 end
65 end
66 return s
67 end
68
69 local teams = {}
70- local msg = _"Overview:" .. "\n"
71- for idx, p in ipairs(plrs) do
72- if p.team == 0 then
73- local artifacts = (ngettext("%i artifact", "%i artifacts", artifacts_per_team[_getkey(p)])):format(artifacts_per_team[_getkey(p)])
74+ local msg = h3(_"Overview:")
75+ for idx, plr in ipairs(plrs) do
76+ if plr.team == 0 then
77+ local artifacts = (ngettext("%i artifact", "%i artifacts", artifacts_per_team[_getkey(plr)])):format(artifacts_per_team[_getkey(plr)])
78 -- TRANSLATORS: e.g. Team 1 owns 5 artifacts.
79- msg = msg .. "\n" .. (_"%1$s owns %2$s."):bformat(p.name, artifacts)
80+ msg = msg .. p((_"%1$s owns %2$s."):bformat(plr.name, artifacts))
81 else
82- if teams[p.team] then
83- teams[p.team][#teams[p.team]+1] = p
84+ if teams[plr.team] then
85+ teams[plr.team][#teams[plr.team]+1] = plr
86 else
87- teams[p.team] = {p}
88+ teams[plr.team] = {plr}
89 end
90 end
91 end
92@@ -162,19 +162,19 @@
93 local members = _get_member_names(t)
94 local artifacts = (ngettext("%i artifact", "%i artifacts", artifacts_per_team[_getkey(t[1])])):format(artifacts_per_team[_getkey(t[1])])
95 -- TRANSLATORS: %1$i is the team's number; %2$s is a list of team members (e.g. "Steve, Robert, David"), %3$s is something like "x artifact(s)"
96- msg = msg .. "\n" .. (_"Team %1$i (%2$s) owns %3$s."):bformat(t[1].team, members, artifacts)
97+ msg = msg .. p((_"Team %1$i (%2$s) owns %3$s."):bformat(t[1].team, members, artifacts))
98 end
99
100
101- for idx, p in ipairs(plrs) do
102- local key = _getkey(p)
103+ for idx, plr in ipairs(plrs) do
104+ local key = _getkey(plr)
105 -- If two or more teams have the same amount of artifacts, they are all considered winners.
106 if artifacts_per_team[key] == max_artifacts then
107- p:send_message(won_game_over.title, won_game_over.body .. "\n\n" .. msg)
108- wl.game.report_result(p, 1, make_extra_data(p, wc_descname, wc_version, {score=artifacts_per_team[key]}))
109+ plr:send_message(won_game_over.title, rt(won_game_over.body .. msg))
110+ wl.game.report_result(plr, 1, make_extra_data(plr, wc_descname, wc_version, {score=artifacts_per_team[key]}))
111 else
112- p:send_message(lost_game_over.title, lost_game_over.body .. "\n\n" .. msg)
113- wl.game.report_result(p, 0, make_extra_data(p, wc_descname, wc_version, {score=artifacts_per_team[key]}))
114+ plr:send_message(lost_game_over.title, rt(lost_game_over.body .. msg))
115+ wl.game.report_result(plr, 0, make_extra_data(plr, wc_descname, wc_version, {score=artifacts_per_team[key]}))
116 end
117 end
118 end,
119
120=== modified file 'data/scripting/win_conditions/collectors.lua'
121--- data/scripting/win_conditions/collectors.lua 2016-05-20 21:03:41 +0000
122+++ data/scripting/win_conditions/collectors.lua 2016-09-14 18:27:18 +0000
123@@ -196,10 +196,10 @@
124 local lost_or_won = 0
125 if (info[2] < win_points) then
126 lost_or_won = 0
127- player:send_message(lost_game_over.title, lost_game_over.body)
128+ player:send_message(lost_game_over.title, rt(lost_game_over.body))
129 else
130 lost_or_won = 1
131- player:send_message(won_game_over.title, won_game_over.body)
132+ player:send_message(won_game_over.title, rt(won_game_over.body))
133 end
134 if (player.team == 0) then
135 wl.game.report_result(player, lost_or_won, make_extra_data(player, wc_descname, wc_version, {score=info[2]}))
136
137=== modified file 'data/scripting/win_conditions/territorial_lord.lua'
138--- data/scripting/win_conditions/territorial_lord.lua 2016-08-07 08:12:58 +0000
139+++ data/scripting/win_conditions/territorial_lord.lua 2016-09-14 18:27:18 +0000
140@@ -199,10 +199,10 @@
141 p.see_all = 1
142 if candidateisteam and currentcandidate == p.team
143 or not candidateisteam and currentcandidate == p.name then
144- p:send_message(won_game_over.title, won_game_over.body)
145+ p:send_message(won_game_over.title, rt(won_game_over.body))
146 wl.game.report_result(p, 1, make_extra_data(p, wc_descname, wc_version, {score=_landsizes[p.number]}))
147 else
148- p:send_message(lost_game_over.title, lost_game_over.body)
149+ p:send_message(lost_game_over.title, rt(lost_game_over.body))
150 wl.game.report_result(p, 0, make_extra_data(p, wc_descname, wc_version, {score=_landsizes[p.number]}))
151 end
152 end
153
154=== modified file 'data/scripting/win_conditions/territorial_time.lua'
155--- data/scripting/win_conditions/territorial_time.lua 2016-05-17 16:40:22 +0000
156+++ data/scripting/win_conditions/territorial_time.lua 2016-09-14 18:27:18 +0000
157@@ -238,7 +238,7 @@
158 :format(remaining_max_time // 60))
159 end
160 msg = msg .. "\n\n"
161- msg = msg .. "</rt>" .. game_status.body .. "<rt>"
162+ msg = msg .. "</rt>" .. rt(game_status.body) .. "<rt>"
163 msg = msg .. _status(points, "has")
164 send_message(pl, game_status.title, rt(msg), {popup = true})
165 end
166@@ -285,9 +285,9 @@
167
168 maxpoints = points[1][2]
169 local wonmsg = won_game_over.body
170- wonmsg = wonmsg .. "\n\n" .. game_status.body
171+ wonmsg = wonmsg .. game_status.body
172 local lostmsg = lost_game_over.body
173- lostmsg = lostmsg .. "\n\n" .. game_status.body
174+ lostmsg = lostmsg .. game_status.body
175 for i=1,#points do
176 if points[i][1] == team_str:format(pl.team) or points[i][1] == pl.name then
177 if points[i][2] >= maxpoints then
178
179=== modified file 'data/scripting/win_conditions/win_condition_texts.lua'
180--- data/scripting/win_conditions/win_condition_texts.lua 2016-03-15 08:42:41 +0000
181+++ data/scripting/win_conditions/win_condition_texts.lua 2016-09-14 18:27:18 +0000
182@@ -12,15 +12,15 @@
183
184 won_game_over = {
185 title = _"You won",
186- body = rt(p(_"You are the winner!"))
187+ body = h2(_"You are the winner!")
188 }
189
190 lost_game_over = {
191 title = _"You lost",
192- body = rt(p(_"You’ve lost this game!"))
193+ body = h2(_"You’ve lost this game!")
194 }
195
196 game_status = {
197 title = _"Status",
198- body = rt(p(_"Player overview:"))
199+ body = h3(_"Player overview:")
200 }
201
202=== modified file 'data/scripting/win_conditions/wood_gnome.lua'
203--- data/scripting/win_conditions/wood_gnome.lua 2016-05-17 16:40:22 +0000
204+++ data/scripting/win_conditions/wood_gnome.lua 2016-09-14 18:27:18 +0000
205@@ -3,6 +3,7 @@
206 -- =======================================================================
207
208 include "scripting/coroutine.lua" -- for sleep
209+include "scripting/formatting.lua"
210 include "scripting/table.lua"
211 include "scripting/win_conditions/win_condition_functions.lua"
212
213@@ -83,19 +84,16 @@
214 local function _send_state()
215 set_textdomain("win_conditions")
216 local playerpoints = _calc_points()
217- local msg = (ngettext("The game will end in %i minute.", "The game will end in %i minutes.", remaining_time))
218+ local msg = p(ngettext("The game will end in %i minute.", "The game will end in %i minutes.", remaining_time))
219 :format(remaining_time)
220- msg = msg .. "\n\n"
221- msg = msg .. game_status.body
222+ msg = msg .. "<p font-size=8> <br></p>" .. game_status.body
223 for idx,plr in ipairs(plrs) do
224- msg = msg .. "\n"
225 local trees = (ngettext ("%i tree", "%i trees", playerpoints[plr.number]))
226 :format(playerpoints[plr.number])
227 -- TRANSLATORS: %1$s = player name, %2$s = x tree(s)
228- msg = msg .. (_"%1$s has %2$s at the moment."):bformat(plr.name,trees)
229+ msg = msg .. p(_"%1$s has %2$s at the moment."):bformat(plr.name,trees)
230 end
231-
232- broadcast(plrs, game_status.title, msg)
233+ broadcast(plrs, game_status.title, rt(msg))
234 end
235
236 -- Start a new coroutine that checks for defeated players
237@@ -137,30 +135,29 @@
238 end
239 table.sort(points, function(a,b) return a[2] < b[2] end)
240
241- local msg = "\n\n"
242- msg = msg .. game_status.body
243+ local msg = "<p font-size=8> <br></p>" .. game_status.body
244 for idx,plr in ipairs(plrs) do
245- msg = msg .. "\n"
246+ msg = msg .. "<p font-size=8> <br></p>"
247 local trees = (ngettext ("%i tree", "%i trees", playerpoints[plr.number])):format(playerpoints[plr.number])
248 -- TRANSLATORS: %1$s = player name, %2$s = x tree(s)
249- msg = msg .. (_"%1$s had %2$s."):bformat(plr.name,trees)
250+ msg = msg .. p(_"%1$s had %2$s."):bformat(plr.name,trees)
251 end
252- msg = msg .. "\n\n"
253+ msg = msg .. "<p font-size=8> <br></p>"
254 local trees = (ngettext ("%i tree", "%i trees", playerpoints[points[#points][1].number]))
255 :format(playerpoints[points[#points][1].number])
256 -- TRANSLATORS: %1$s = player name, %2$s = x tree(s)
257- msg = msg .. (_"The winner is %1$s with %2$s."):bformat(points[#points][1].name, trees)
258+ msg = msg .. h3(_"The winner is %1$s with %2$s."):bformat(points[#points][1].name, trees)
259
260 local privmsg = ""
261 for i=1,#points-1 do
262- privmsg = lost_game_over.title
263+ privmsg = lost_game_over.body
264 privmsg = privmsg .. msg
265- points[i][1]:send_message(lost_game_over.body, privmsg)
266+ points[i][1]:send_message(lost_game_over.title, rt(privmsg))
267 wl.game.report_result(points[i][1], 0, make_extra_data(points[i][1], wc_descname, wc_version, {score=points[i][2]}))
268 end
269- privmsg = won_game_over.title
270+ privmsg = won_game_over.body
271 privmsg = privmsg .. msg
272- points[#points][1]:send_message(won_game_over.body, privmsg)
273+ points[#points][1]:send_message(won_game_over.title, rt(privmsg))
274 wl.game.report_result(points[#points][1], 1,
275 make_extra_data(points[#points][1], wc_descname, wc_version, {score=points[#points][2]}))
276 end

Subscribers

People subscribed via source and target branches

to status/vote changes: