Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // NExt Gen Pokemon
- //
- // Created by Robin Michaelson on 26/6/17.
- // Copyright © 2017 Robin Michaelson. All rights reserved.
- //
- #include <iostream>
- #include <time.h>
- #include "Monster.h"
- //Functions
- Monster starter();
- Monster beginning();
- void attack(Monster&, Monster&);
- void defend(Monster&, Monster&);
- void fight(Monster&, Monster&, int);
- void firstbattle(Monster&, Monster&);
- int main()
- {
- srand(time(NULL));
- Monster player = beginning(),
- enemy("Reginald", 20, 3);
- firstbattle(player, enemy);
- system("PAUSE");
- return 0;
- }
- //The start of the epic journey, runs the starter function and names your Monster as well as sets the stats for your starter
- Monster beginning()
- {
- Monster temp;
- std::cout << "Welcome to the real world jackass!" << std::endl;
- temp = starter();
- std::cout << std::endl << "Really? You chose " << temp.getName() << ", lame but okay..." << std::endl;
- std::cout << "Your HP is " << temp.getHP() << std::endl;
- std::cout << "Your Attack stat is " << temp.getAtt() << std::endl;
- return temp;
- }
- //Sets the pointer for mymon to the starter you choose
- Monster starter()
- {
- int select,
- hp = rand() % 10 + 1,
- att = rand() % 5 + 1;
- std::cout << "Pick a fighter:" << std::endl;
- std::cout << "[1] Aggressive\n[2] Balanced\n[3] Defensive\n>";
- std::cin >> select;
- switch (select)
- {
- case 1:
- std::cout << "You've chosen 'Aggressive', now name it:" << std::endl;
- hp += 15;
- att += 5;
- break;
- case 2:
- std::cout << "You've chosen 'Balanced', now name it:" << std::endl;
- hp += 20;
- att += 3;
- break;
- case 3:
- std::cout << "You've chosen 'Defensive', now name it:" << std::endl;
- hp += 25;
- att += 1;
- break;
- default:
- std::cout << "Go fuck yourself!" << std::endl;
- return starter();
- }
- std::string name;
- std::cin >> name;
- return Monster(name, hp, att);
- }
- void attack(Monster& attacker, Monster& defender)
- {
- int attack;
- std::cout << "Choose your attack this turn " << std::endl;
- std::cout << " 1) Powerful 2) Accurate 3) Defensive " << std::endl;
- std::cin >> attack;
- fight(attacker, defender, attack);
- }
- void defend(Monster& attacker, Monster& defender)
- {
- int rando = rand() % 3 + 1;
- fight(attacker, defender, rando);
- }
- //Monster y is the one doing the attacking to x
- void fight(Monster& attacker, Monster& defender, int choice)
- {
- switch (choice)
- {
- case 1:
- std::cout << attacker.getName() << " uses a powerful attack!" << std::endl;
- if (rand() % 2)
- defender.subHp(2 * attacker.getAtt());
- else
- std::cout << "The attack missed!" << std::endl;
- break;
- case 2:
- std::cout << attacker.getName() << " uses an accurate attack!" << std::endl;
- defender.subHp(attacker.getAtt());
- break;
- case 3:
- std::cout << attacker.getName() << " uses a defensive attack and heals for half the damage done!" << std::endl;
- defender.subHp(attacker.getAtt() / 2);
- attacker.heal(attacker.getAtt() / 2);
- break;
- }
- std::cout << "HP of " << attacker.getName() << " is now " << attacker.getHP() << std::endl;
- std::cout << "HP of " << defender.getName() << " is now " << defender.getHP() << std::endl;
- std::cout << std::endl;
- }
- //Runs the first fight simulation
- void firstbattle(Monster& player, Monster& enemy)
- {
- std::cout << std::endl << "It's time for your first fight, cause that's just what we do in this world." << std::endl;
- do {
- attack(player, enemy);
- defend(enemy, player);
- } while (player.getHP() && enemy.getHP());
- if (player.getHP())
- std::cout << "Congratulations on your first victory..." << std::endl;
- else
- std::cout << "Go fuck yourself!" << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement