Ejemplo n.º 1
0
int skill_limit(faction * f, skill_t sk)
{
    int m = INT_MAX;
    int al = allied_skilllimit(f, sk);
    if (al > 0) {
        if (sk != SK_ALCHEMY && sk != SK_MAGIC)
            return INT_MAX;
        if (f_get_alliance(f)) {
            int sc, fl, ac = listlen(f->alliance->members);   /* number of factions */

            assert(ac > 0);
            fl = (al + ac - 1) / ac;      /* faction limit, rounded up */
            /* the faction limit may not be achievable because it would break the alliance-limit */
            sc = al - allied_skillcount(f, sk);
            if (sc <= 0)
                return 0;
            return fl;
        }
    }
    if (sk == SK_MAGIC) {
        m = max_magicians(f);
    }
    else if (sk == SK_ALCHEMY) {
        m = config_get_int("rules.maxskills.alchemy", 3);
    }
    return m;
}
Ejemplo n.º 2
0
static int allied_skillcount(const faction * f, skill_t sk)
{
    int num = 0;
    alliance *a = f_get_alliance(f);
    selist *members = a->members;
    int qi;

    for (qi = 0; members; selist_advance(&members, &qi, 1)) {
        faction *m = (faction *)selist_get(members, qi);
        num += count_skill(m, sk);
    }
    return num;
}
Ejemplo n.º 3
0
static void out_faction(FILE * file, const struct faction *f)
{
  if (alliances != NULL) {
    fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n",
      f->name, itoa36(f->no), f_get_alliance(f) ? f->alliance->id : 0,
      LOC(default_locale, rc_name(f->race, NAME_SINGULAR)), magic_school[f->magiegebiet],
      count_units(f), f->num_total, f->money, turn - f->lastorders);
  } else {
    fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n",
      factionname(f), LOC(default_locale, rc_name(f->race, NAME_SINGULAR)),
      magic_school[f->magiegebiet], count_units(f), f->num_total, f->money,
      turn - f->lastorders);
  }
}
Ejemplo n.º 4
0
static int tolua_faction_get_alliance(lua_State * L)
{
    faction *self = (faction *)tolua_tousertype(L, 1, 0);
    tolua_pushusertype(L, f_get_alliance(self), TOLUA_CAST "alliance");
    return 1;
}