Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- struct Player{
- string name;
- int health;
- int atk;
- int def;
- int mag;
- };
- struct Weapons{
- string name;
- int atk;
- int price;
- };
- struct Armors{
- string name;
- int def;
- int price;
- };
- struct Enemies{
- string name;
- int atk;
- int health;
- int def;
- };
- int main()
- {
- vector<Weapons> swords;
- vector<Weapons> axes;
- vector<Weapons> staffs;
- vector<Armors> heavy;
- vector<Armors> light;
- vector<Armors> mage;
- vector<Enemies> mobs;
- vector<Enemies> bosses;
- Player player;
- swords.push_back(Weapons());
- swords.push_back(Weapons());
- mobs.push_back(Enemies());
- swords[0].name = "Bastard Sword";
- swords[0].atk = 26;
- swords[0].price = 35;
- swords[1].name = "Broad Sword";
- swords[1].atk = 32;
- swords[1].price = 50;
- player.name = "Devlin";
- player.health = 100;
- player.def = 20;
- player.atk = 30;
- player.mag = 130;
- mobs[0].name = "Wood Troll";
- mobs[0].atk = 24;
- mobs[0].health = 100;
- mobs[0].def = 5;
- for (int i = 0; i < 2; i++)
- {
- cout << swords[i].name << ' ' << swords[i].atk << ' ' << swords[i].price << endl;
- }
- int turn = 1;
- int round = 1;
- while(mobs[0].health != 0 && player.health != 0)
- {
- cout << "At the start of round " << round << " Player's HP is: " << player.health << ", and "
- << mobs[0].name << " HP is: " << mobs[0].health << "\n";
- if(turn == 1 && player.health != 0) // player's attack
- {
- mobs[0].health = mobs[0].health - player.atk;
- if(mobs[0].health < 0)
- mobs[0].health = 0;
- turn = 0;
- }
- if(turn == 0 && mobs[0].health != 0)
- {
- player.health = player.health - mobs[0].atk;
- if(player.health < 0)
- player.health = 0;
- turn = 1;
- }
- if(mobs[0].health == 0)
- cout << "You have beat " << mobs[0].name << ".\n";
- if(player.health == 0)
- cout << "You died by the hand of the " << mobs[0].name << "\nHave a nice day!";
- round++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment