Item::Item( const ItemDesc& id, Core::UOBJ_CLASS uobj_class ) : UObject( id.objtype, uobj_class ), container( nullptr ), decayat_gameclock_( 0 ), amount_( 1 ), slot_index_( 0 ), _itemdesc( nullptr ), layer( 0 ), hp_( id.maxhp ) { graphic = id.graphic; color = id.color; setfacing( id.facing ); equip_script_ = id.equip_script; unequip_script_ = id.unequip_script; newbie( id.newbie ); insured( id.insured ); movable( id.default_movable() ); inuse( false ); invisible( id.invisible ); ++Core::stateManager.uobjcount.uitem_count; // hmm, doesn't quite work right with items created on startup.. decayat_gameclock_ = Core::read_gameclock() + id.decay_time * 60; }
//Let the user input all required info of the new Staff //re-enter if the info is invalid //After all the info has been filled, display options: //1. Add Staff //call addStaff() //2. Re enter info //mainAddStaff() //0. return; void StaffList::createStaff() { string new_name, new_dob, new_address, new_dept, new_pos; int new_sal_rate; cout << "Name: "; cin.ignore(); getline(cin, new_name); cout << "DOB: "; //cin.ignore(); getline(cin, new_dob); cout << "Address: "; //cin.ignore(); getline(cin, new_address); cout << "Department: "; cin.ignore(); getline(cin, new_dept); cout << "Position: "; //cin.ignore(); getline(cin, new_pos); cout << "Salary rate: "; while (!(cin >> new_sal_rate)||new_sal_rate<0) { cout << "Invalid number!" << endl; cin.clear(); cin.ignore(256,'\n'); } int new_id = newID(); Staff newbie( new_id, new_name, new_dob, new_address, new_dept, new_pos, new_sal_rate); cout << "Choose one: " << endl; cout << "1. Add a staff member" << endl; cout << "0. Back" << endl; cout << "Enter Your option: "; int command; while (true) { cin >> command; if (cin && (command < 4) && (command > -1)) break; cout << "Invalid command!" << endl; cin.clear(); cin.ignore(256,'\n'); } switch (command) { case 1: if (userConfirm()) { addStaff(newbie); cout << "Add success! New staff member info: " << endl; newbie.Print(); cout << endl; } else { cout << "No change is commited"; } break; case 0: return; default: cout << "Invalid command!" << endl; break; } }