← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug1792297_worker_encyclopedia into lp:widelands

 

hessenfarmer has proposed merging lp:~widelands-dev/widelands/bug1792297_worker_encyclopedia into lp:widelands.

Commit message:
fixes bug 1792297 


Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1792297 in widelands: "Advanced buildings report wrong worker experience in the encyclopedia"
  https://bugs.launchpad.net/widelands/+bug/1792297

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug1792297_worker_encyclopedia/+merge/354986

correct experience levels are displayed for the workers in the building help.

all possible working places for workers are listed including positions of lower experienced workers 
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug1792297_worker_encyclopedia into lp:widelands.
=== modified file 'data/tribes/scripting/help/building_help.lua'
--- data/tribes/scripting/help/building_help.lua	2018-09-12 19:51:07 +0000
+++ data/tribes/scripting/help/building_help.lua	2018-09-15 16:11:36 +0000
@@ -666,6 +666,9 @@
          end
       end
 
+      worker_description = building_description.working_positions[1]
+      becomes_description = worker_description.becomes
+      
       if (becomes_description) then
          result = result .. help_worker_experience(worker_description, becomes_description)
       end

=== modified file 'data/tribes/scripting/help/worker_help.lua'
--- data/tribes/scripting/help/worker_help.lua	2017-12-07 08:17:40 +0000
+++ data/tribes/scripting/help/worker_help.lua	2018-09-15 16:11:36 +0000
@@ -97,15 +97,37 @@
 --
 function worker_help_employers_string(worker_description)
    local result = ""
-   local employers = worker_description.employers;
 
-   if (#employers > 0) then
+   if (#worker_description.employers > 0) then
       -- TRANSLATORS: Worker Encyclopedia: A list of buildings where a worker can work
       -- TRANSLATORS: You can also translate this as 'workplace(s)'
-      result = result .. h2(ngettext("Works at", "Works at", #employers))
+      result = result .. h2(ngettext("Works at", "Works at", #worker_description.employers))
       for i, building in ipairs(worker_description.employers) do
          result = result .. dependencies({worker_description, building}, building.descname)
       end
+      building = worker_description.employers[1]
+         if #building.working_positions > 1 and worker_description.descname == building.working_positions[2].descname and worker_description.descname ~= building.working_positions[1].descname then
+            for i, build in ipairs(building.working_positions[1].employers) do
+               if not build.working_positions[2] then
+                  -- TRANSLATORS: this text should describe that a more expereinced worker can be a substitute for a less experienced worker
+                  result = result .. dependencies({worker_description, build}, build.descname .. _" (instead of " .. build.working_positions[1].descname .. ")")
+               end
+            end
+         elseif #building.working_positions > 2 and worker_description.descname == building.working_positions[3].descname then
+            for i, build in ipairs(building.working_positions[1].employers) do
+               if #build.working_positions > 1 and not build.working_positions[3] then
+                  -- TRANSLATORS: This text should describe that a level 3 worker can be a substitute for a level 2 worker or a level 1 worker
+                  result = result .. dependencies({worker_description, build}, build.descname .. _" (instead of " .. build.working_positions[2].descname .. " or " .. build.working_positions[1].descname .. ")")
+               end
+            end
+            for i, build in ipairs(building.working_positions[1].employers) do
+               if not build.working_positions[2] then
+                  -- TRANSLATORS: this text should describe that a more expereinced worker can be a substitute for a less experienced worker
+                  result = result .. dependencies({worker_description, build}, build.descname .. _" (instead of " .. build.working_positions[1].descname .. ")")
+               end
+            end
+         end
+      -- end
    end
    return result
 end


Follow ups