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 <kernel/config.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/pool.h>
|
||||
#include "academy.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);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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
|
||||
}
|
||||
#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) {
|
||||
/* Solange Akademien groessenbeschraenkt sind, sollte Lehrer und
|
||||
* Student auch in unterschiedlichen Gebaeuden stehen duerfen */
|
||||
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? */
|
||||
if (get_pooled(student, get_resourcetype(R_SILVER), GET_DEFAULT, j) >= j) {
|
||||
/* 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 */
|
||||
if (academy_can_teach(teacher, student, sk)) {
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 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->ucs = ucs;
|
||||
ref->node = 0;
|
||||
ref->node = node;
|
||||
ref->nexthash = tk->next[index];
|
||||
tk->next[index] = ref;
|
||||
|
|
Loading…
Reference in New Issue