diff --git a/src/study.c b/src/study.c index 561e5b9cb..c5d657c48 100644 --- a/src/study.c +++ b/src/study.c @@ -140,7 +140,8 @@ int study_cost(struct unit *u, skill_t sk) int next_level = 1 + (u ? get_level(u, sk) : 0); /* Die Magiekosten betragen 50+Summe(50*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) { case SK_SPY: diff --git a/src/study.test.c b/src/study.test.c index 7e790eee7..3bea76b86 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -418,11 +418,26 @@ static void test_study_magic(CuTest *tc) { } static void test_study_cost_magic(CuTest *tc) { + unit * u; + const struct item_type *itype; + test_setup(); - config_set("skills.cost.magic", "50"); - CuAssertIntEquals(tc, 50, study_cost(NULL, SK_MAGIC)); + itype = test_create_silver(); + 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"); - CuAssertIntEquals(tc, 100, study_cost(NULL, SK_MAGIC)); + CuAssertIntEquals(tc, 2*20350, study_cost(u, SK_MAGIC)); + test_teardown(); }