forked from github/server
Bug 2407: do not cache study_cost(SK_MAGIC).
This commit is contained in:
parent
8e9ffa2d2b
commit
2cf20dd6e2
2 changed files with 20 additions and 4 deletions
|
@ -140,7 +140,8 @@ int study_cost(struct unit *u, skill_t sk)
|
||||||
int next_level = 1 + (u ? get_level(u, sk) : 0);
|
int next_level = 1 + (u ? get_level(u, sk) : 0);
|
||||||
/* Die Magiekosten betragen 50+Summe(50*Stufe) */
|
/* Die Magiekosten betragen 50+Summe(50*Stufe) */
|
||||||
/* 'Stufe' ist dabei die naechste zu erreichende Stufe */
|
/* 'Stufe' ist dabei die naechste zu erreichende Stufe */
|
||||||
cost = 50 * (1 + ((next_level + 1) * next_level / 2));
|
cost = config_get_int("skills.cost.magic", 50);
|
||||||
|
return cost * (1 + ((next_level + next_level * next_level) / 2));
|
||||||
}
|
}
|
||||||
else switch (sk) {
|
else switch (sk) {
|
||||||
case SK_SPY:
|
case SK_SPY:
|
||||||
|
|
|
@ -418,11 +418,26 @@ static void test_study_magic(CuTest *tc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_study_cost_magic(CuTest *tc) {
|
static void test_study_cost_magic(CuTest *tc) {
|
||||||
|
unit * u;
|
||||||
|
const struct item_type *itype;
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
config_set("skills.cost.magic", "50");
|
itype = test_create_silver();
|
||||||
CuAssertIntEquals(tc, 50, study_cost(NULL, SK_MAGIC));
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, 100, study_cost(u, SK_MAGIC));
|
||||||
|
set_level(u, SK_MAGIC, 1);
|
||||||
|
CuAssertIntEquals(tc, 200, study_cost(u, SK_MAGIC));
|
||||||
|
set_level(u, SK_MAGIC, 2);
|
||||||
|
CuAssertIntEquals(tc, 350, study_cost(u, SK_MAGIC));
|
||||||
|
set_level(u, SK_MAGIC, 29);
|
||||||
|
CuAssertIntEquals(tc, 23300, study_cost(u, SK_MAGIC));
|
||||||
|
set_level(u, SK_MAGIC, 27);
|
||||||
|
CuAssertIntEquals(tc, 20350, study_cost(u, SK_MAGIC));
|
||||||
|
|
||||||
config_set("skills.cost.magic", "100");
|
config_set("skills.cost.magic", "100");
|
||||||
CuAssertIntEquals(tc, 100, study_cost(NULL, SK_MAGIC));
|
CuAssertIntEquals(tc, 2*20350, study_cost(u, SK_MAGIC));
|
||||||
|
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue