trade 2:1 except money

dwarven/halfling armor
remove stone and metal bonus for dwarves
This commit is contained in:
Enno Rehling 2010-02-09 03:47:31 +00:00
parent a90235aa3c
commit 8553d0083b
7 changed files with 65 additions and 24 deletions

View File

@ -85,12 +85,18 @@ add_give(unit * u, unit * u2, int given, int received, const resource_type * rty
}
}
static boolean
limited_give(const item_type * type)
{
/* trade only money 2:1, if at all */
return (type == i_silver);
}
int give_quota(const unit * src, const unit * dst, const item_type * type, int n)
{
static float divisor = -1;
/* luxuries and herbs are traded 1:1 */
if (fval(type, ITF_HERB) || type->rtype->ltype) {
if (divisor==0 || !limited_give(type)) {
return n;
}
if (dst && src && src->faction!=dst->faction) {
@ -100,15 +106,7 @@ int give_quota(const unit * src, const unit * dst, const item_type * type, int n
}
if (divisor>=1) {
/* predictable > correct: */
#if 0
double r = n / divisor;
int x = (int)r;
r = r - x;
if (chance(r)) ++x;
#else
int x = (int)(n/divisor);
#endif
return x;
}
}

View File

@ -1,11 +1,11 @@
<?xml version="1.0"?>
<resource name="scale">
<item weight="400" score="150">
<item weight="300" score="150">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="armorer" minskill="4" reqsize="1">
<construction skill="armorer" minskill="5" reqsize="1">
<modifier function="mod_dwarves_only"/>
<requirement type="iron" quantity="2"/>
</construction>
<armor ac="3" penalty="0.15" projectile="0.10" magres="0.0"/>
<armor ac="3" penalty="0.10" projectile="0.05" magres="0.0"/>
</item>
</resource>

View File

@ -147,9 +147,9 @@
<param name="rules.combat.herospeed" value="3"/>
<param name="rules.combat.demon_vampire" value="5"/> <!-- regen 1 hp per X points of damage done -->
<param name="rules.combat.skill_bonus" value="0"/>
<param name="rules.combat.loot" value="5"/> <!-- only self + others - keeploot -->
<param name="rules.items.loot_divisor" value="4"/> <!-- damage skims off 3/4 of goods transfers -->
<param name="rules.items.give_divisor" value="3"/> <!-- corruption skims off 2/3 of goods transfers -->
<!--param name="rules.combat.loot" value="5"/--> <!-- only self + others - keeploot -->
<param name="rules.items.loot_divisor" value="2"/> <!-- damage skims off 1/2 of goods transfers -->
<param name="rules.items.give_divisor" value="2"/> <!-- corruption skims off 1/2 of goods transfers -->
<param name="rules.move.owner_leave" value="1"/> <!-- owner must leave before moving -->
<param name="rules.cavalry.skill" value="2"/>
<param name="rules.cavalry.mode" value="1"/>
@ -161,7 +161,7 @@
<param name="rules.magic.common" value="tybied"/> <!-- tybied spells can be cast by anyone -->
<param name="rules.magic.elfpower" value="1"/> <!-- elves get ring-of-power bonus in a forest -->
<param name="rules.magic.playerschools" value="gwyrrd illaun draig cerddor"/>
<param name="rules.build.other_buildings" value="0"/>
<param name="rules.build.other_buildings" value="1"/>
<param name="rules.economy.taxation" value="1"/>
<param name="rules.economy.food" value="2"/>
<param name="rules.economy.wages" value="1"/>

View File

@ -7,5 +7,6 @@
<xi:include href="../armor/rustychainmail-2.xml"/>
<xi:include href="../armor/rustyshield-2.xml"/>
<xi:include href="../armor/shield-2.xml"/>
<xi:include href="../armor/scale.xml"/>
<xi:include href="../armor/towershield.xml"/>
</resources>

View File

@ -2,8 +2,10 @@
<resources xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- this file contains resources that can be mined in some way (anything with a resourcelimit) -->
<xi:include href="../resources/iron.xml"/>
<xi:include href="../resources/stone-2.xml"/>
<!--xi:include href="../resources/iron.xml"/-->
<!--xi:include href="../resources/stone-2.xml"/-->
<xi:include href="../resources/iron-nobonus.xml"/>
<xi:include href="../resources/stone-nobonus.xml"/>
<xi:include href="../resources/laen.xml"/>
<xi:include href="../resources/horse.xml"/>
<xi:include href="../resources/mallorn.xml"/>

View File

@ -583,3 +583,24 @@ function test_storage()
assert(u)
assert(u:get_item("money") == u.number * 100)
end
function test_building_other()
local r = region.create(0,0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local f2 = faction.create("noreply@eressea.de", "human", "de")
local b = building.create(r, "castle")
b.size = 10
local u1 = unit.create(f1, r, 3)
u1.building = b
u1:add_item("money", 100)
local u2 = unit.create(f2, r, 3)
u2:set_skill("building", 10)
u2:add_item("money", 100)
u2:add_item("stone", 100)
u2:clear_orders()
u2:add_order("MACHEN BURG " .. itoa36(b.id))
update_owners()
process_orders()
assert_not_equal(10, b.size)
end

View File

@ -412,7 +412,7 @@ function test_canoe_passes_through_land()
assert_equal(u2.region.id, dst.id, "canoe could not leave coast")
end
function test_give_only_a_third_of_items()
function test_give_50_percent_of_money()
local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions())
local r = u2.region
u1.faction.age = 10
@ -420,7 +420,7 @@ function test_give_only_a_third_of_items()
u1: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) .. " 332 Silber")
u1:add_order("GIB " .. itoa36(u2.id) .. " 221 Silber")
u2:clear_orders()
u2:add_order("LERNEN Hiebwaffen")
process_orders()
@ -429,14 +429,33 @@ function test_give_only_a_third_of_items()
m1, m2 = u1:get_item("money"), u2:get_item("money")
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " 332 Silber")
u1:add_order("GIB " .. itoa36(u2.id) .. " 221 Silber")
u2:clear_orders()
u2:add_order("HELFE " .. itoa36(u1.faction.id) .. " GIB")
u2:add_order("HELFEN " .. itoa36(u1.faction.id) .. " GIB")
u2:add_item("horse", 100)
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-332-10*u1.number, u1:get_item("money"))
assert_equal(m1-221-10*u1.number, u1:get_item("money"))
assert_equal(m2+110-10*u2.number, u2:get_item("money"))
end
function test_give_100_percent_of_items()
free_game()
local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions())
local r = u2.region
u1.faction.age = 10
u2.faction.age = 10
u1:add_item("money", 500)
u1:add_item("log", 500)
local m1, m2 = u1:get_item("log"), u2:get_item("log")
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " 332 Holz")
u2:clear_orders()
u2:add_order("LERNEN Hiebwaffen")
u2:add_order("HELFEN " .. itoa36(u1.faction.id) .. " GIB")
process_orders()
assert_equal(m1-332, u1:get_item("log"))
assert_equal(m2+332, u2:get_item("log"))
end