Merge branch 'master' of ssh://eressea_git/home/eressea/repo/eressea

This commit is contained in:
Enno Rehling 2010-12-04 14:55:18 -08:00
commit 98cdebc573
19 changed files with 316 additions and 115 deletions

3
.gitignore vendored
View File

@ -6,3 +6,6 @@ bin/
*.suo
*.sdf
*.bak
*.opensdf
ipch/
*.log

View File

@ -64,7 +64,6 @@
<order name="OPFERE" disable="yes"/>
<order name="SABOTIEREN" disable="yes"/>
<order name="SPIONIEREN" disable="yes"/>
<order name="TARNEN" disable="yes"/>
<order name="TREIBEN" disable="yes"/>
<order name="UNTERHALTEN" disable="yes"/>
<order name="VERKAUFEN" disable="yes"/>
@ -131,7 +130,8 @@
<param name="world.era" value="3"/>
<param name="rules.migrants" value="0"/>
<param name="rules.transfermen" value="0"/>
<param name="rules.stealth.faction" value="0"/>
<param name="rules.stealth.faction" value="1"/>
<param name="rules.stealth.anon_battle" value="0"/>
<param name="rules.check_overload" value="0"/>
<param name="rules.combat.goblinbonus" value="3"/>
<param name="rules.ship.damage_drift" value="0.00"/> <!-- percent damage from drifting-->

View File

@ -100,7 +100,8 @@
<param name="hunger.long" value="1"/>
<param name="init_spells" value="0"/>
<param name="rules.check_overload" value="0"/>
<param name="rules.limit.faction" value="1500"/>
<param name="rules.limit.faction" value="2500"/>
<param name="rules.maxskills.magic" value="5"/>
</game>
<strings>
<string name="mailto">

View File

@ -3,6 +3,7 @@
<ship name="canoe" nocoast="true" range="3" fishing="20" storm="1.00" damage="1.00" cabins="2" cargo="2000" cptskill="1" minskill="1" sumskill="2" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<coast terrain="swamp"/>
<coast terrain="desert"/>
<coast terrain="highland"/>
@ -10,8 +11,6 @@
<coast terrain="glacier"/>
<coast terrain="volcano"/>
<coast terrain="activevolcano"/>
<coast terrain="iceberg_sleep"/>
<coast terrain="iceberg"/>
<construction skill="shipcraft" minskill="1" maxsize="3" reqsize="1">
<requirement type="log" quantity="1"/>
</construction>
@ -20,6 +19,7 @@
<ship name="raft" range="1" fishing="20" storm="1.00" damage="1.00" cabins="5" cargo="50000" cptskill="1" minskill="1" sumskill="5" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<coast terrain="swamp"/>
<coast terrain="desert"/>
<construction skill="shipcraft" minskill="1" maxsize="10" reqsize="1">
@ -30,6 +30,7 @@
<ship name="cutter" range="2" fishing="20" storm="1.00" damage="1.00" cabins="5" cargo="5500" cptskill="2" minskill="1" sumskill="5" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<coast terrain="swamp"/>
<coast terrain="desert"/>
<coast terrain="highland"/>
@ -37,8 +38,6 @@
<coast terrain="glacier"/>
<coast terrain="volcano"/>
<coast terrain="activevolcano"/>
<coast terrain="iceberg_sleep"/>
<coast terrain="iceberg"/>
<construction skill="shipcraft" minskill="2" maxsize="10" reqsize="1">
<requirement type="log" quantity="1"/>
</construction>
@ -47,6 +46,7 @@
<ship name="barge" range="3" fishing="20" storm="1.00" damage="1.00" cabins="11" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<coast terrain="swamp"/>
<coast terrain="desert"/>
<coast terrain="highland"/>
@ -54,8 +54,6 @@
<coast terrain="glacier"/>
<coast terrain="volcano"/>
<coast terrain="activevolcano"/>
<coast terrain="iceberg_sleep"/>
<coast terrain="iceberg"/>
<construction skill="shipcraft" minskill="2" maxsize="10" reqsize="1">
<requirement type="log" quantity="1"/>
</construction>
@ -65,6 +63,7 @@
<ship name="royalbarge" range="5" storm="0.25" damage="1.00" cabins="11" cargo="5000" cptskill="5" minskill="1" sumskill="10" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<coast terrain="swamp"/>
<coast terrain="desert"/>
<coast terrain="highland"/>
@ -72,8 +71,6 @@
<coast terrain="glacier"/>
<coast terrain="volcano"/>
<coast terrain="activevolcano"/>
<coast terrain="iceberg_sleep"/>
<coast terrain="iceberg"/>
<construction skill="shipcraft" minskill="6" maxsize="10" reqsize="1">
<requirement type="mallorn" quantity="1"/>
<requirement type="money" quantity="100"/>
@ -83,6 +80,7 @@
<ship name="catamaran" range="7" storm="0.25" damage="1.00" cabins="22" cargo="10000" cptskill="7" minskill="1" sumskill="20" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<construction skill="shipcraft" minskill="8" maxsize="30" reqsize="1">
<requirement type="mallorn" quantity="1"/>
<requirement type="money" quantity="100"/>
@ -93,6 +91,7 @@
<ship name="cog" range="4" storm="0.50" damage="1.00" cabins="50" cargo="200000" cptskill="4" minskill="1" sumskill="20" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<construction skill="shipcraft" minskill="4" maxsize="100" reqsize="1">
<requirement type="log" quantity="1"/>
</construction>
@ -101,6 +100,7 @@
<ship name="caravel" range="4" storm="0.50" damage="1.00" cabins="150" cargo="600000" cptskill="6" minskill="1" sumskill="30" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<construction skill="shipcraft" minskill="6" maxsize="300" reqsize="1">
<requirement type="log" quantity="1"/>
</construction>
@ -111,6 +111,7 @@
<modifier type="defense" value="+2"/>
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<construction skill="shipcraft" minskill="5" maxsize="100" reqsize="1">
<requirement type="log" quantity="1"/>
<requirement type="money" quantity="10"/>
@ -121,6 +122,7 @@
<modifier type="defense" value="+2"/>
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<construction skill="shipcraft" minskill="7" maxsize="300" reqsize="1">
<requirement type="log" quantity="1"/>
<requirement type="money" quantity="10"/>
@ -133,6 +135,7 @@
<modifier type="tactics" factor="2.00"/>
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<construction skill="shipcraft" minskill="5" maxsize="100" reqsize="1">
<requirement type="log" quantity="1"/>
<requirement type="money" quantity="10"/>
@ -144,6 +147,7 @@
<modifier type="tactics" factor="2.00"/>
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="packice"/>
<construction skill="shipcraft" minskill="7" maxsize="300" reqsize="1">
<requirement type="log" quantity="1"/>
<requirement type="money" quantity="10"/>

View File

@ -13,6 +13,15 @@
<text locale="en">the third age</text>
</string>
<string name="packice">
<text locale="de">Packeis</text>
<text locale="en">fast ice</text>
</string>
<string name="packice_trail">
<text locale="de">%s</text>
<text locale="en">%s</text>
</string>
<string name="rpg_item_1_p">
<text locale="de">Urkunden</text>
<text locale="en">Certificates</text>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<terrains>
<!-- defaults: walk="yes" sail="yes" fly="yes" shallow="yes" swim="no" forest="no" sea="no" land="yes" forbidden="no" arctic="no" cavalry="no" size="0" -->
<!-- defaults: build="yes" walk="yes" sail="yes" fly="yes" shallow="yes" swim="no" forest="no" sea="no" land="yes" forbidden="no" arctic="no" cavalry="no" size="0" -->
<terrain name="ocean" size="100" shallow="no" walk="no" swim="yes" land="no" sea="yes" />
<terrain name="plain" size="4000" road="50" shallow="no" forest="yes" cavalry="yes" seed="3">
<herb name="h0" />
@ -44,19 +44,7 @@
<resource name="stone" chance="1.0" level="1" base="2" div="100" />
<resource name="laen" chance="0.05" level="1" base="4" div="100" />
</terrain>
<terrain name="iceberg_sleep" size="150" road="250" arctic="yes">
<herb name="h18" />
<herb name="h20" />
<resource name="iron" chance="0.9" level="1" base="3" div="50" />
<resource name="stone" chance="0.9" level="1" base="2" div="100" />
<resource name="laen" chance="0.05" level="1" base="4" div="100" />
</terrain>
<terrain name="iceberg" size="150" arctic="yes">
<herb name="h18" />
<herb name="h20" />
<resource name="iron" chance="0.9" level="1" base="3" div="50" />
<resource name="stone" chance="0.9" level="1" base="2" div="100" />
</terrain>
<terrain name="packice" land="no" arctic="yes" swim="yes"/>
<terrain name="firewall" road="250" land="no" walk="no" sail="no" fly="no" forbidden="yes" />
<terrain name="fog" sail="no" land="no" />
<terrain name="thickfog" forbidden="yes" sail="no" walk="no" fly="no" land="no" />

View File

@ -292,7 +292,7 @@
<spell name="song_suscept_magic" type="cerddor" rank="2" level="12" index="101" far="true" variable="true">
<resource name="aura" amount="2" cost="level"/>
</spell>
<spell name="analyze_magic" type="tybied" rank="5" level="1" index="102" parameters="kc?" los="true" ship="true" variable="true">
<spell name="analyze_magic" type="tybied" rank="5" level="1" index="102" parameters="kc+" los="true" ship="true" variable="true">
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="analysedream" type="illaun" rank="5" level="5" index="103" parameters="u" los="true" ship="true">
@ -301,10 +301,10 @@
<spell name="analysesong_unit" type="cerddor" rank="5" level="5" index="104" parameters="u" los="true" ship="true">
<resource name="aura" amount="10" cost="fixed"/>
</spell>
<spell name="analyse_object" type="cerddor" rank="5" level="8" index="105" parameters="kc?" ship="true" variable="true">
<spell name="analyse_object" type="cerddor" rank="5" level="8" index="105" parameters="kc+" ship="true" variable="true">
<resource name="aura" amount="3" cost="level"/>
</spell>
<spell name="destroy_magic" type="tybied" rank="2" level="5" index="106" parameters="kc?" los="true" ship="true" far="true" variable="true">
<spell name="destroy_magic" type="tybied" rank="2" level="5" index="106" parameters="kc+" los="true" ship="true" far="true" variable="true">
<resource name="aura" amount="4" cost="level"/>
</spell>
<spell name="break_curse" type="tybied" rank="3" level="7" index="107" syntax="spellid" parameters="kcc?" los="true" ship="true" far="true" variable="true">
@ -368,16 +368,16 @@
<spell name="icastle" type="illaun" rank="5" level="3" index="137" syntax="buildingtype" parameters="c">
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="gwyrrddestroymagic" type="gwyrrd" rank="2" level="8" index="138" parameters="kc?" los="true" ship="true" far="true" variable="true">
<spell name="gwyrrddestroymagic" type="gwyrrd" rank="2" level="8" index="138" parameters="kc+" los="true" ship="true" far="true" variable="true">
<resource name="aura" amount="6" cost="level"/>
</spell>
<spell name="draigdestroymagic" type="draig" rank="2" level="10" index="139" parameters="kc?" los="true" ship="true" far="true" variable="true">
<spell name="draigdestroymagic" type="draig" rank="2" level="10" index="139" parameters="kc+" los="true" ship="true" far="true" variable="true">
<resource name="aura" amount="10" cost="level"/>
</spell>
<spell name="illaundestroymagic" type="illaun" rank="2" level="8" index="140" parameters="kc?" los="true" ship="true" far="true" variable="true">
<spell name="illaundestroymagic" type="illaun" rank="2" level="8" index="140" parameters="kc+" los="true" ship="true" far="true" variable="true">
<resource name="aura" amount="6" cost="level"/>
</spell>
<spell name="cerddor_destroymagic" type="cerddor" rank="2" level="8" index="141" parameters="kc?" los="true" ship="true" far="true" variable="true">
<spell name="cerddor_destroymagic" type="cerddor" rank="2" level="8" index="141" parameters="kc+" los="true" ship="true" far="true" variable="true">
<resource name="aura" amount="5" cost="level"/>
</spell>
<spell name="barkskin" type="gwyrrd" rank="2" level="12" index="142" variable="true" combat="1">

