report newbie immuniy clearly

This commit is contained in:
Steffen Mecke 2021-04-26 21:31:00 +02:00
parent 557f5458ea
commit eb5ddfaeda
5 changed files with 43 additions and 6 deletions

View File

@ -5480,6 +5480,8 @@
<arg name="turns" type="int"/> <arg name="turns" type="int"/>
</type> </type>
</message> </message>
<message name="newbieimmunityending" section="nr" />
<message name="newbieimmunityended" section="nr" />
<message name="alliance::kickedout" section="events"> <message name="alliance::kickedout" section="events">
<type> <type>
<arg name="votes" type="int"/> <arg name="votes" type="int"/>

View File

@ -2649,7 +2649,13 @@ msgid "error201"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Rasse und Zieleinheit wurden vergessen.\"" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Rasse und Zieleinheit wurden vergessen.\""
msgid "newbieimmunity" msgid "newbieimmunity"
msgstr "\"Deine Partei ist noch $int($turns) Wochen immun gegen Angriffe.\"" msgstr "\"Deine Partei ist noch die nächsten $int($turns) Wochen immun gegen Angriffe.\""
msgid "newbieimmunityending"
msgstr "\"Deine Partei ist nur noch in der kommenden Woche immun gegen Angriffe.\""
msgid "newbieimmunityended"
msgstr "\"Deine Partei ist nun nicht mehr immun gegen Angriffe.\""
msgid "curseinfo::auraboost_0" msgid "curseinfo::auraboost_0"
msgstr "\"$unit($unit) fühlt sich von starken magischen Energien durchströmt. ($int36($id))\"" msgstr "\"$unit($unit) fühlt sich von starken magischen Energien durchströmt. ($int36($id))\""

View File

@ -2649,7 +2649,13 @@ msgid "error201"
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Race and target unit have not been supplied.\"" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Race and target unit have not been supplied.\""
msgid "newbieimmunity" msgid "newbieimmunity"
msgstr "\"Your faction is immune against assaults for $int($turns) more weeks.\"" msgstr "\"Your faction will be immune against assaults for the next $int($turns) weeks.\""
msgid "newbieimmunityending"
msgstr "\"Your faction will be immune against assaults only one more week.\""
msgid "newbieimmunityended"
msgstr "\"Your faction will no longer be immune against assaults.\""
msgid "curseinfo::auraboost_0" msgid "curseinfo::auraboost_0"
msgstr "\"Powerful magical energies are pulsing through $unit($unit). ($int36($id))\"" msgstr "\"Powerful magical energies are pulsing through $unit($unit). ($int36($id))\""

View File

@ -1433,9 +1433,16 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) {
void report_warnings(faction *f, int now) void report_warnings(faction *f, int now)
{ {
if (f->age < NewbieImmunity()) { if (f->age < NewbieImmunity()) {
ADDMSG(&f->msgs, msg_message("newbieimmunity", "turns", assert(IsImmune(f));
NewbieImmunity() - f->age)); if (f->age + 2 < NewbieImmunity()) {
} ADDMSG(&f->msgs, msg_message("newbieimmunity", "turns",
NewbieImmunity() - f->age - 1));
} else if (f->age +1 < NewbieImmunity()) {
ADDMSG(&f->msgs, msg_message("newbieimmunityending", ""));
} else {
ADDMSG(&f->msgs, msg_message("newbieimmunityended", ""));
}
} /* else assert(!IsImmune(f)); */
if (f->race == get_race(RC_INSECT)) { if (f->race == get_race(RC_INSECT)) {
season_t season = calendar_season(now + 1); season_t season = calendar_season(now + 1);

View File

@ -835,14 +835,30 @@ static void test_newbie_warning(CuTest *tc) {
f = test_create_faction(); f = test_create_faction();
config_set_int("NewbieImmunity", 3); config_set_int("NewbieImmunity", 3);
f->age = 2; f->age = 0;
report_warnings(f, 0); report_warnings(f, 0);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "newbieimmunity")); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "newbieimmunity"));
CuAssertIntEquals(tc, true, IsImmune(f));
test_clear_messages(f);
f->age = 1;
report_warnings(f, 0);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "newbieimmunityending"));
CuAssertIntEquals(tc, true, IsImmune(f));
test_clear_messages(f);
f->age = 2;
report_warnings(f, 0);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "newbieimmunityended"));
CuAssertIntEquals(tc, true, IsImmune(f));
test_clear_messages(f); test_clear_messages(f);
f->age = 3; f->age = 3;
report_warnings(f, 0); report_warnings(f, 0);
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "newbieimmunityended"));
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "newbieimmunityending"));
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "newbieimmunity")); CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "newbieimmunity"));
CuAssertIntEquals(tc, false, IsImmune(f));
test_clear_messages(f); test_clear_messages(f);
test_teardown(); test_teardown();