Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FORGET before GIVE PERSON #1053

Merged
merged 2 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion scripts/tests/laws.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,39 @@ function setup()
eressea.free_game()
conf = [[{
"races": {
"human" : { "flags" : [ "player" ] }
"human" : { "flags" : [ "player", "giveperson" ] }
},
"terrains" : {
"plain": { "flags" : [ "land", "walk", "sail" ] }
},
"parameters" : {
"de" : {
"EINHEIT": "EINHEIT",
"PERSONEN": "PERSONEN"
}
},
"keywords" : {
"de": {
"attack" : "ATTACKIERE",
"guard" : "BEWACHE",
"maketemp" : "MACHETEMP",
"end" : "ENDE",
"use" : "BENUTZEN",
"forget" : "VERGISS",
"give" : "GIB",
"recruit" : "REKRUTIERE"
}
},
"buildings" : {
"castle" : {}
},
"skills" : {
"de": {
"tactics" : "Taktik",
"alchemy" : "Alchemie",
"crossbow" : "Armbrust"
}
},
"items" : {
"sword" : {
"weapon" : {
Expand Down Expand Up @@ -149,3 +164,19 @@ function test_force_leave_postcombat()
assert_equal(1, u3.number)
end

function test_give_and_forget()
local r = region.create(0, 0, "plain")
local f = faction.create("human")
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
u1.name = 'Xolgrim'
u1:set_skill('alchemy', 1)
u1:set_skill('crossbow', 1)
u2:set_skill('alchemy', 1)
u1:set_orders("GIB " .. itoa36(u2.id) .. " 1 PERSON\nVERGISS Armbrust")
process_orders()
assert_equal(0, u1.number)
assert_equal(2, u2.number)
assert_equal(0, u2:get_skill('crossbow'))
assert_equal(1, u2:get_skill('alchemy'))
end
5 changes: 1 addition & 4 deletions src/economy.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void maintain_buildings(region * r)
}
}

void economics(region * r)
void do_give(region * r)
{
unit *u;

Expand All @@ -401,9 +401,6 @@ void economics(region * r)
transfer = ord;
}
}
else if (kwd == K_FORGET) {
forget_cmd(u, ord);
}
if (u->orders == NULL) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/economy.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extern "C" {
int income(const struct unit *u);
int entertainmoney(const struct region *r);

void economics(struct region *r);
void do_give(struct region *r);
void destroy(struct region *r);
void produce(struct region *r);
void auto_work(struct region *r);
Expand Down
2 changes: 1 addition & 1 deletion src/give.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ param_t give_cmd(unit * u, order * ord)
return p;
}
else if (p == NOPARAM) {
/* the most likely case: giving items to someone.
/* the most likely case: giving items, ships, or persons.
* let's catch this and save ourselves the rest of the param_t checks.
*/
}
Expand Down
3 changes: 2 additions & 1 deletion src/laws.c
Original file line number Diff line number Diff line change
Expand Up @@ -3704,12 +3704,13 @@ void init_processor(void)

p += 10; /* in case it has any effects on alliance victories */
add_proc_order(p, K_GIVE, give_control_cmd, 0, "GIB KOMMANDO");
add_proc_order(p, K_FORGET, forget_cmd, 0, "Vergessen");

p += 10; /* reset rng again before economics */
if (rule_force_leave(FORCE_LEAVE_ALL)) {
add_proc_region(p, do_force_leave, "kick non-allies out of buildings/ships");
}
add_proc_region(p, economics, "Geben, Vergessen");
add_proc_region(p, do_give, "Geben");
add_proc_region(p+1, recruit, "Rekrutieren");
add_proc_region(p+2, destroy, "Zerstoeren");
add_proc_unit(p, follow_cmds, "Folge auf Einheiten setzen");
Expand Down
Loading