52
scripts/e3a/frost.lua Normal file
View File

@ -0,0 +1,52 @@
module('frost', package.seeall)
local function is_winter(turn)
local season = get_season(turn)
return season == "calendar::winter"
end
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 (chance>=100 or math.mod(rng_int(), 100)<chance) then
rn.terrain = "packice"
end
end
end
local function thaw(r, chance)
if chance>=100 or math.mod(rng_int(), 100)<chance then
r.terrain = "ocean"
for s in r.ships do
s.coast = nil
end
end
end
function update()
local turn = get_turn()
if is_winter(turn) then
for r in regions() do
if r.terrain=="glacier" then
freeze(r, 20)
end
end
elseif is_spring(turn) then
for r in regions() do
if r.terrain=="packice" then
thaw(r, 20)
end
end
elseif is_spring(turn-1) then
for r in regions() do
if r.terrain=="packice" then
thaw(r, 100)
end
end
end
end

View File

@ -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)

View File

@ -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',
}

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)
@ -48,6 +49,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
@ -406,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)
@ -420,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()
@ -443,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)
@ -552,43 +571,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

View File

@ -4,6 +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()
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()
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()
@ -79,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")
@ -142,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

42
scripts/tests/stealth.lua Normal file
View File

@ -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

View File

@ -11,7 +11,7 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>amalgamation-eressea</ProjectName>
<ProjectName>eressea</ProjectName>
<ProjectGuid>{AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}</ProjectGuid>
<RootNamespace>build</RootNamespace>
<Keyword>Win32Proj</Keyword>
@ -186,4 +186,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -53,35 +53,35 @@
<ClCompile Include="spells\spells.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\server\src\tests.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="spells\unitcurse.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="races\zombies.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\server\src\build\external.c">
<Filter>Unity Build</Filter>
</ClCompile>
<ClCompile Include="..\..\server\src\build\gamecode.c">
<Filter>Unity Build</Filter>
</ClCompile>
<ClCompile Include="..\..\server\src\build\kernel.c">
<Filter>Unity Build</Filter>
</ClCompile>
<ClCompile Include="..\..\server\src\build\lib.c">
<Filter>Unity Build</Filter>
</ClCompile>
<ClCompile Include="server.c">
<Filter>Unity Build</Filter>
</ClCompile>
<ClCompile Include="..\..\server\src\build\stdafx.c">
<Filter>Unity Build</Filter>
<ClCompile Include="..\..\shared\src\tests.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\server\src\build\util.c">
<Filter>Unity Build</Filter>
<ClCompile Include="..\..\shared\src\build\external.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\shared\src\build\gamecode.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\shared\src\build\kernel.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\shared\src\build\lib.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\shared\src\build\stdafx.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\shared\src\build\util.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@ -106,15 +106,15 @@
<ClInclude Include="spells\spells.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\server\src\build\stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\server\src\tests.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="spells\unitcurse.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\shared\src\build\stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\shared\src\tests.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="spells\Jamfile" />

View File

@ -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);
}