bool PlayerVendorSpeech(cChar* pVendor, const QString& comm, cChar* pPlayer, UOXSOCKET s) { if (!(pVendor->npcaitype == 17)) return 0; if (pPlayer->dist(pVendor) > 4) return 0; if (!VendorChkName(pVendor,comm)) return false; //if (strstr(comm, " BROWSE") || strstr(comm, " VIEW") || strstr(comm, " LOOK")) if ((comm.contains(" BROWSE")) || (comm.contains(" VIEW")) || (comm.contains(" LOOK"))) { npctalk(s,pVendor,"Take a look at my goods.",1); P_ITEM pi_backpack = Packitem(pVendor); if (pi_backpack != NULL) { backpack(s, pi_backpack->serial); return true; } } //if (strstr(comm, " BUY") || strstr(comm, " PURCHASE")) if ((comm.contains(" BUY")) || (comm.contains(" PURCHASE"))) { addx[s]=pVendor->serial; npctalk(s,pVendor,"What would you like to buy?",0); target(s,0,1,0,224," "); return true; } if (!pPlayer->Owns(pVendor)) return 0; //if (strstr( comm, " COLLECT") || strstr( comm, " GOLD") || strstr( comm, " GET")) if ((comm.contains(" COLLECT")) || (comm.contains(" GOLD")) || (comm.contains(" GET"))) { PlVGetgold(s, pVendor); return true; } //if (strstr( comm, "PACKUP")) if (comm.contains("PACKUP")) { P_ITEM pDeed = Items->SpawnItem(pPlayer, 1, "employment deed", 0, 0x14F0, 0, 1); if (pDeed) { pDeed->type = 217; pDeed->value = 2000; RefreshItem( pDeed ); Npcs->DeleteChar( pVendor ); sysmessage(s, "Packed up vendor %s.", pVendor->name.c_str()); return true; } } return false; }
static void test_repair( std::vector<item> tools, bool expect_craftable ) { clear_player(); clear_map(); tripoint test_origin( 60, 60, 0 ); g->u.setpos( test_origin ); item backpack( "backpack" ); g->u.wear( g->u.i_add( backpack ), false ); for( item gear : tools ) { g->u.i_add( gear ); } tripoint vehicle_origin = test_origin + tripoint( 1, 1, 0 ); vehicle *veh_ptr = g->m.add_vehicle( vproto_id( "bicycle" ), vehicle_origin, -90, 0, 0 ); REQUIRE( veh_ptr != nullptr ); // Find the frame at the origin. vehicle_part *origin_frame = nullptr; for( vehicle_part *part : veh_ptr->get_parts( vehicle_origin ) ) { if( part->info().location == "structure" ) { origin_frame = part; break; } } REQUIRE( origin_frame != nullptr ); REQUIRE( origin_frame->hp() == origin_frame->info().durability ); veh_ptr->mod_hp( *origin_frame, -100 ); REQUIRE( origin_frame->hp() < origin_frame->info().durability ); const vpart_info &vp = origin_frame->info(); // Assertions about frame part? requirement_data reqs = vp.repair_requirements(); // Bust cache on crafting_inventory() g->u.mod_moves( 1 ); inventory crafting_inv = g->u.crafting_inventory(); bool can_repair = vp.repair_requirements().can_make_with_inventory( g->u.crafting_inventory() ); CHECK( can_repair == expect_craftable ); }