forked from github/server
just a little bit of refactoring
This commit is contained in:
parent
d83bd3bec5
commit
ae7d86dae0
|
@ -19,6 +19,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include <kernel/unit.h>
|
#include <kernel/unit.h>
|
||||||
|
#include <kernel/building.h>
|
||||||
|
#include <kernel/item.h>
|
||||||
|
#include <kernel/pool.h>
|
||||||
#include "academy.h"
|
#include "academy.h"
|
||||||
#include "study.h"
|
#include "study.h"
|
||||||
|
|
||||||
|
@ -28,3 +31,15 @@ void academy_teaching_bonus(struct unit *u, skill_t sk, int academy) {
|
||||||
learn_skill(u, sk, academy / 30.0 / TEACHNUMBER);
|
learn_skill(u, sk, academy / 30.0 / TEACHNUMBER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool academy_can_teach(unit *teacher, unit *student, skill_t sk) {
|
||||||
|
const struct building_type *btype = bt_find("academy");
|
||||||
|
if (active_building(teacher, btype) && active_building(student, btype)) {
|
||||||
|
int j = study_cost(student, sk);
|
||||||
|
j = _max(50, j * 2);
|
||||||
|
/* kann Einheit das zahlen? */
|
||||||
|
return get_pooled(student, get_resourcetype(R_SILVER), GET_DEFAULT, j) >= j;
|
||||||
|
/* sonst nehmen sie nicht am Unterricht teil */
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ extern "C" {
|
||||||
|
|
||||||
struct unit;
|
struct unit;
|
||||||
void academy_teaching_bonus(struct unit *u, skill_t sk, int academy);
|
void academy_teaching_bonus(struct unit *u, skill_t sk, int academy);
|
||||||
|
bool academy_can_teach(struct unit *teacher, struct unit *student, skill_t sk);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
19
src/study.c
19
src/study.c
|
@ -230,18 +230,13 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
|
||||||
if (student->building && teacher->building == student->building) {
|
if (student->building && teacher->building == student->building) {
|
||||||
/* Solange Akademien groessenbeschraenkt sind, sollte Lehrer und
|
/* Solange Akademien groessenbeschraenkt sind, sollte Lehrer und
|
||||||
* Student auch in unterschiedlichen Gebaeuden stehen duerfen */
|
* Student auch in unterschiedlichen Gebaeuden stehen duerfen */
|
||||||
const struct building_type *btype = bt_find("academy");
|
if (academy_can_teach(teacher, student, sk)) {
|
||||||
if (active_building(teacher, btype) && active_building(student, btype)) {
|
/* Jeder Schueler zusaetzlich +10 Tage wenn in Uni. */
|
||||||
int j = study_cost(student, sk);
|
teach->value += (n / 30) * 10; /* learning erhoehen */
|
||||||
j = _max(50, j * 2);
|
/* Lehrer zusaetzlich +1 Tag pro Schueler. */
|
||||||
/* kann Einheit das zahlen? */
|
if (academy) {
|
||||||
if (get_pooled(student, get_resourcetype(R_SILVER), GET_DEFAULT, j) >= j) {
|
*academy += n;
|
||||||
/* Jeder Schueler zusaetzlich +10 Tage wenn in Uni. */
|
}
|
||||||
teach->value += (n / 30) * 10; /* learning erhoehen */
|
|
||||||
/* Lehrer zusaetzlich +1 Tag pro Schueler. */
|
|
||||||
if (academy)
|
|
||||||
*academy += n;
|
|
||||||
} /* sonst nehmen sie nicht am Unterricht teil */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Teaching ist die Anzahl Leute, denen man noch was beibringen kann. Da
|
/* Teaching ist die Anzahl Leute, denen man noch was beibringen kann. Da
|
||||||
|
|
|
@ -171,7 +171,6 @@ void addtoken(void ** root, const char *str, variant id)
|
||||||
|
|
||||||
ref = (tref *)malloc(sizeof(tref));
|
ref = (tref *)malloc(sizeof(tref));
|
||||||
ref->ucs = ucs;
|
ref->ucs = ucs;
|
||||||
ref->node = 0;
|
|
||||||
ref->node = node;
|
ref->node = node;
|
||||||
ref->nexthash = tk->next[index];
|
ref->nexthash = tk->next[index];
|
||||||
tk->next[index] = ref;
|
tk->next[index] = ref;
|
||||||
|
|
Loading…
Reference in New Issue