forked from github/server
- recruiting fixes
This commit is contained in:
parent
627947194e
commit
d569cc0088
3 changed files with 26 additions and 6 deletions
|
@ -374,7 +374,7 @@ do_recruiting(recruitment * recruits, int available)
|
||||||
|
|
||||||
for (req=rec->requests;req;req=req->next) {
|
for (req=rec->requests;req;req=req->next) {
|
||||||
unit * u = req->unit;
|
unit * u = req->unit;
|
||||||
const race * rc = u->faction->race;
|
const race * rc = u->race; /* race is set in recruit() */
|
||||||
int number, dec;
|
int number, dec;
|
||||||
float multi = 2.0F * rc->recruit_multi;
|
float multi = 2.0F * rc->recruit_multi;
|
||||||
|
|
||||||
|
@ -486,6 +486,8 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
|
||||||
const struct race * rc = f->race;
|
const struct race * rc = f->race;
|
||||||
const char * str;
|
const char * str;
|
||||||
|
|
||||||
|
if (fval(u, UFL_RECRUITING)) rc = u->race;
|
||||||
|
|
||||||
init_tokens(ord);
|
init_tokens(ord);
|
||||||
skip_token();
|
skip_token();
|
||||||
n = getuint();
|
n = getuint();
|
||||||
|
@ -575,7 +577,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
|
||||||
/* snotlinge sollten hiermit bereits abgefangen werden, die
|
/* snotlinge sollten hiermit bereits abgefangen werden, die
|
||||||
* parteirasse ist uruk oder ork*/
|
* parteirasse ist uruk oder ork*/
|
||||||
if (u->race != rc) {
|
if (u->race != rc) {
|
||||||
if (u->number != 0) {
|
if (fval(u, UFL_RECRUITING) || u->number>0) {
|
||||||
cmistake(u, ord, 139, MSG_EVENT);
|
cmistake(u, ord, 139, MSG_EVENT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -606,6 +608,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
|
||||||
cmistake(u, ord, 142, MSG_EVENT);
|
cmistake(u, ord, 142, MSG_EVENT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
fset(u, UFL_RECRUITING);
|
||||||
o = (request *) calloc(1, sizeof(request));
|
o = (request *) calloc(1, sizeof(request));
|
||||||
o->qty = n;
|
o->qty = n;
|
||||||
o->unit = u;
|
o->unit = u;
|
||||||
|
|
|
@ -62,6 +62,7 @@ struct item;
|
||||||
#define UFL_STEALTH (1<<26)
|
#define UFL_STEALTH (1<<26)
|
||||||
#define UFL_GUARD (1<<27)
|
#define UFL_GUARD (1<<27)
|
||||||
#define UFL_GROUP (1<<28)
|
#define UFL_GROUP (1<<28)
|
||||||
|
#define UFL_RECRUITING (1<<29) /* unit is recruiting, and cannot change race */
|
||||||
|
|
||||||
/* Flags, die gespeichert werden sollen: */
|
/* Flags, die gespeichert werden sollen: */
|
||||||
#define UFL_SAVEMASK (UFL_MOVED | UFL_NOAID | UFL_OWNER | UFL_PARTEITARNUNG | UFL_LOCKED | UFL_HUNGER | UFL_TAKEALL | UFL_GUARD | UFL_STEALTH | UFL_GROUP | UFL_HERO)
|
#define UFL_SAVEMASK (UFL_MOVED | UFL_NOAID | UFL_OWNER | UFL_PARTEITARNUNG | UFL_LOCKED | UFL_HUNGER | UFL_TAKEALL | UFL_GUARD | UFL_STEALTH | UFL_GROUP | UFL_HERO)
|
||||||
|
|
|
@ -227,6 +227,23 @@ function test_events()
|
||||||
assert(fail==0)
|
assert(fail==0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function test_recruit2()
|
||||||
|
free_game()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("enno@eressea.de", "human", "de")
|
||||||
|
local u = unit.create(f, r)
|
||||||
|
u.number = 1
|
||||||
|
u:add_item("money", 2000)
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_order("MACHE TEMP 1")
|
||||||
|
u:add_order("REKRUTIERE 1 Elf")
|
||||||
|
u:add_order("REKRUTIERE 1 mensch")
|
||||||
|
u:add_order("REKRUTIERE 1")
|
||||||
|
process_orders()
|
||||||
|
print(u:get_item("money"))
|
||||||
|
print(u.number)
|
||||||
|
end
|
||||||
|
|
||||||
local function test_recruit()
|
local function test_recruit()
|
||||||
free_game()
|
free_game()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
|
@ -525,6 +542,7 @@ tests = {
|
||||||
["produce"] = test_produce,
|
["produce"] = test_produce,
|
||||||
["rename"] = test_rename,
|
["rename"] = test_rename,
|
||||||
["recruit"] = test_recruit,
|
["recruit"] = test_recruit,
|
||||||
|
["recruit2"] = test_recruit2,
|
||||||
["spells"] = test_spells,
|
["spells"] = test_spells,
|
||||||
["herbalism"] = test_herbalism,
|
["herbalism"] = test_herbalism,
|
||||||
["storage"] = test_storage,
|
["storage"] = test_storage,
|
||||||
|
@ -535,12 +553,10 @@ tests = {
|
||||||
["market"] = test_market
|
["market"] = test_market
|
||||||
}
|
}
|
||||||
mytests = {
|
mytests = {
|
||||||
["leave"] = test_leave,
|
["recruit2"] = test_recruit2
|
||||||
["taxes"] = test_taxes,
|
|
||||||
["market"] = test_market
|
|
||||||
}
|
}
|
||||||
fail = 0
|
fail = 0
|
||||||
for k, v in pairs(tests) do
|
for k, v in pairs(mytests) do
|
||||||
local status, err = pcall(v)
|
local status, err = pcall(v)
|
||||||
if not status then
|
if not status then
|
||||||
fail = fail + 1
|
fail = fail + 1
|
||||||
|
|
Loading…
Reference in a new issue