new rules for morale

no more uruks (it's all orcs now)
This commit is contained in:
Enno Rehling 2010-03-21 23:45:18 -07:00
parent 569e38cbd4
commit be729e8856
6 changed files with 185 additions and 36 deletions

View File

@ -23,7 +23,7 @@
<familiar race="giantturtle"/> <familiar race="giantturtle"/>
</race> </race>
<race name="uruk" studyspeed="-5" magres="-0.05" maxaura="1.0" regaura="1.0" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="orc" studyspeed="-5" magres="-0.05" maxaura="1.0" regaura="1.0" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<param name="other_race" value="troll"/> <param name="other_race" value="troll"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<equipment> <equipment>
<set name="new_uruk_unit"> <set name="new_orc_unit">
<skill name="polearm" level="1"/> <skill name="polearm" level="1"/>
<skill name="melee" level="1"/> <skill name="melee" level="1"/>
</set> </set>

View File

@ -1212,7 +1212,7 @@
<familiar race="demon"/> <familiar race="demon"/>
</race> </race>
<race name="orc" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="50" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="crazy_orc" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="50" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<skill name="alchemy" modifier="1"/> <skill name="alchemy" modifier="1"/>
@ -1301,7 +1301,7 @@
<familiar race="wolf"/> <familiar race="wolf"/>
<familiar race="rat"/> <familiar race="rat"/>
</race> </race>
<race name="uruk" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="orc" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<param name="recruit_multi" value="0.5"/> <param name="recruit_multi" value="0.5"/>
<skill name="alchemy" modifier="1"/> <skill name="alchemy" modifier="1"/>

View File

@ -218,6 +218,7 @@ function test_owners()
end end
function test_taxes() function test_taxes()
set_key("test", 42)
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
r:set_resource("peasant", 1000) r:set_resource("peasant", 1000)
r:set_resource("money", 5000) r:set_resource("money", 5000)
@ -230,6 +231,7 @@ function test_taxes()
b.size = 10 b.size = 10
u.building = b u.building = b
update_owners() update_owners()
assert_equal(1, r.morale)
process_orders() process_orders()
assert_equal(1, r.morale) assert_equal(1, r.morale)
assert_equal(25, u:get_item("money")) assert_equal(25, u:get_item("money"))
@ -395,38 +397,6 @@ function test_alliance()
assert(f2.alliance~=nil) assert(f2.alliance~=nil)
end end
function test_morale()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
local b = building.create(r, "castle")
b.size = 10
u1.building = b
u2.building = b
update_owners()
assert_equal(1, r.morale)
r.morale = 5
assert_equal(r.owner, u1.faction)
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " KOMMANDO")
process_orders()
u1:clear_orders()
assert_equal(u2.faction, r.owner)
assert_equal(3, r.morale) -- 5-MORALE_TRANSFER
for u in r.units do
if u.faction.id==u2.faction.id then
u.building = nil
end
end
update_owners()
assert_equal(r.owner, u1.faction)
assert_equal(0, r.morale)
end
function test_canoe_passes_through_land() function test_canoe_passes_through_land()
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply@eressea.de", "human", "de")
local src = region.create(0, 0, "ocean") local src = region.create(0, 0, "ocean")

View File

@ -136,3 +136,8 @@ function test_can_give_person()
assert_equal(9, u2.number) assert_equal(9, u2.number)
assert_equal(11, u1.number) assert_equal(11, u1.number)
end end
function test_no_uruk()
local f1 = faction.create("noreply@eressea.de", "uruk", "de")
assert_equal(f1.race, "orc")
end

174
scripts/tests/morale.lua Normal file
View File

@ -0,0 +1,174 @@
require "lunit"
module( "e3", package.seeall, lunit.testcase )
function setup()
free_game()
end
function test_when_owner_returns_morale_drops_only_2()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 10000)
local b = building.create(r, "castle")
b.size = 50
set_turn(get_turn()+10)
u1.building = b
update_owners()
r.morale = 6
u1.building = nil
update_owners()
assert_equal(6, r.morale)
u1.building = b
update_owners()
assert_equal(4, r.morale)
end
function test_morale_alliance()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 10000)
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
u2:add_item("money", 10000)
local al = alliance.create(42, "Die Antwoord")
f1.alliance = al;
f2.alliance = al;
local b = building.create(r, "castle")
b.size = 50
u1.building = b
u2.building = b
update_owners()
r.morale = 6
local function run_a_turn()
process_orders()
f1.lastturn=get_turn()
f2.lastturn=get_turn()
end
-- just checking everything's okay after setup.
run_a_turn()
assert_equal(6, r.morale)
-- change owner, same alliance as before, but has new owner hasn't been 10 weeks in the alliance yet.
u1.building = nil
update_owners()
assert_equal(0, r.morale)
-- change owner, this time the alliance is 10 weeks old
r.morale = 6
u1.building = b
for i=1,10 do
run_a_turn()
end
assert_equal(6, r.morale)
u2.building = nil
update_owners()
assert_equal(4, r.morale)
end
function test_morale_change()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 10000)
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
u2:add_item("money", 10000)
local AVG_STEP = 6
local b = building.create(r, "castle")
b.size = 10
u1.building = b
local function run_a_turn()
process_orders()
f1.lastturn=get_turn()
f2.lastturn=get_turn()
end
-- reinhardt-regel: nach 2*AVG_STEP ist moral mindestens einmal gestiegen.
for i=1,AVG_STEP*2 do
run_a_turn()
assert_not_equal(r.owner, nil)
end
assert_not_equal(1, r.morale)
-- regel: moral ist nie hoeher als 2 punkte ueber burgen-max.
for i=1,AVG_STEP*4 do
run_a_turn()
end
assert_equal(4, r.morale)
-- auch mit herrscher faellt moral um 1 pro woche, wenn moral > burgstufe
r.morale = 6
run_a_turn()
assert_equal(5, r.morale)
run_a_turn()
assert_equal(4, r.morale)
run_a_turn()
assert_equal(4, r.morale)
-- regel: ohne herrscher fällt die moral jede woche um 1 punkt, bis sie 1 erreicht
u1.building = nil
update_owners()
run_a_turn()
assert_equal(3, r.morale)
run_a_turn()
assert_equal(2, r.morale)
run_a_turn()
assert_equal(1, r.morale)
run_a_turn()
assert_equal(1, r.morale)
-- ohne herrscher ändert sich auch beschissene Moral nicht:
r.morale = 0
run_a_turn()
assert_equal(0, r.morale)
end
function test_morale_old()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
local b = building.create(r, "castle")
b.size = 10
u1.building = b
u2.building = b
update_owners()
assert_equal(1, r.morale)
r.morale = 5
assert_equal(r.owner, u1.faction)
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " KOMMANDO")
process_orders()
u1:clear_orders()
assert_equal(u2.faction, r.owner)
assert_equal(3, r.morale) -- 5-MORALE_TRANSFER
for u in r.units do
if u.faction.id==u2.faction.id then
u.building = nil
end
end
update_owners()
assert_equal(r.owner, u1.faction)
assert_equal(0, r.morale)
end
function test_no_uruk()
local f1 = faction.create("noreply@eressea.de", "uruk", "de")
assert_equal(f1.race, "orc")
end