Exemplo n.º 1
0
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);
    r = findregion(0, 0); // plain
    rsetpeasants(r, 0);
    rsetmoney(r, 0);

    set_level(m, SK_WEAPONLESS, 10);
    config_set("rules.monsters.attack_chance", ".0");
    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();
}
Exemplo n.º 2
0
static void test_dragon_attacks_the_rich(CuTest * tc)
{
    faction *f, *f2;
    unit *u, *m;
    const item_type *i_silver;

    create_monsters(&f, &f2, &u, &m);
    init_resources();

    setguard(m, true);
    set_level(m, SK_WEAPONLESS, 10);

    rsetmoney(findregion(0, 0), 1);
    rsetmoney(findregion(1, 0), 0);
    i_silver = it_find("money");
    assert(i_silver);
    i_change(&u->items, i_silver, 5000);

    config_set("rules.monsters.attack_chance", "0.00001");

    plan_monsters(f2);

    CuAssertPtrNotNull(tc, find_order("attack 1", m));
    CuAssertPtrNotNull(tc, find_order("loot", m));
    test_cleanup();
}
Exemplo n.º 3
0
static void test_dragon_attacks_the_rich(CuTest * tc)
{
    faction *f, *f2;
    region *r;
    unit *u, *m;
    const item_type *i_silver;

    init_language();
    create_monsters(&f, &f2, &r, &u, &m);

    guard(m, GUARD_TAX);
    set_level(m, SK_WEAPONLESS, 10);

    rsetmoney(r, 1);
    rsetmoney(findregion(1, 0), 0);
    i_silver = it_find("money");
    assert(i_silver);
    i_change(&u->items, i_silver, 5000);

    config_set("rules.monsters.attack_chance", "0.00001");

    plan_monsters(f2);

    CuAssertPtrNotNull(tc, find_order("ATTACKIERE 1", m));
    CuAssertPtrNotNull(tc, find_order("PLUENDERE", m));
    test_cleanup();
}
Exemplo n.º 4
0
static void test_monsters_attack(CuTest * tc)
{
    faction *f, *f2;
    unit *u, *m;

    create_monsters(&f, &f2, &u, &m);

    setguard(m, true);

    config_set("rules.monsters.attack_chance", "1");

    plan_monsters(f2);

    CuAssertPtrNotNull(tc, find_order("attack 1", m));
    test_cleanup();
}
Exemplo n.º 5
0
static void test_monsters_attack(CuTest * tc)
{
    faction *f, *f2;
    region *r;
    unit *u, *m;

    create_monsters(&f, &f2, &r, &u, &m);

    guard(m, GUARD_TAX);

    config_set("rules.monsters.attack_chance", "1");

    plan_monsters(f2);

    CuAssertPtrNotNull(tc, find_order("ATTACKIERE 1", m));
    test_cleanup();
}
Exemplo n.º 6
0
static void test_dragon_moves(CuTest * tc)
{
    faction *f, *f2;
    region *r;
    unit *u, *m;

    create_monsters(&f, &f2, &r, &u, &m);
    rsetpeasants(r, 0);
    rsetmoney(r, 0);
    rsetmoney(findregion(1, 0), 1000);

    set_level(m, SK_WEAPONLESS, 10);
    config_set("rules.monsters.attack_chance", ".0");
    plan_monsters(f2);

    CuAssertPtrNotNull(tc, find_order("NACH O", m));
    test_cleanup();
}
Exemplo n.º 7
0
static void test_monsters_attack_ocean(CuTest * tc)
{
    faction *f, *f2;
    region *r;
    unit *u, *m;

    create_monsters(&f, &f2, &u, &m);
    r = findregion(-1, 0); // ocean
    u = test_create_unit(u->faction, r);
    unit_setid(u, 2);
    m = test_create_unit(m->faction, r);
    assert(!m->region->land);

    config_set("rules.monsters.attack_chance", "1");

    plan_monsters(f2);

    CuAssertPtrNotNull(tc, find_order("attack 2", m));
    test_cleanup();
}
Exemplo n.º 8
0
static void test_seaserpent_piracy(CuTest * tc)
{
    faction *f, *f2;
    region *r;
    unit *u, *m;
    race *rc;

    create_monsters(&f, &f2, &u, &m);
    r = findregion(-1, 0); // ocean
    u = test_create_unit(u->faction, r);
    unit_setid(u, 2);
    m = test_create_unit(m->faction, r);
    u_setrace(m, rc = test_create_race("seaserpent"));
    assert(!m->region->land);
    fset(m, UFL_MOVED);
    fset(rc, RCF_ATTACK_MOVED);

    config_set("rules.monsters.attack_chance", "1");

    plan_monsters(f2);
    CuAssertPtrNotNull(tc, find_order("piracy", m));
    CuAssertPtrNotNull(tc, find_order("attack 2", m));
    test_cleanup();
}