forked from github/server
commit
61acd40424
|
@ -7574,4 +7574,22 @@
|
|||
</string>
|
||||
</namespace>
|
||||
|
||||
<string name="growl0">
|
||||
<text locale="de">Groaamm...</text>
|
||||
</string>
|
||||
<string name="growl1">
|
||||
<text locale="de">Tschrrrk...</text>
|
||||
<text locale="en">Tshrrrk...</text>
|
||||
</string>
|
||||
<string name="growl2">
|
||||
<text locale="de">Schhhhh...</text>
|
||||
<text locale="en">Shhhhhh...</text>
|
||||
</string>
|
||||
<string name="growl3">
|
||||
<text locale="de">Roaarrr...</text>
|
||||
</string>
|
||||
<string name="growl4">
|
||||
<text locale="de">Chrrr...</text>
|
||||
</string>
|
||||
|
||||
</strings>
|
||||
|
|
|
@ -8441,4 +8441,15 @@
|
|||
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - Heroes cannot recruit."</text>
|
||||
</message>
|
||||
|
||||
<message name="dragon_growl" section="mail">
|
||||
<type>
|
||||
<arg name="dragon" type="unit"/>
|
||||
<arg name="number" type="int"/>
|
||||
<arg name="target" type="region"/>
|
||||
<arg name="growl" type="string"/>
|
||||
</type>
|
||||
<text locale="de">"$unit($dragon): \"$localize($growl) $if($eq($number,1), "Ich rieche", "Wir riechen") etwas in $region($target)\"."</text>
|
||||
<text locale="en">"$unit($dragon): \"$localize($growl) $if($eq($number,1), "I smell", "We smell") something in $region($target)\"."</text>
|
||||
</message>
|
||||
|
||||
</messages>
|
||||
|
|
|
@ -547,21 +547,23 @@ static order *monster_seeks_target(region * r, unit * u)
|
|||
}
|
||||
#endif
|
||||
|
||||
static const char *random_growl(void)
|
||||
void random_growl(const unit *u, region *target, int rand)
|
||||
{
|
||||
switch (rng_int() % 5) {
|
||||
case 0:
|
||||
return "Groammm";
|
||||
case 1:
|
||||
return "Roaaarrrr";
|
||||
case 2:
|
||||
return "Chhhhhhhhhh";
|
||||
case 3:
|
||||
return "Tschrrrkk";
|
||||
case 4:
|
||||
return "Schhhh";
|
||||
const struct locale *lang = u->faction->locale;
|
||||
const char *growl;
|
||||
switch(rand){
|
||||
case 1: growl = "growl1"; break;
|
||||
case 2: growl = "growl2"; break;
|
||||
case 3: growl = "growl3"; break;
|
||||
case 4: growl = "growl4"; break;
|
||||
default: growl = "growl0";
|
||||
}
|
||||
|
||||
|
||||
if (rname(target, lang)) {
|
||||
message *msg = msg_message("dragon_growl", "dragon number target growl", u, u->number, target, growl);
|
||||
ADDMSG(&u->region->msgs, msg);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
extern struct attrib_type at_direction;
|
||||
|
@ -707,17 +709,7 @@ static order *plan_dragon(unit * u)
|
|||
reduce_weight(u);
|
||||
}
|
||||
if (rng_int() % 100 < 15) {
|
||||
const struct locale *lang = u->faction->locale;
|
||||
/* do a growl */
|
||||
if (rname(tr, lang)) {
|
||||
addlist(&u->orders,
|
||||
create_order(K_MAIL, lang, "%s '%s... %s %s %s'",
|
||||
LOC(lang, parameters[P_REGION]),
|
||||
random_growl(),
|
||||
u->number ==
|
||||
1 ? "Ich rieche" : "Wir riechen",
|
||||
"etwas in", rname(tr, u->faction->locale)));
|
||||
}
|
||||
random_growl(u, tr, rng_int() % 5);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -12,10 +12,13 @@
|
|||
|
||||
#include "monster.h"
|
||||
#include "guard.h"
|
||||
#include "reports.h"
|
||||
#include "skill.h"
|
||||
#include "study.h"
|
||||
|
||||
#include <util/language.h>
|
||||
#include <util/message.h>
|
||||
#include <util/nrmessage.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
#include <tests.h>
|
||||
|
@ -185,11 +188,14 @@ static void test_dragon_attacks_the_rich(CuTest * tc)
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
extern void random_growl(const unit *u, region *tr, int rand);
|
||||
|
||||
static void test_dragon_moves(CuTest * tc)
|
||||
{
|
||||
faction *f, *f2;
|
||||
region *r;
|
||||
unit *u, *m;
|
||||
struct message *msg;
|
||||
|
||||
create_monsters(&f, &f2, &u, &m);
|
||||
rsetmoney(findregion(1, 0), 1000);
|
||||
|
@ -202,6 +208,18 @@ static void test_dragon_moves(CuTest * tc)
|
|||
plan_monsters(f2);
|
||||
|
||||
CuAssertPtrNotNull(tc, find_order("move east", m));
|
||||
|
||||
mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "growl:string", 0));
|
||||
|
||||
random_growl(m, findregion(1, 0), 3);
|
||||
|
||||
msg = test_get_last_message(r->msgs);
|
||||
assert_message(tc, msg, "dragon_growl", 4);
|
||||
assert_pointer_parameter(tc, msg, 0, m);
|
||||
assert_int_parameter(tc, msg, 1, 1);
|
||||
assert_pointer_parameter(tc, msg, 2, findregion(1,0));
|
||||
assert_string_parameter(tc, msg, 3, "growl3");
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
|
23
src/tests.c
23
src/tests.c
|
@ -391,6 +391,29 @@ void test_clear_messages(faction *f) {
|
|||
}
|
||||
}
|
||||
|
||||
void assert_message(CuTest * tc, message *msg, char *name, int numpar) {
|
||||
const message_type *mtype = msg->type;
|
||||
assert(mtype);
|
||||
|
||||
CuAssertStrEquals(tc, name, mtype->name);
|
||||
CuAssertIntEquals(tc, numpar, mtype->nparameters);
|
||||
}
|
||||
|
||||
void assert_pointer_parameter(CuTest * tc, message *msg, int index, void *arg) {
|
||||
const message_type *mtype = (msg)->type;
|
||||
CuAssertIntEquals((tc), VAR_VOIDPTR, mtype->types[(index)]->vtype);CuAssertPtrEquals((tc), (arg), msg->parameters[(index)].v);
|
||||
}
|
||||
|
||||
void assert_int_parameter(CuTest * tc, message *msg, int index, int arg) {
|
||||
const message_type *mtype = (msg)->type;
|
||||
CuAssertIntEquals((tc), VAR_INT, mtype->types[(index)]->vtype);CuAssertIntEquals((tc), (arg), msg->parameters[(index)].i);
|
||||
}
|
||||
|
||||
void assert_string_parameter(CuTest * tc, message *msg, int index, const char *arg) {
|
||||
const message_type *mtype = (msg)->type;
|
||||
CuAssertIntEquals((tc), VAR_VOIDPTR, mtype->types[(index)]->vtype);CuAssertStrEquals((tc), (arg), msg->parameters[(index)].v);
|
||||
}
|
||||
|
||||
void disabled_test(void *suite, void (*test)(CuTest *), const char *name) {
|
||||
(void)test;
|
||||
fprintf(stderr, "%s: SKIP\n", name);
|
||||
|
|
|
@ -54,6 +54,11 @@ extern "C" {
|
|||
struct message * test_find_messagetype(struct message_list *msgs, const char *name);
|
||||
struct message * test_get_last_message(struct message_list *mlist);
|
||||
void test_clear_messages(struct faction *f);
|
||||
void assert_message(struct CuTest * tc, struct message *msg, char *name, int numpar);
|
||||
|
||||
void assert_pointer_parameter(struct CuTest * tc, struct message *msg, int index, void *arg);
|
||||
void assert_int_parameter(struct CuTest * tc, struct message *msg, int index, int arg);
|
||||
void assert_string_parameter(struct CuTest * tc, struct message *msg, int index, const char *arg);
|
||||
|
||||
void disabled_test(void *suite, void (*)(struct CuTest *), const char *name);
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ static void test_logging(CuTest * tc)
|
|||
struct log_t * id2 = log_create(LOG_CPWARNING, str2, log_string);
|
||||
CuAssertTrue(tc, id1!=id2);
|
||||
log_warning("Hello %s", "World");
|
||||
CuAssertStrEquals(tc, str1, "World");
|
||||
CuAssertStrEquals(tc, str2, "World");
|
||||
log_destroy(id1);
|
||||
log_destroy(id2);
|
||||
CuAssertStrEquals(tc, "World", str1);
|
||||
CuAssertStrEquals(tc, "World", str2);
|
||||
}
|
||||
|
||||
CuSuite *get_log_suite(void)
|
||||
|
|
Loading…
Reference in New Issue