forked from github/server
taxing without skill does not fail silently any more
http://bugs.eressea.de/view.php?id=2158 added configuration parameter for tax per level
This commit is contained in:
parent
5ef9b624ff
commit
493b45c832
|
@ -15,6 +15,7 @@
|
||||||
"modules.wormholes": true,
|
"modules.wormholes": true,
|
||||||
"entertain.base": 0,
|
"entertain.base": 0,
|
||||||
"entertain.perlevel": 20,
|
"entertain.perlevel": 20,
|
||||||
|
"taxing.perlevel": 20,
|
||||||
"nmr.timeout": 5,
|
"nmr.timeout": 5,
|
||||||
"nmr.removenewbie": 0,
|
"nmr.removenewbie": 0,
|
||||||
"GiveRestriction": 3,
|
"GiveRestriction": 3,
|
||||||
|
|
|
@ -6357,6 +6357,16 @@
|
||||||
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist nicht der Eigentümer."</text>
|
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist nicht der Eigentümer."</text>
|
||||||
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The unit is not the owner."</text>
|
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The unit is not the owner."</text>
|
||||||
</message>
|
</message>
|
||||||
|
<message name="error_no_tax_skill" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist nicht geschult im Eintreiben von Steuern."</text>
|
||||||
|
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The unit does not now how to tax."</text>
|
||||||
|
</message>
|
||||||
|
|
||||||
<message name="error48" section="errors">
|
<message name="error48" section="errors">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
|
|
|
@ -2924,7 +2924,7 @@ static void expandloot(region * r, request * lootorders)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void expandtax(region * r, request * taxorders)
|
void expandtax(region * r, request * taxorders)
|
||||||
{
|
{
|
||||||
unit *u;
|
unit *u;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -2957,6 +2957,11 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
|
||||||
request *o;
|
request *o;
|
||||||
int max;
|
int max;
|
||||||
keyword_t kwd;
|
keyword_t kwd;
|
||||||
|
static int taxperlevel = 0;
|
||||||
|
|
||||||
|
if (!taxperlevel) {
|
||||||
|
taxperlevel = get_param_int(global.parameters, "taxing.perlevel", 0);
|
||||||
|
}
|
||||||
|
|
||||||
kwd = init_order(ord);
|
kwd = init_order(ord);
|
||||||
assert(kwd == K_TAX);
|
assert(kwd == K_TAX);
|
||||||
|
@ -2982,6 +2987,12 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (effskill(u, SK_TAXING, 0) <= 0) {
|
||||||
|
ADDMSG(&u->faction->msgs,
|
||||||
|
msg_feedback(u, ord, "error_no_tax_skill", ""));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
max = getint();
|
max = getint();
|
||||||
|
|
||||||
if (max <= 0) {
|
if (max <= 0) {
|
||||||
|
@ -2991,7 +3002,7 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
|
||||||
u->wants = _min(income(u), max);
|
u->wants = _min(income(u), max);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u->wants = _min(n * effskill(u, SK_TAXING, 0) * 20, max);
|
u->wants = _min(n * effskill(u, SK_TAXING, 0) * taxperlevel, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
u2 = is_guarded(r, u, GUARD_TAX);
|
u2 = is_guarded(r, u, GUARD_TAX);
|
||||||
|
|
|
@ -45,6 +45,7 @@ extern "C" {
|
||||||
struct faction;
|
struct faction;
|
||||||
struct order;
|
struct order;
|
||||||
struct message;
|
struct message;
|
||||||
|
struct request;
|
||||||
|
|
||||||
int income(const struct unit *u);
|
int income(const struct unit *u);
|
||||||
|
|
||||||
|
@ -59,6 +60,8 @@ extern "C" {
|
||||||
int recruit_archetypes(void);
|
int recruit_archetypes(void);
|
||||||
int give_control_cmd(struct unit *u, struct order *ord);
|
int give_control_cmd(struct unit *u, struct order *ord);
|
||||||
void give_control(struct unit * u, struct unit * u2);
|
void give_control(struct unit * u, struct unit * u2);
|
||||||
|
void tax_cmd(struct unit * u, struct order *ord, struct request ** taxorders);
|
||||||
|
void expandtax(struct region * r, struct request * taxorders);
|
||||||
|
|
||||||
struct message * check_steal(const struct unit * u, struct order *ord);
|
struct message * check_steal(const struct unit * u, struct order *ord);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <CuTest.h>
|
#include <CuTest.h>
|
||||||
#include <tests.h>
|
#include <tests.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
static void test_give_control_building(CuTest * tc)
|
static void test_give_control_building(CuTest * tc)
|
||||||
{
|
{
|
||||||
|
@ -169,6 +170,77 @@ static void test_normals_recruit(CuTest * tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct request {
|
||||||
|
struct request *next;
|
||||||
|
struct unit *unit;
|
||||||
|
struct order *ord;
|
||||||
|
int qty;
|
||||||
|
int no;
|
||||||
|
union {
|
||||||
|
bool goblin; /* stealing */
|
||||||
|
const struct luxury_type *ltype; /* trading */
|
||||||
|
} type;
|
||||||
|
} request;
|
||||||
|
|
||||||
|
static void test_tax_cmd(CuTest *tc) {
|
||||||
|
order *ord;
|
||||||
|
faction *f;
|
||||||
|
region *r;
|
||||||
|
unit *u;
|
||||||
|
item_type *sword, *silver;
|
||||||
|
request *taxorders = 0;
|
||||||
|
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
set_param(&global.parameters, "taxing.perlevel", "20");
|
||||||
|
test_create_world();
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
r = findregion(0, 0);
|
||||||
|
assert(r && f);
|
||||||
|
u = test_create_unit(f, r);
|
||||||
|
|
||||||
|
ord = create_order(K_TAX, f->locale, "");
|
||||||
|
assert(ord);
|
||||||
|
|
||||||
|
tax_cmd(u, ord, &taxorders);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error48"));
|
||||||
|
test_clear_messages(u->faction);
|
||||||
|
|
||||||
|
silver = get_resourcetype(R_SILVER)->itype;
|
||||||
|
|
||||||
|
sword = it_get_or_create(rt_get_or_create("sword"));
|
||||||
|
new_weapontype(sword, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 1);
|
||||||
|
i_change(&u->items, sword, 1);
|
||||||
|
set_level(u, SK_MELEE, 1);
|
||||||
|
|
||||||
|
tax_cmd(u, ord, &taxorders);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error_no_tax_skill"));
|
||||||
|
test_clear_messages(u->faction);
|
||||||
|
|
||||||
|
set_level(u, SK_TAXING, 1);
|
||||||
|
tax_cmd(u, ord, &taxorders);
|
||||||
|
CuAssertPtrEquals(tc, 0, test_find_messagetype(u->faction->msgs, "error_no_tax_skill"));
|
||||||
|
CuAssertPtrNotNull(tc, taxorders);
|
||||||
|
|
||||||
|
|
||||||
|
r->land->money = 11;
|
||||||
|
expandtax(r, taxorders);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "income"));
|
||||||
|
CuAssertTrue(tc, i_get(u->items, silver) > 0 && i_get(u->items, silver) <= 11);
|
||||||
|
test_clear_messages(u->faction);
|
||||||
|
i_change(&u->items, silver, -i_get(u->items, silver));
|
||||||
|
|
||||||
|
r->land->money = 1000;
|
||||||
|
taxorders = 0;
|
||||||
|
tax_cmd(u, ord, &taxorders);
|
||||||
|
expandtax(r, taxorders);
|
||||||
|
CuAssertIntEquals(tc, 20, i_get(u->items, silver));
|
||||||
|
test_clear_messages(u->faction);
|
||||||
|
|
||||||
|
free_order(ord);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_economy_suite(void)
|
CuSuite *get_economy_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -179,5 +251,6 @@ CuSuite *get_economy_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_steal_nosteal);
|
SUITE_ADD_TEST(suite, test_steal_nosteal);
|
||||||
SUITE_ADD_TEST(suite, test_normals_recruit);
|
SUITE_ADD_TEST(suite, test_normals_recruit);
|
||||||
SUITE_ADD_TEST(suite, test_heroes_dont_recruit);
|
SUITE_ADD_TEST(suite, test_heroes_dont_recruit);
|
||||||
|
SUITE_ADD_TEST(suite, test_tax_cmd);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue