From 63fdc369f0b476635bba1cad2b2590290cc75b9c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Aug 2010 17:02:41 -0700 Subject: [PATCH 01/20] names too long --- src/eressea.vcxproj | 4 +-- src/eressea.vcxproj.filters | 50 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/eressea.vcxproj b/src/eressea.vcxproj index 640685a1c..6bc2b8490 100644 --- a/src/eressea.vcxproj +++ b/src/eressea.vcxproj @@ -11,7 +11,7 @@ - amalgamation-eressea + eressea {AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387} build Win32Proj @@ -186,4 +186,4 @@ - + \ No newline at end of file diff --git a/src/eressea.vcxproj.filters b/src/eressea.vcxproj.filters index f3457e733..4af32df31 100644 --- a/src/eressea.vcxproj.filters +++ b/src/eressea.vcxproj.filters @@ -53,35 +53,35 @@ Source Files - - Source Files - Source Files Source Files - - Unity Build - - - Unity Build - - - Unity Build - - - Unity Build - Unity Build - - Unity Build + + Source Files - - Unity Build + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files @@ -106,15 +106,15 @@ Header Files - - Header Files - - - Header Files - Header Files + + Header Files + + + Header Files + From 320bcb2121381555dff31191a3540d761f06fd29 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 17 Aug 2010 23:34:50 -0700 Subject: [PATCH 02/20] http://bugs.eressea.de/view.php?id=1796 great bows should be allowed for all, not just elves --- scripts/eressea/rules.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/eressea/rules.lua b/scripts/eressea/rules.lua index 5866a8ffc..8e2137a13 100644 --- a/scripts/eressea/rules.lua +++ b/scripts/eressea/rules.lua @@ -1,8 +1,8 @@ function item_canuse(u, iname) - local race = u.race - if iname=="greatbow" then - -- only elves use greatbow - return race=="elf" - end + -- local race = u.race + -- if iname=="greatbow" then + -- -- only elves use greatbow + -- return race=="elf" + -- end return true end From 201ae39a4d696b61f6e48b9d9d4d731d94f370d0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 28 Aug 2010 17:54:15 -0700 Subject: [PATCH 03/20] re-enable stealth faction (anon) --- res/config-e3a.xml | 1 - scripts/e3a/modules.lua | 1 + scripts/tests/e3a.lua | 13 ++++++++++++ scripts/tests/stealth.lua | 42 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 scripts/tests/stealth.lua diff --git a/res/config-e3a.xml b/res/config-e3a.xml index a42b5ffdb..f4b0a7401 100644 --- a/res/config-e3a.xml +++ b/res/config-e3a.xml @@ -64,7 +64,6 @@ - diff --git a/scripts/e3a/modules.lua b/scripts/e3a/modules.lua index 59a3aef7f..60045005a 100644 --- a/scripts/e3a/modules.lua +++ b/scripts/e3a/modules.lua @@ -9,4 +9,5 @@ tests = { srcpath .. '/eressea/scripts/tests/morale.lua', srcpath .. '/shared/scripts/tests/common.lua', srcpath .. '/eressea/scripts/tests/e3a.lua', + srcpath .. '/eressea/scripts/tests/stealth.lua', } diff --git a/scripts/tests/e3a.lua b/scripts/tests/e3a.lua index 1d5e446c6..a3b15f62f 100644 --- a/scripts/tests/e3a.lua +++ b/scripts/tests/e3a.lua @@ -48,6 +48,19 @@ function test_attrib() end end +function test_no_stealth() + local r = region.create(0,0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + u:set_skill("stealth", 1) + assert_equal(-1, u:get_skill("stealth")) + u:clear_orders() + u:add_order("LERNEN TARNUNG") + process_orders() + assert_equal(-1, u:get_skill("stealth")) +end + function test_seecast() local r = region.create(0,0, "plain") for i = 1,10 do diff --git a/scripts/tests/stealth.lua b/scripts/tests/stealth.lua new file mode 100644 index 000000000..c1ff9dcb2 --- /dev/null +++ b/scripts/tests/stealth.lua @@ -0,0 +1,42 @@ +require "lunit" + +module("e3-stealth", package.seeall, lunit.testcase) + +function setup_stealth() + local result = {} + free_game() + result.r = region.create(0,0, "plain") + result.f1 = faction.create("noreply@eressea.de", "human", "de") + result.f2 = faction.create("noreply@eressea.de", "human", "de") + result.u1 = unit.create(result.f1, result.r, 1) + result.u2 = unit.create(result.f2, result.r, 1) + result.u1:add_item("money", 1000) + result.u2:add_item("money", 1000) + return result +end + +function test_stealth_faction_on() + local result = setup_stealth() + local f = result.f2 + local u = result.u1 + u:clear_orders() + u:add_order("TARNEN PARTEI") + + settings.set("rules.stealth.faction", 1) + process_orders() + assert_not_match("Partei", report.report_unit(u, f)) + assert_match("anonym", report.report_unit(u, f)) +end + +function test_stealth_faction_off() + local result = setup_stealth() + local f = result.f2 + local u = result.u1 + u:clear_orders() + u:add_order("TARNEN PARTEI") + + settings.set("rules.stealth.faction", 0) + process_orders() + assert_match("Partei", report.report_unit(u, f)) + assert_not_match("anonym", report.report_unit(u, f)) +end From 6e4a38ee65631cd676c6c6b0152236774062d684 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 28 Aug 2010 18:03:29 -0700 Subject: [PATCH 04/20] enable faction stealth for E3 --- res/config-e3a.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/config-e3a.xml b/res/config-e3a.xml index f4b0a7401..88099b403 100644 --- a/res/config-e3a.xml +++ b/res/config-e3a.xml @@ -130,7 +130,7 @@ - + From 65512365441a9ceb15eb10de81f94456ad0508d4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 28 Aug 2010 23:05:09 -0700 Subject: [PATCH 05/20] E3: no anonymous sides in combat. --- res/config-e3a.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/config-e3a.xml b/res/config-e3a.xml index 88099b403..7037ffd24 100644 --- a/res/config-e3a.xml +++ b/res/config-e3a.xml @@ -131,6 +131,7 @@ + From be2d7d203d40703fc0b1b601a52abce3ff29e8f9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Sep 2010 18:48:08 -0700 Subject: [PATCH 06/20] frost module: during winter, some oceans freeze over --- res/e3a/ships.xml | 16 ++++++++++++++++ scripts/e3a/frost.lua | 36 ++++++++++++++++++++++++++++++++++++ scripts/eressea/main.lua | 2 ++ 3 files changed, 54 insertions(+) create mode 100644 scripts/e3a/frost.lua diff --git a/res/e3a/ships.xml b/res/e3a/ships.xml index 0c8c184e0..393479234 100644 --- a/res/e3a/ships.xml +++ b/res/e3a/ships.xml @@ -22,6 +22,8 @@ + + @@ -83,6 +85,8 @@ + + @@ -93,6 +97,8 @@ + + @@ -101,6 +107,8 @@ + + @@ -111,6 +119,8 @@ + + @@ -121,6 +131,8 @@ + + @@ -133,6 +145,8 @@ + + @@ -144,6 +158,8 @@ + + diff --git a/scripts/e3a/frost.lua b/scripts/e3a/frost.lua new file mode 100644 index 000000000..7cd788de9 --- /dev/null +++ b/scripts/e3a/frost.lua @@ -0,0 +1,36 @@ +module('frost', package.seeall) + +local function is_winter(turn) + local season = get_season(turn) + return season == "calendar::winter" +end + +local function freeze(r) + for i, rn in ipairs(r.adj) do + -- each region has a chance to freeze + if rn.terrain=="ocean" and math.mod(rng_int(), 100)<20 then + rn.terrain = "iceberg_sleep" + end + end +end + +local function thaw(r) + r.terrain = "ocean" +end + +function update() + local turn = get_turn() + if is_winter(turn) then + for r in regions() do + if r.terrain=="glacier" then + freeze(r) + end + end + else if is_winter(turn-1) then + for r in regions() do + if r.terrain=="iceberg_sleep" then + thaw(r) + end + end + end +end \ No newline at end of file diff --git a/scripts/eressea/main.lua b/scripts/eressea/main.lua index 060fdbf8c..4eed4d057 100644 --- a/scripts/eressea/main.lua +++ b/scripts/eressea/main.lua @@ -1,4 +1,5 @@ require "multis" +require "e3a.frost" function apply_fixes() local turn = get_turn() @@ -48,6 +49,7 @@ function process(orders) update_embassies() update_guards() update_scores() + frost.update() local localechange = { de = { "ii" } } change_locales(localechange) From 02b89b7d503d301859482c52dfcf136d184ab79a Mon Sep 17 00:00:00 2001 From: Enno Date: Sun, 12 Sep 2010 04:12:04 +0200 Subject: [PATCH 07/20] feature was meant for e3a, not eressea --- scripts/e3a/frost.lua | 6 ++++-- scripts/e3a/main.lua | 2 ++ scripts/eressea/main.lua | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/e3a/frost.lua b/scripts/e3a/frost.lua index 7cd788de9..1b653c161 100644 --- a/scripts/e3a/frost.lua +++ b/scripts/e3a/frost.lua @@ -9,6 +9,7 @@ local function freeze(r) for i, rn in ipairs(r.adj) do -- each region has a chance to freeze if rn.terrain=="ocean" and math.mod(rng_int(), 100)<20 then + print("terraforming .. " .. tostring(rn)) rn.terrain = "iceberg_sleep" end end @@ -21,16 +22,17 @@ end function update() local turn = get_turn() if is_winter(turn) then + print "it is winter" for r in regions() do if r.terrain=="glacier" then freeze(r) end end - else if is_winter(turn-1) then + elseif is_winter(turn-1) then for r in regions() do if r.terrain=="iceberg_sleep" then thaw(r) end end end -end \ No newline at end of file +end diff --git a/scripts/e3a/main.lua b/scripts/e3a/main.lua index 0548ce513..3d4c7c2ca 100644 --- a/scripts/e3a/main.lua +++ b/scripts/e3a/main.lua @@ -1,4 +1,5 @@ require "multis" +require "e3a.frost" function process(orders) local confirmed_multis = { } @@ -45,6 +46,7 @@ function process(orders) -- post-turn updates: update_guards() update_scores() + frost.update() local localechange = { de = { "ii" } } change_locales(localechange) diff --git a/scripts/eressea/main.lua b/scripts/eressea/main.lua index 4eed4d057..060fdbf8c 100644 --- a/scripts/eressea/main.lua +++ b/scripts/eressea/main.lua @@ -1,5 +1,4 @@ require "multis" -require "e3a.frost" function apply_fixes() local turn = get_turn() @@ -49,7 +48,6 @@ function process(orders) update_embassies() update_guards() update_scores() - frost.update() local localechange = { de = { "ii" } } change_locales(localechange) From 92f0ba6dcf824e2d0ab6d281fc90bbbeaa65e119 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Sep 2010 19:30:19 -0700 Subject: [PATCH 08/20] frost / packice --- .gitignore | 3 +++ res/e3a/ships.xml | 36 ++++++++++++------------------------ res/e3a/strings.xml | 9 +++++++++ res/e3a/terrains.xml | 16 ++-------------- scripts/e3a/frost.lua | 6 ++---- 5 files changed, 28 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 18c434a75..fe7235a1d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ bin/ *.suo *.sdf *.bak +*.opensdf +ipch/ +*.log diff --git a/res/e3a/ships.xml b/res/e3a/ships.xml index 393479234..1174eda8e 100644 --- a/res/e3a/ships.xml +++ b/res/e3a/ships.xml @@ -3,6 +3,7 @@ + @@ -10,8 +11,6 @@ - - @@ -20,10 +19,9 @@ + - - @@ -32,6 +30,7 @@ + @@ -39,8 +38,6 @@ - - @@ -49,6 +46,7 @@ + @@ -56,8 +54,6 @@ - - @@ -67,6 +63,7 @@ + @@ -74,8 +71,6 @@ - - @@ -85,8 +80,7 @@ - - + @@ -97,8 +91,7 @@ - - + @@ -107,8 +100,7 @@ - - + @@ -119,8 +111,7 @@ - - + @@ -131,8 +122,7 @@ - - + @@ -145,8 +135,7 @@ - - + @@ -158,8 +147,7 @@ - - + diff --git a/res/e3a/strings.xml b/res/e3a/strings.xml index 3e4c3e9d1..3b368a28e 100644 --- a/res/e3a/strings.xml +++ b/res/e3a/strings.xml @@ -13,6 +13,15 @@ the third age + + Packeis + fast ice + + + %s + %s + + Urkunden Certificates diff --git a/res/e3a/terrains.xml b/res/e3a/terrains.xml index 512536c38..5312a0aad 100644 --- a/res/e3a/terrains.xml +++ b/res/e3a/terrains.xml @@ -1,6 +1,6 @@ - + @@ -44,19 +44,7 @@ - - - - - - - - - - - - - + diff --git a/scripts/e3a/frost.lua b/scripts/e3a/frost.lua index 1b653c161..235cdc77f 100644 --- a/scripts/e3a/frost.lua +++ b/scripts/e3a/frost.lua @@ -9,8 +9,7 @@ local function freeze(r) for i, rn in ipairs(r.adj) do -- each region has a chance to freeze if rn.terrain=="ocean" and math.mod(rng_int(), 100)<20 then - print("terraforming .. " .. tostring(rn)) - rn.terrain = "iceberg_sleep" + rn.terrain = "packice" end end end @@ -22,7 +21,6 @@ end function update() local turn = get_turn() if is_winter(turn) then - print "it is winter" for r in regions() do if r.terrain=="glacier" then freeze(r) @@ -30,7 +28,7 @@ function update() end elseif is_winter(turn-1) then for r in regions() do - if r.terrain=="iceberg_sleep" then + if r.terrain=="packice" then thaw(r) end end From 22ab8ae62010d495f493618b3e0c6de0005dae0b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Sep 2010 19:38:32 -0700 Subject: [PATCH 09/20] frost / packice has no land_region strucutre (no peasants, no name and all that jazz) --- res/e3a/terrains.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/e3a/terrains.xml b/res/e3a/terrains.xml index 5312a0aad..f473fd500 100644 --- a/res/e3a/terrains.xml +++ b/res/e3a/terrains.xml @@ -44,7 +44,7 @@ - + From cfa66a87c718c482baa142bd47a8ba0e5b532af4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Sep 2010 20:46:46 -0700 Subject: [PATCH 10/20] functional test of the new packice terrain --- scripts/tests/e3a.lua | 92 +++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 35 deletions(-) diff --git a/scripts/tests/e3a.lua b/scripts/tests/e3a.lua index a3b15f62f..4bbc6a55f 100644 --- a/scripts/tests/e3a.lua +++ b/scripts/tests/e3a.lua @@ -565,43 +565,65 @@ function test_market_action() assert_equal(70, u:get_item("h2")) end --- function test_process_execute() - -- local i = 0 - -- local f = faction.create("noreply@eressea.de", "human", "de") - -- local r = region.create(0, 0, "plain") - -- local u = unit.create(f, r, 1) - -- local r1, u1 +local function setup_packice(x, onfoot) + local f = faction.create("noreply@eressea.de", "human", "de") + local plain = region.create(0,0, "plain") + local ice = region.create(1,0, "packice") + local ocean = region.create(2,0, "ocean") + local u = unit.create(f, get_region(x, 0), 2) + if not onfoot then + local s = ship.create(u.region, "cutter") + u:set_skill("sailing", 3) + u.ship = s + end + u:add_item("money", 400) - -- function a() i = 2 end - -- function b() i = i * 2 end - -- function c(r) r1 = r i = i + 1 end - -- function d(u) u1 = u i = i * 3 end - -- process.execute({a, b}, {c}, {d}) - -- assert_equal(15, i) - -- assert_equal(r, r1) - -- assert_equal(u, u1) --- end + return u +end --- function test_new_orders() - -- local i = 0 - -- local f = faction.create("noreply@eressea.de", "human", "de") - -- local r = region.create(0, 0, "plain") - -- local u = unit.create(f, r, 1) - -- local r1, u1 +function test_no_sailing_through_packice() + local u = setup_packice(0) + u:clear_orders() + u:add_order("NACH O O") + process_orders() + assert_equal(0, u.region.x) +end - -- function a() i = 2 end - -- function b() i = i * 2 end - -- function c(r) r1 = r i = i + 1 end - -- function d(u) u1 = u i = i * 3 end +function test_can_sail_from_packice_to_ocean() + local u = setup_packice(1) - -- process.setup() - -- process.push(a) - -- process.push(b) - -- process.push(c, "region") - -- process.push(d, "unit") - -- process.start() + u:clear_orders() + u:add_order("NACH W") + process_orders() + assert_equal(1, u.region.x) + + u:clear_orders() + u:add_order("NACH O") + process_orders() + assert_equal(2, u.region.x) +end + +function test_can_sail_into_packice() + local u = setup_packice(2) + u:clear_orders() + u:add_order("NACH W W") + process_orders() + assert_equal(1, u.region.x) +end + +function test_can_walk_into_packice() + local u = setup_packice(0, true) + u:clear_orders() + u:add_order("NACH O") + process_orders() + assert_equal(1, u.region.x) +end + +function test_cannot_walk_into_ocean() + local u = setup_packice(1, true) + u:clear_orders() + u:add_order("NACH O") + process_orders() + assert_equal(1, u.region.x) +end - -- assert_equal(15, i) - -- assert_equal(r, r1) - -- assert_equal(u, u1) --- end From e5967dd13d4ce47ac90dfdfab89a8d8ffd2bc742 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 2 Oct 2010 12:48:09 -0700 Subject: [PATCH 11/20] these spells need at least one argument --- res/eressea/spells.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml index 08f43a0ac..7c4816912 100644 --- a/res/eressea/spells.xml +++ b/res/eressea/spells.xml @@ -292,7 +292,7 @@ - + @@ -301,10 +301,10 @@ - + - + @@ -368,16 +368,16 @@ - + - + - + - + From 9b06900d7547444f0eb0eb78e3758088437ba266 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 2 Oct 2010 15:37:06 -0700 Subject: [PATCH 12/20] unit and magician limit extended in E2 --- res/config-eressea.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/res/config-eressea.xml b/res/config-eressea.xml index 291277c6f..e28a6ece5 100644 --- a/res/config-eressea.xml +++ b/res/config-eressea.xml @@ -100,7 +100,8 @@ - + + From 21eef2159b690160f2f0b22fb40ad2387a22d8cb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 5 Oct 2010 22:12:17 -0700 Subject: [PATCH 13/20] we want to test teaching. --- scripts/tests/eressea.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/scripts/tests/eressea.lua b/scripts/tests/eressea.lua index 06e1fd701..27659b1f5 100644 --- a/scripts/tests/eressea.lua +++ b/scripts/tests/eressea.lua @@ -6,6 +6,42 @@ function setup() free_game() end +function test_learn() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + f.age = 20 + local u = unit.create(f, r) + u:add_item("money", 1000) + u:clear_orders() + u:add_order("@LERNEN Reiten") + process_orders() + assert_equal(1, u:get_skill("riding")) + process_orders() + process_orders() + process_orders() + process_orders() + assert_true(2<=u:get_skill("riding")) +end + +function test_teach() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + f.age = 20 + local u = unit.create(f, r, 10) + local u2 = unit.create(f, r) + u:add_item("money", 1000) + u:clear_orders() + u:add_order("@LERNEN reiten") + u2:clear_orders() + u2:add_order("LEHREN " .. itoa36(u.id)) + u2:set_skill("riding", 4) + process_orders() + assert_equal(1, u:get_skill("riding")) + process_orders() + process_orders() + assert_true(2<=u:get_skill("riding")) +end + function test_rename() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") From 8000b9bb2b0947e2abf9de5b6eacc7e9841a1f7e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 8 Oct 2010 23:40:19 -0700 Subject: [PATCH 14/20] test learning and teaching, eliminate randomness --- scripts/tests/eressea.lua | 64 +++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/scripts/tests/eressea.lua b/scripts/tests/eressea.lua index 27659b1f5..767cff742 100644 --- a/scripts/tests/eressea.lua +++ b/scripts/tests/eressea.lua @@ -4,42 +4,45 @@ module( "e2", package.seeall, lunit.testcase ) function setup() free_game() + settings.set("nmr.timeout", "0") + settings.set("rules.economy.food", "4") end function test_learn() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - f.age = 20 - local u = unit.create(f, r) - u:add_item("money", 1000) - u:clear_orders() - u:add_order("@LERNEN Reiten") - process_orders() - assert_equal(1, u:get_skill("riding")) - process_orders() - process_orders() - process_orders() - process_orders() - assert_true(2<=u:get_skill("riding")) + settings.set("study.random_progress", "0") + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + f.age = 20 + local u = unit.create(f, r) + u:clear_orders() + u:add_order("@LERNEN Reiten") + process_orders() + assert_equal(1, u:get_skill("riding")) + process_orders() + process_orders() + assert_equal(2, u:get_skill("riding")) + process_orders() + process_orders() + process_orders() + assert_equal(3, u:get_skill("riding")) end function test_teach() - local r = region.create(0, 0, "plain") - local f = faction.create("noreply@eressea.de", "human", "de") - f.age = 20 - local u = unit.create(f, r, 10) - local u2 = unit.create(f, r) - u:add_item("money", 1000) - u:clear_orders() - u:add_order("@LERNEN reiten") - u2:clear_orders() - u2:add_order("LEHREN " .. itoa36(u.id)) - u2:set_skill("riding", 4) - process_orders() - assert_equal(1, u:get_skill("riding")) - process_orders() - process_orders() - assert_true(2<=u:get_skill("riding")) + settings.set("study.random_progress", "0") + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + f.age = 20 + local u = unit.create(f, r, 10) + local u2 = unit.create(f, r) + u:clear_orders() + u:add_order("@LERNEN reiten") + u2:clear_orders() + u2:add_order("LEHREN " .. itoa36(u.id)) + u2:set_skill("riding", 4) + process_orders() + assert_equal(1, u:get_skill("riding")) + process_orders() + assert_equal(2, u:get_skill("riding")) end function test_rename() @@ -115,6 +118,7 @@ function test_ship_capacity() u4:add_order("NACH O O") process_orders() + -- print(s.region, u.region, r2) assert_equal(r2.id, u1.region.id, "boat with 5 humans did not move") assert_not_equal(r2.id, u2.region.id, "boat with too many people has moved") From 0837fe4176c86becf8032b3315bb6c55c597c24b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 10 Oct 2010 21:42:27 -0700 Subject: [PATCH 15/20] http://bugs.eressea.de/view.php?id=1809 Monsters attacking units that they cannot see? Bad! --- src/monsters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monsters.c b/src/monsters.c index c80915ee7..c956350e8 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -543,7 +543,7 @@ monster_attacks(unit * u) unit * u2; for (u2=r->units;u2;u2=u2->next) { - if (u2->faction!=u->faction && chance(0.75)) { + if (cansee(u->faction, r, u2, 0) && u2->faction!=u->faction && chance(0.75)) { order * ord = monster_attack(u, u2); if (ord) addlist(&u->orders, ord); } From 561745b3560d2d19b0387bd10fbdf591489ef7e0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 16 Oct 2010 21:11:03 -0700 Subject: [PATCH 16/20] springtime on ice --- scripts/e3a/frost.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/e3a/frost.lua b/scripts/e3a/frost.lua index 235cdc77f..d0a36e9f3 100644 --- a/scripts/e3a/frost.lua +++ b/scripts/e3a/frost.lua @@ -16,6 +16,9 @@ end local function thaw(r) r.terrain = "ocean" + for s in r.ships do + s.coast = nil + end end function update() From 337dfab982dd4dc9a34467d1043a6f2ad3460938 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 16 Oct 2010 21:35:59 -0700 Subject: [PATCH 17/20] springtime is time to drown --- scripts/e3a/frost.lua | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/scripts/e3a/frost.lua b/scripts/e3a/frost.lua index d0a36e9f3..31bf9fe6f 100644 --- a/scripts/e3a/frost.lua +++ b/scripts/e3a/frost.lua @@ -5,19 +5,26 @@ local function is_winter(turn) return season == "calendar::winter" end -local function freeze(r) +local function is_spring(turn) + local season = get_season(turn) + return season == "calendar::spring" +end + +local function freeze(r, chance) for i, rn in ipairs(r.adj) do -- each region has a chance to freeze - if rn.terrain=="ocean" and math.mod(rng_int(), 100)<20 then + if rn.terrain=="ocean" and (chance>=100 or math.mod(rng_int(), 100)=100 or math.mod(rng_int(), 100) Date: Sat, 23 Oct 2010 01:12:23 -0700 Subject: [PATCH 18/20] bring script up to date with current syntax. --- scripts/eressea/adamant.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/eressea/adamant.lua b/scripts/eressea/adamant.lua index 66c260bdf..dae8b7929 100644 --- a/scripts/eressea/adamant.lua +++ b/scripts/eressea/adamant.lua @@ -27,7 +27,7 @@ end -- create a fixed path to a specific region local function create_path(from, to) local param = tostring(to.uid) - local b = add_building(from, "portal") + local b = building.create(from, "portal") b.name = "Weltentor" b.size = 1 b:add_action("tunnel_action", param) @@ -35,7 +35,7 @@ end -- create a wonky tunnel wth more than one exit local function create_tunnel(from, param) - local b = add_building(from, "portal") + local b = building.create(from, "portal") b.name = "Weltentor" b.size = 1 b:add_action("tunnel_action", param) @@ -59,8 +59,8 @@ function mkanchors() if not r:get_key("tnnL") then r:set_key("tnnL", true) if r:get_flag(0) then - -- RF_CHAOTIC - r:set_flag(0, true) + -- RF_CHAOTIC gets removed + r:set_flag(0, false) end r:set_resource("peasant", r:get_resource("peasant") + 1) end From 7b08767aa5d8acd1844202fc3ca9321cf93b927e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 31 Oct 2010 23:49:05 -0700 Subject: [PATCH 19/20] * fix tests to no longer depend on certain common functions * decouple tests from upkeep --- scripts/tests/e3a.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/scripts/tests/e3a.lua b/scripts/tests/e3a.lua index 4bbc6a55f..20d0b396e 100644 --- a/scripts/tests/e3a.lua +++ b/scripts/tests/e3a.lua @@ -4,6 +4,7 @@ module( "e3", package.seeall, lunit.testcase ) function setup() free_game() + settings.set("rules.economy.food", "0") end function has_attrib(u, value) @@ -419,7 +420,8 @@ function test_canoe_passes_through_land() region.create(2, 0, "ocean") local dst = region.create(3, 0, "ocean") local sh = ship.create(src, "canoe") - local u1, u2 = two_units(src, f, f) + local u1 = unit.create(f, src, 1) + local u2 = unit.create(f, src, 1) u1.ship = sh u2.ship = sh u1:set_skill("sailing", 10) @@ -433,19 +435,22 @@ function test_canoe_passes_through_land() end function test_give_50_percent_of_money() - local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions()) - local r = u2.region + settings.set("rules.economy.food", "4") + local r = region.create(0, 0, "plain") + local u1 = unit.create(faction.create("noreply@eressea.de", "human", "de"), r, 1) + local u2 = unit.create(faction.create("noreply@eressea.de", "orc", "de"), r, 1) u1.faction.age = 10 u2.faction.age = 10 u1:add_item("money", 500) + u2:add_item("money", 500) local m1, m2 = u1:get_item("money"), u2:get_item("money") u1:clear_orders() u1:add_order("GIB " .. itoa36(u2.id) .. " 221 Silber") u2:clear_orders() u2:add_order("LERNEN Hiebwaffen") process_orders() - assert(u1:get_item("money")==m1-10*u1.number) - assert(u2:get_item("money")==m2-10*u2.number) + assert_equal(m1, u1:get_item("money")) + assert_equal(m2, u2:get_item("money")) m1, m2 = u1:get_item("money"), u2:get_item("money") u1:clear_orders() @@ -456,14 +461,15 @@ function test_give_50_percent_of_money() u2:add_order("GIB 0 ALLES PFERD") local h = r:get_resource("horse") process_orders() - assert(r:get_resource("horse")>=h+100) - assert_equal(m1-221-10*u1.number, u1:get_item("money")) - assert_equal(m2+110-10*u2.number, u2:get_item("money")) + assert_true(r:get_resource("horse")>=h+100) + assert_equal(m1-221, u1:get_item("money")) + assert_equal(m2+110, u2:get_item("money")) end function test_give_100_percent_of_items() - local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions()) - local r = u2.region + r = region.create(0, 0, "plain") + local u1 = unit.create(faction.create("noreply@eressea.de", "human", "de"), r, 1) + local u2 = unit.create(faction.create("noreply@eressea.de", "orc", "de"), r, 1) u1.faction.age = 10 u2.faction.age = 10 u1:add_item("money", 500) From 2073e8f860670a4f7515cd1fad294a8ca2332661 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Nov 2010 18:01:46 -0800 Subject: [PATCH 20/20] http://bugs.eressea.de/view.php?id=1816 repair snowmen (xmas 2004) --- scripts/eressea/xmas2004.lua | 2 +- scripts/tests/eressea.lua | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/eressea/xmas2004.lua b/scripts/eressea/xmas2004.lua index 6a6bcfa63..92913c183 100644 --- a/scripts/eressea/xmas2004.lua +++ b/scripts/eressea/xmas2004.lua @@ -1,6 +1,6 @@ function use_snowman(u, amount) if u.region.terrain == "glacier" then - local man = add_unit(u.faction, u.region) + local man = unit.create(u.faction, u.region) man.race = "snowman" man.number = amount u:add_item("snowman", -amount) diff --git a/scripts/tests/eressea.lua b/scripts/tests/eressea.lua index 767cff742..8a0060088 100644 --- a/scripts/tests/eressea.lua +++ b/scripts/tests/eressea.lua @@ -182,3 +182,21 @@ function test_no_uruk() local f1 = faction.create("noreply@eressea.de", "uruk", "de") assert_equal(f1.race, "orc") end + +function test_snowman() + local r = region.create(0, 0, "glacier") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("snowman", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Schneemann") + process_orders() + for u2 in r.units do + if u2~=u then + assert_equal(u2.race, "snowman") + u = nil + break + end + end + assert_equal(nil, u) +end