forked from github/server
Merge branch 'master' of github.com:eressea/server
This commit is contained in:
commit
5d3f51178e
|
@ -5519,7 +5519,7 @@ msgstr "aquarians"
|
|||
|
||||
msgctxt "iteminfo"
|
||||
msgid "fairyboot"
|
||||
msgstr "These leather boots are embroidere with unicorn hair and allow their wearer to walk at twice his normal speed."
|
||||
msgstr "These leather boots are embroidered with unicorn hair and allow their wearer to walk at twice his normal speed."
|
||||
|
||||
msgctxt "spell"
|
||||
msgid "skillmod"
|
||||
|
|
|
@ -29,6 +29,25 @@ function test_castle_names()
|
|||
assert_equal("citadel", b:get_typename(6250))
|
||||
end
|
||||
|
||||
function test_build_tunnel_limited()
|
||||
-- bug 2221
|
||||
local r = region.create(0, 0, "plain")
|
||||
local b = building.create(r, "tunnel")
|
||||
local f = faction.create('human')
|
||||
local u = unit.create(f, r, 2)
|
||||
u:set_skill('building', 6, true)
|
||||
u:add_item('stone', 22)
|
||||
u:add_item('log', 10)
|
||||
u:add_item('iron', 2)
|
||||
u:add_item('money', 700)
|
||||
u.building = b
|
||||
u.name = 'Xolgrim'
|
||||
u:add_order('MACHE 2 BURG ' .. itoa36(b.id))
|
||||
b.size = 99
|
||||
process_orders()
|
||||
assert_equal(100, b.size)
|
||||
end
|
||||
|
||||
function test_build_castle_one_stage()
|
||||
local r = region.create(0, 0, 'plain')
|
||||
local f = faction.create('human')
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
require 'tests.e2.buildings'
|
||||
require 'tests.e2.allies'
|
||||
require 'tests.e2.quit'
|
||||
require 'tests.e2.movement'
|
||||
require 'tests.e2.carts'
|
||||
require 'tests.e2.quit'
|
||||
|
@ -5,7 +8,6 @@ require 'tests.e2.astral'
|
|||
require 'tests.e2.spells'
|
||||
require 'tests.e2.e2features'
|
||||
require 'tests.e2.insects'
|
||||
require 'tests.e2.buildings'
|
||||
require 'tests.e2.production'
|
||||
require 'tests.e2.adamantium'
|
||||
require 'tests.e2.undead'
|
||||
|
|
|
@ -1495,7 +1495,7 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
|
|||
bool unlimited = true;
|
||||
const item_type *itype;
|
||||
const luxury_type *ltype;
|
||||
int n, i;
|
||||
int n, k;
|
||||
region *r = u->region;
|
||||
const char *s;
|
||||
keyword_t kwd;
|
||||
|
@ -1546,8 +1546,9 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
|
|||
}
|
||||
/* Ein Haendler kann nur 10 Gueter pro Talentpunkt verkaufen. */
|
||||
|
||||
i = u->number * 10 * effskill(u, SK_TRADE, NULL);
|
||||
if (n > i) n = i;
|
||||
/* Ein Haendler kann nur 10 Gueter pro Talentpunkt handeln. */
|
||||
k = u->number * 10 * effskill(u, SK_TRADE, NULL);
|
||||
if (n > k) n = k;
|
||||
|
||||
if (!n) {
|
||||
cmistake(u, ord, 54, MSG_COMMERCE);
|
||||
|
@ -1563,7 +1564,7 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
|
|||
else {
|
||||
attrib *a;
|
||||
econ_request *o;
|
||||
int k, available;
|
||||
int available;
|
||||
|
||||
if (!r->land || !r_demand(r, ltype)) {
|
||||
cmistake(u, ord, 263, MSG_COMMERCE);
|
||||
|
@ -1594,9 +1595,6 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
|
|||
* produktion, wo fuer jedes produkt einzeln eine obere limite
|
||||
* existiert, so dass man arrays von orders machen kann. */
|
||||
|
||||
/* Ein Haendler kann nur 10 Gueter pro Talentpunkt handeln. */
|
||||
k = u->number * 10 * effskill(u, SK_TRADE, NULL);
|
||||
|
||||
/* hat der Haendler bereits gehandelt, muss die Menge der bereits
|
||||
* verkauften/gekauften Gueter abgezogen werden */
|
||||
a = a_find(u->attribs, &at_trades);
|
||||
|
|
|
@ -209,7 +209,7 @@ static void setup_terrains(CuTest *tc) {
|
|||
static region *setup_trade_region(CuTest *tc, const struct terrain_type *terrain) {
|
||||
region *r;
|
||||
item_type *it_luxury;
|
||||
struct locale * lang = default_locale;
|
||||
struct locale * lang = test_create_locale();
|
||||
|
||||
new_luxurytype(it_luxury = test_create_itemtype("balm"), 5);
|
||||
locale_setstring(lang, it_luxury->rtype->_name, it_luxury->rtype->_name);
|
||||
|
@ -233,6 +233,36 @@ static unit *setup_trade_unit(CuTest *tc, region *r, const struct race *rc) {
|
|||
return u;
|
||||
}
|
||||
|
||||
static void test_trade_limits(CuTest *tc) {
|
||||
region *r;
|
||||
unit *u;
|
||||
building *b;
|
||||
const item_type *it_jewel, *it_balm;
|
||||
|
||||
test_setup();
|
||||
setup_production();
|
||||
setup_terrains(tc);
|
||||
init_terrains();
|
||||
r = setup_trade_region(tc, NULL);
|
||||
b = test_create_building(r, test_create_buildingtype("castle"));
|
||||
b->size = 2;
|
||||
rsetpeasants(r, TRADE_FRACTION * 20);
|
||||
it_jewel = it_find("jewel");
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
set_level(u, SK_TRADE, 1);
|
||||
i_change(&u->items, it_find("money"), 500);
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "5 %s",
|
||||
LOC(u->faction->locale, resourcename(it_jewel->rtype, 0))));
|
||||
it_balm = it_find("balm");
|
||||
i_change(&u->items, it_balm, 10);
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, "10 %s",
|
||||
LOC(u->faction->locale, resourcename(it_balm->rtype, 0))));
|
||||
produce(r);
|
||||
CuAssertIntEquals(tc, 5, i_get(u->items, it_jewel));
|
||||
CuAssertIntEquals(tc, 5, i_get(u->items, it_balm));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_trade_needs_castle(CuTest *tc) {
|
||||
/* Handeln ist nur in Regionen mit Burgen möglich. */
|
||||
race *rc;
|
||||
|
@ -837,6 +867,7 @@ CuSuite *get_economy_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_heroes_dont_recruit);
|
||||
SUITE_ADD_TEST(suite, test_tax_cmd);
|
||||
SUITE_ADD_TEST(suite, test_buy_cmd);
|
||||
SUITE_ADD_TEST(suite, test_trade_limits);
|
||||
SUITE_ADD_TEST(suite, test_trade_needs_castle);
|
||||
SUITE_ADD_TEST(suite, test_trade_insect);
|
||||
SUITE_ADD_TEST(suite, test_maintain_buildings);
|
||||
|
|
|
@ -810,25 +810,13 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
|||
}
|
||||
built = b->size;
|
||||
}
|
||||
if (n <= 0 || n == INT_MAX) {
|
||||
if (b == NULL) {
|
||||
if (btype->maxsize > 0) {
|
||||
n = btype->maxsize - built;
|
||||
}
|
||||
else {
|
||||
n = INT_MAX;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (b->type->maxsize > 0) {
|
||||
n = b->type->maxsize - built;
|
||||
}
|
||||
else {
|
||||
n = INT_MAX;
|
||||
}
|
||||
|
||||
if (btype->maxsize > 0) {
|
||||
int remain = btype->maxsize - built;
|
||||
if (remain < n) {
|
||||
n = remain;
|
||||
}
|
||||
}
|
||||
|
||||
built = build_stages(u, btype, built, n, basesk, &skills);
|
||||
|
||||
if (built < 0) {
|
||||
|
|
Loading…
Reference in New Issue