Beispiel #1
0
static void test_rename_building_twice(CuTest * tc)
{
  region *r;
  building *b;
  unit *u;
  faction *f;
  building_type *btype;

  test_cleanup();
  test_create_world();

  btype = bt_get_or_create("castle");

  r = findregion(-1, 0);
  b = new_building(btype, r, default_locale);
  f = test_create_faction(rc_find("human"));
  u = test_create_unit(f, r);
  u_set_building(u, b);

  rename_building(u, NULL, b, "Villa Nagel");
  CuAssertStrEquals(tc, "Villa Nagel", b->name);

  rename_building(u, NULL, b, "Villa Kunterbunt");
  CuAssertStrEquals(tc, "Villa Kunterbunt", b->name);
}
Beispiel #2
0
static void json_buildings(cJSON *json) {
    cJSON *child;
    if (json->type != cJSON_Object) {
        log_error("buildings is not a json object: %d", json->type);
        return;
    }
    for (child = json->child; child; child = child->next) {
        json_building(child, bt_get_or_create(child->string));
    }
}
Beispiel #3
0
static void test_new_building_can_be_renamed(CuTest * tc)
{
  region *r;
  building *b;
  building_type *btype;

  test_cleanup();
  test_create_world();

  btype = bt_get_or_create("castle");
  r = findregion(-1, 0);

  b = new_building(btype, r, default_locale);
  CuAssertTrue(tc, !renamed_building(b));
}
Beispiel #4
0
static void test_register_building(CuTest * tc)
{
    building_type *btype;
    int cache = 0;

    test_setup();

    CuAssertIntEquals(tc, true, bt_changed(&cache));
    CuAssertIntEquals(tc, false, bt_changed(&cache));

    btype = bt_get_or_create("herp");
    CuAssertIntEquals(tc, true, bt_changed(&cache));
    CuAssertPtrEquals(tc, btype, (void *)bt_find("herp"));

    free_buildingtypes();
    CuAssertIntEquals(tc, true, bt_changed(&cache));
    test_teardown();
}
Beispiel #5
0
static void test_buildingtype(CuTest *tc) {
    building_type *btype;
    test_setup();

    btype = test_create_buildingtype("hodor");
    CuAssertPtrNotNull(tc, btype->stages);
    CuAssertPtrEquals(tc, NULL, btype->stages->name);
    CuAssertPtrNotNull(tc, btype->stages->construction);
    CuAssertStrEquals(tc, "hodor", buildingtype(btype, NULL, 1));

    btype->stages->name = str_strdup("castle");
    CuAssertStrEquals(tc, "castle", buildingtype(btype, NULL, 1));

    btype = bt_get_or_create("portal");
    CuAssertPtrEquals(tc, NULL, btype->stages);
    CuAssertStrEquals(tc, "portal", buildingtype(btype, NULL, 1));

    test_teardown();
}
Beispiel #6
0
static void test_btype_defaults(CuTest *tc) {
    building_type * btype;

    test_setup();

    btype = bt_get_or_create("hodor");
    CuAssertPtrNotNull(tc, btype);
    CuAssertStrEquals(tc, "hodor", btype->_name);
    CuAssertPtrEquals(tc, NULL, btype->maintenance);
    CuAssertPtrEquals(tc, NULL, btype->stages);
    CuAssertDblEquals(tc, 1.0, btype->auraregen, 0.0);
    CuAssertIntEquals(tc, 0, btype->taxes);
    CuAssertIntEquals(tc, -1, btype->maxsize);
    CuAssertIntEquals(tc, 1, btype->capacity);
    CuAssertIntEquals(tc, -1, btype->maxcapacity);
    CuAssertIntEquals(tc, 0, btype->magres.sa[0]);
    CuAssertIntEquals(tc, 0, btype->magresbonus);
    CuAssertIntEquals(tc, 0, btype->fumblebonus);
    CuAssertIntEquals(tc, BTF_DEFAULT, btype->flags);
    test_teardown();
}