forked from github/server
fixed demon_skillchange and produceexp
learn_skill's argument is the number of person days, not the number of unit days as assumed!
This commit is contained in:
parent
80bfb5dbc6
commit
f0c17b01af
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue