void test_equipment(CuTest * tc) { equipment * eq; unit * u; const item_type * it_horses; spell *sp; sc_mage * mage; test_cleanup(); test_create_race("human"); enable_skill(SK_MAGIC, true); it_horses = test_create_itemtype("horse"); CuAssertPtrNotNull(tc, it_horses); sp = create_spell("testspell", 0); CuAssertPtrNotNull(tc, sp); CuAssertPtrEquals(tc, 0, get_equipment("herpderp")); eq = create_equipment("herpderp"); CuAssertPtrEquals(tc, eq, get_equipment("herpderp")); equipment_setitem(eq, it_horses, "1"); equipment_setskill(eq, SK_MAGIC, "5"); equipment_addspell(eq, sp, 1); u = test_create_unit(0, 0); equip_unit_mask(u, eq, EQUIP_ALL); CuAssertIntEquals(tc, 1, i_get(u->items, it_horses)); CuAssertIntEquals(tc, 5, get_level(u, SK_MAGIC)); mage = get_mage(u); CuAssertPtrNotNull(tc, mage); CuAssertPtrNotNull(tc, mage->spellbook); CuAssertTrue(tc, u_hasspell(u, sp)); }
static void test_all_spy_message(CuTest *tc) { spy_fixture fix; setup_spy(&fix); enable_skill(SK_MAGIC, true); set_level(fix.victim, SK_MINING, 2); set_level(fix.victim, SK_MAGIC, 2); create_mage(fix.victim, M_DRAIG); set_factionstealth(fix.victim, fix.spy->faction); item_type *itype; itype = it_get_or_create(rt_get_or_create("sword")); new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2); i_change(&fix.victim->items, itype, 1); spy_message(99, fix.spy, fix.victim); CuAssertPtrNotNull(tc, test_find_messagetype(fix.spy->faction->msgs, "spyreport")); CuAssertPtrNotNull(tc, test_find_messagetype(fix.spy->faction->msgs, "spyreport_mage")); CuAssertPtrNotNull(tc, test_find_messagetype(fix.spy->faction->msgs, "spyreport_skills")); CuAssertPtrNotNull(tc, test_find_messagetype(fix.spy->faction->msgs, "spyreport_faction")); CuAssertPtrNotNull(tc, test_find_messagetype(fix.spy->faction->msgs, "spyreport_items")); test_cleanup(); }
/** disable a feature. * features are identified by eone of: * 1. the keyword for their orders, * 2. the name of the skill they use, * 3. a "module.enabled" flag in the settings */ static void disable_feature(const char *str) { char name[32]; int k; skill_t sk; sk = findskill(str); if (sk != NOSKILL) { enable_skill(sk, false); return; } for (k = 0; k != MAXKEYWORDS; ++k) { // FIXME: this loop is slow as balls. if (strcmp(keywords[k], str) == 0) { log_debug("disable keyword %s\n", str); enable_keyword(k, false); return; } } _snprintf(name, sizeof(name), "%s.enabled", str); log_info("disable feature %s\n", name); config_set(name, "0"); }