Equiping Process - picardrulez/textAdventure GitHub Wiki
- equipMenu()
- equipItem()
- equipWeapon()
- equipItem()
int equipMenu() { doneEquiping = 0; while (doneEquiping == 0) { // clearScreen(); cout << menuBar; cout << " Press '0' to return.\n"; cout << " Choose Item to equip / use:\n\n"; int startNumber = 0; for (int i = 0; i < playerItemCount; i++) { string tableName; for (int j = 0; j < 3; j++) { if (j == 0) { pos1 = player_inv[i][j]; } else if (j == 1) { pos2 = player_inv[i][j]; } else if (j == 2) { itemUses = player_inv[i][j]; startNumber++; cout << " (" << startNumber << ") " << findItemName(pos1, pos2) << "\n"; } } } cout <<"\n"; cout << menuBar; if (userMessage == 1) { equipMessage(); } else if (userMessage == 2) { healthMessage(); } else if (userMessage == 3) { magicMessage(); } else if (userMessage == 4) { drunkMessage(); } userMessage = 0; cin >> userInput; if (userInput == 0) { doneEquiping = 1; return 0; return 0; } itemNumber = userInput - 1; pos1 = player_inv[itemNumber][0]; pos2 = player_inv[itemNumber][1]; itemUses = player_inv[itemNumber][2]; item = findItemName(pos2, pos2); if (pos1 == 2) { useItem(pos2); } else { cout << "itemUses is " << itemUses << "\n"; equipItem(pos1,pos2, itemUses); } dropItem(itemNumber); } }
equipItem()
void equipItem(int table, int itemNumber, int uses) { item = findItemName(table, itemNumber); lastEquipped = item; userMessage = 1; if (item.find("Sword") != string::npos || item.find("Axe") != string::npos || item.find("Hammer") != string::npos || item.find("Dart") != string::npos ) { equipWeapon(table, itemNumber, uses); } else if (item.find("Helm") != string::npos) { equipHelm(table, itemNumber, uses); } else if (item.find("Gauntlets") != string::npos) { equipGauntlets(table, itemNumber, uses); } else if (item.find("Boots") != string::npos) { equipBoots(table, itemNumber, uses); } else if (item.find("Plate") != string::npos) { equipPlate(table, itemNumber, uses); } }
equipWeapon()
void equipWeapon(int table, int itemNumber, int uses) { if (player_eweapon[0][0] != 9) { etable = player_eweapon[0][0]; eitemNumber = player_eweapon[0][1]; euses = player_eweapon[0][2]; addInventory(etable, eitemNumber, euses); } player_eweapon[0][0] = table; player_eweapon[0][1] = itemNumber; player_eweapon[0][2] = uses; playersAttack = weapon_prop[itemNumber][1]; playersSpeed = weapon_prop[itemNumber][3]; }