~widelands-dev/widelands/frisians

« back to all changes in this revision

Viewing changes to test/maps/market_trading.wmf/scripting/init.lua

Add a test that a market can be build and make it pass. This mostly adds Lua boilerplate classes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
include "scripting/lunit.lua"
 
2
include "scripting/coroutine.lua"
 
3
include "scripting/infrastructure.lua"
 
4
include "scripting/ui.lua"
 
5
 
 
6
game = wl.Game()
 
7
map = game.map
 
8
p1 = game.players[1]
 
9
p2 = game.players[2]
 
10
p1.see_all = true
 
11
 
 
12
p1:allow_workers("all")
 
13
 
 
14
function full_headquarters(player, x, y) 
 
15
   prefilled_buildings(player, { "barbarians_headquarters", x, y })
 
16
   hq = player:get_buildings("barbarians_headquarters")[1]
 
17
   for idx,descr in ipairs(game:get_tribe_description("barbarians").wares) do
 
18
      hq:set_wares(descr.name, 350)
 
19
   end
 
20
   for idx,descr in ipairs(game:get_tribe_description("barbarians").workers) do
 
21
      hq:set_workers(descr.name, 50)
 
22
   end
 
23
end
 
24
 
 
25
full_headquarters(p1, 22, 25)
 
26
full_headquarters(p2, 32, 25)
 
27
 
 
28
game.desired_speed = 50000