diff --git a/src/academy.c b/src/academy.c index 9f42c0e4c..c25ea2476 100644 --- a/src/academy.c +++ b/src/academy.c @@ -25,9 +25,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "academy.h" #include "study.h" -void academy_teaching_bonus(struct unit *u, skill_t sk, int academy) { - if (academy && sk != NOSKILL) { - learn_skill(u, sk, academy); +void academy_teaching_bonus(struct unit *u, skill_t sk, int student_days) { + if (student_days && sk != NOSKILL) { + /* actually days / STUDYDAYS * EXPERIENCEDAYS / MAX_STUDENTS */ + learn_skill(u, sk, student_days / STUDYDAYS); } } diff --git a/src/items/xerewards.c b/src/items/xerewards.c index e39608a16..e9a11d00d 100644 --- a/src/items/xerewards.c +++ b/src/items/xerewards.c @@ -54,6 +54,7 @@ struct order *ord) for (n = 0; n != amount; ++n) { skill *sv = u->skills; while (sv != u->skills + u->skill_size) { + /* only one person learns for 3 weeks */ learn_skill(u, (skill_t)sv->id, STUDYDAYS * 3); ++sv; } diff --git a/src/items/xerewards.test.c b/src/items/xerewards.test.c index ea9f53fde..5739141c0 100644 --- a/src/items/xerewards.test.c +++ b/src/items/xerewards.test.c @@ -31,17 +31,17 @@ static void test_skillpotion(CuTest *tc) { itype = test_create_itemtype("skillpotion"); change_resource(u, itype->rtype, 2); - learn_skill(u, SK_ENTERTAINMENT, STUDYDAYS); + learn_skill(u, SK_ENTERTAINMENT, STUDYDAYS * u->number); pSkill = unit_skill(u, SK_ENTERTAINMENT); sk_set(pSkill, 5); initialWeeks_Entertainment = pSkill->weeks = 4; - learn_skill(u, SK_STAMINA, STUDYDAYS); + learn_skill(u, SK_STAMINA, STUDYDAYS * u->number); pSkill = unit_skill(u, SK_STAMINA); sk_set(pSkill, 5); initialWeeks_Stamina = pSkill->weeks = 4; - learn_skill(u, SK_MAGIC, STUDYDAYS); + learn_skill(u, SK_MAGIC, STUDYDAYS * u->number); pSkill = unit_skill(u, SK_MAGIC); sk_set(pSkill, 5); initialWeeks_Magic = pSkill->weeks = 4; diff --git a/src/study.c b/src/study.c index 56a9bf913..ddded23cc 100644 --- a/src/study.c +++ b/src/study.c @@ -484,7 +484,7 @@ int teach_cmd(unit * teacher, struct order *ord) } if (academy && sk_academy!=NOSKILL) { assert(academy % STUDYDAYS == 0); - academy_teaching_bonus(teacher, sk_academy, academy / STUDYDAYS); + academy_teaching_bonus(teacher, sk_academy, academy); } return 0; } @@ -842,7 +842,7 @@ void produceexp_ex(struct unit *u, skill_t sk, int n, learn_fun learn) assert(u && n <= u->number); if (n > 0 && (is_monsters(u->faction) || playerrace(u_race(u)))) { int days = produceexp_days(); - learn(u, sk, days * n / u->number); + learn(u, sk, days * n); } } @@ -858,6 +858,7 @@ void inject_learn(learn_fun fun) { inject_learn_fun = fun; } #endif +/** days should be scaled by u->number; STUDYDAYS * u->number is one week worth of learning */ void learn_skill(unit *u, skill_t sk, int days) { int leveldays = STUDYDAYS * u->number; int weeks = 0; @@ -929,7 +930,7 @@ void demon_skillchange(unit *u) } } else { - learn_skill(u, sv->id, STUDYDAYS*weeks); + learn_skill(u, sv->id, STUDYDAYS * u->number * weeks); } } ++sv; diff --git a/src/study.test.c b/src/study.test.c index 74104704b..c0b58b493 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -184,12 +184,12 @@ static CuTest *g_tc; static void cb_learn_one(unit *u, skill_t sk, int days) { CuAssertIntEquals(g_tc, SK_ALCHEMY, sk); - CuAssertIntEquals(g_tc, 10, days); + CuAssertIntEquals(g_tc, 20, days); } static void cb_learn_two(unit *u, skill_t sk, int days) { CuAssertIntEquals(g_tc, SK_ALCHEMY, sk); - CuAssertIntEquals(g_tc, 20, days); + CuAssertIntEquals(g_tc, 40, days); } static void test_produceexp(CuTest *tc) { @@ -247,7 +247,7 @@ static void test_academy_building(CuTest *tc) { CuAssertPtrEquals(tc, u, log_learners[0].u); CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk); - CuAssertIntEquals(tc, 15, log_learners[0].days); + CuAssertIntEquals(tc, u1->number, log_learners[0].days); test_cleanup(); } @@ -377,7 +377,7 @@ static void test_study_cost(CuTest *tc) { learn_reset(); CuAssertPtrEquals(tc, u, log_learners[0].u); CuAssertIntEquals(tc, SK_ALCHEMY, log_learners[0].sk); - CuAssertIntEquals(tc, STUDYDAYS*u->number, log_learners[0].days); + CuAssertIntEquals(tc, STUDYDAYS * u->number, log_learners[0].days); CuAssertIntEquals(tc, 0, i_get(u->items, itype)); test_cleanup(); } @@ -405,7 +405,7 @@ static void test_teach_magic(CuTest *tc) { learn_reset(); CuAssertPtrEquals(tc, u, log_learners[0].u); CuAssertIntEquals(tc, SK_MAGIC, log_learners[0].sk); - CuAssertIntEquals(tc, STUDYDAYS*2, log_learners[0].days); + CuAssertIntEquals(tc, STUDYDAYS * 2, log_learners[0].days); CuAssertIntEquals(tc, 0, i_get(u->items, itype)); test_cleanup(); } @@ -426,7 +426,7 @@ static void test_teach_cmd(CuTest *tc) { learn_reset(); CuAssertPtrEquals(tc, u, log_learners[0].u); CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk); - CuAssertIntEquals(tc, STUDYDAYS*2*u->number, log_learners[0].days); + CuAssertIntEquals(tc, STUDYDAYS * 2 * u->number, log_learners[0].days); test_cleanup(); }