Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // if you don't understand it
- // translate it PL-EN
- ///////////////////////////////////////////////////
- // 1.copy this all code checked[1] to file main.cpp
- // 2.copy this all code checked[2] to file class.h
- // 3.copy this all code checked[3] to file class.cpp
- // 4.start your program and enjoy!
- // psss...you can edit code
- ///////////////////////////////////////
- // [1] //
- ///////////////////////////////////////
- #include "Class.h"
- map<int,string>EkwipunekG; // sluzy do przechowywania id ekwipunku
- map<int,string>::iterator it; // iterator do mapy EkwipunekG
- vector<bool>ValueBools; // typ bool tu przechowujemy czy zadanie zostalo rozpoczete czy nie (false/true) na poczatku jest false
- void Skills(Character* chr){
- system("cls");
- char wybor;
- char wyb1;
- static int dmg1;
- cout << "Skille info:\n";
- cout << "------------\n";
- cout << "1."<<chr->SkillName1<<endl;
- cout << "2."<<chr->SkillName2<<endl;
- cout << "0. wyjdz\n";
- cout << "Enter: ";
- wybor=getch();
- switch(wybor){
- case '0':{system("cls");return;}
- case '1': {
- system("cls");
- cout << "Edytuj skilla:\n";
- cout << "Nazwa: "<<chr->SkillName1<<endl;
- cout << "Typ: specjalny\n";
- cout << "Moc: nieokreslona\n";
- cout << "-----------------\n";
- cout << "Tego skilla nie da sie edytowac\n";
- cout << "0. aby wyjsc\n";
- cout << "Enter: ";
- wyb1=getch();
- if(wyb1=='0'){system("cls");return;}
- break;
- }
- case '2':{
- system("cls");
- cout << "Edytuj skilla:\n";
- cout << "Nazwa: "<<chr->SkillName2<<endl;
- cout << "Typ: normalny\n";
- cout << "Moc: "<<chr->skills2<<endl;
- cout << "-----------------\n";
- cout << "czy chcesz zwiekszyc moc?\n";
- dmg1+= 25;
- cout << "koszt wynosi: "<<dmg1<< " zlota.\n";
- cout << "1)tak\n";
- cout << "2)nie\n";
- cout << "Enter: ";
- wyb1=getch();
- if(wyb1=='1' && chr->getGold() >= chr->skills1_koszt){
- int g;
- system("cls");
- chr->skills1_koszt *= 2;
- g = chr->getGold();
- g -= chr->skills1_koszt;
- chr->setGold(g);
- cout << "pomyslnie kupiles ulepszenie!\n";
- chr->skills2+=10;
- cout << "teraz twoj skill ma +"<<chr->skills2<<" mocy!\n";
- cout << "nacisnij aby kontynuowac...";
- wyb1=getch();
- system("cls");
- }else if(wyb1=='1' && chr->getGold() < chr->skills1_koszt){
- system("cls");
- cout << "masz za malo zlota nie mozesz kupic tego\n";
- Sleep(3000);
- }else {system("cls");return;}
- break;
- }
- default: {system("cls");cout<<"Wybrales zla opcje!\n";Sleep(3000);system("cls");return;}
- }
- system("cls");
- }
- void LogicQuests(Character* acc){
- if(ValueBools[0] == true && acc->ZabiteMWilk >= acc->PolowanieMWilk){
- system("cls");
- int g;
- cout << "Udalo ci sie wykonac zadanie!\n";
- cout << "oto nagroda: " << 50 << " zlota";
- acc->ZabiteMWilk = 0;
- acc->PolowanieMWilk *= 2;
- g = acc->getGold();
- g += 25;
- acc->setGold(g);
- Sleep(5000);
- system("cls");
- }
- }
- void Quests(Character* acc){
- system("cls");
- char wybor;
- if(ValueBools[0] == true){
- cout <<"--------------------\n";
- cout << "Upoluj "<<acc->PolowanieMWilk<< " mlode wilki\n";
- cout << "Postep znajdziesz na dole\n";
- cout <<"["<<acc->ZabiteMWilk<<"/"<<acc->PolowanieMWilk<<"]"<<endl;
- cout <<"--------------------\n";
- }else {cout << "Nie masz zadnych zadan w tej chwili!\n";Sleep(3000);system("cls");return;}
- cout << "\n\nwcisnij cokolwiek aby kontynuowac...";
- wybor=getch();
- cout <<wybor;
- system("cls");
- }
- void Equipment(Character* acc){
- int wybor=0;
- system("cls");
- if(EkwipunekG.size() == 0){
- cout << "Nie masz nic w ekwipunku!\n";
- Sleep(3000);
- }else{
- for(auto it=EkwipunekG.begin();it!=EkwipunekG.end();it++){
- cout << it->first<<"."<<it->second<<endl;
- }
- cout << "Enter: ";
- cin >> wybor;
- if(!cin){
- cin.clear();
- cin.sync();
- system("cls");
- cout << "Nieprawidlowa opcja!\n";
- Sleep(3500);
- system("cls");
- return;
- }
- it = EkwipunekG.find(wybor);
- if(it != EkwipunekG.end()){
- acc->LogicEQ(it->second,it->first);
- }else {cout << "Nie znaleziono przedmiotu o takim id\n";Sleep(3000);}
- }
- system("cls");
- }
- void Shop(Character* acc){
- system("cls");
- char wybor=0;
- string wybierz;
- cout << "0)wyjdz\n";
- cout << "1)Mala mikstura zycia\n";
- cout << "Enter: ";
- wybor=getch();
- switch(wybor){
- case '0':{system("cls");return;}
- case '1': {
- system("cls");
- cout << "Leczy: 20 punktow zycia\n";
- cout << "Koszt zakupu: ["<<acc->Mikstura_01_koszt<<"] zlota!\n";
- cout << "Czy chcesz kupic?(Mala mikstura zycia\n)";
- cout << "wypisz (tak/Tak) lub (nie/Nie)\n";
- cout << "Enter: ";
- cin >> wybierz;
- if(wybierz == "tak" || wybierz == "Tak"){
- int g=0;
- if(acc->getGold() >= acc->Mikstura_01_koszt){
- acc->Mikstura_01_ilosc++;
- if(acc->Mikstura_01_ilosc <= 1)acc->iteruj++;
- EkwipunekG[acc->iteruj] = "MalaMiksturaZycia";
- g = acc->getGold();
- g -= acc->Mikstura_01_koszt;
- acc->setGold(g);
- system("cls");
- }else {system("cls");cout << "Nie masz na tyle zlota!\n";Sleep(4500);system("cls");}
- }else {system("cls");}
- break;}
- default: {system("cls");cout<<"Zla opcja!\n";Sleep(3500);system("cls");}
- }
- }
- void SaveGame(Character* acc){
- system("cls");
- string odp;
- cout << "Czy na pewno chcesz nadpisac stan gry?\n";
- cout << "wypisz (tak/Tak) lub (nie/Nie)\n";
- cout << "enter: ";
- cin >> odp;
- //if(!cin){cin.clear();cin.sync();system("cls");cout<<"Blad!\n";Sleep(2500);file.close();return;}
- if(odp=="tak" || odp=="Tak"){
- ofstream file;
- file.open("statystyki.txt",std::ofstream::out);
- if(!file.is_open()){
- system("cls");
- //jezeli sie nie da zapisac wyswietl komunikat o bledzie
- cout << "Blad przy zapisie danych!\n";
- cout << "Sprobuj ponownie.\n";
- Sleep(3000);
- system("cls");
- file.close();
- return;
- }else{
- file << acc->getHealth();
- file <<endl;
- file << acc->getMaxHealth();
- file <<endl;
- file << acc->getGold();
- file <<endl;
- file << acc->getAttack();
- file <<endl;
- file << acc->name;
- file <<endl;
- file << acc->getType();
- file <<endl;
- file << acc->PolowanieMWilk;
- file <<endl;
- file << acc->ZabiteMWilk;
- file <<endl;
- file << ValueBools[0];
- file <<endl;
- file << acc->eqiuppedWep;
- file <<endl;
- file << acc->EqWep;
- file <<endl;
- file << acc->iteruj;
- file <<endl;
- file << EkwipunekG[1];
- file <<endl;
- file << acc->Mikstura_01_ilosc;
- file <<endl;
- file << acc->skills1;
- }
- system("cls");
- cout << "Pomyslne zapisanie gry!\n";
- Sleep(3000);
- system("cls");
- // zamykamy plik
- file.close();
- }else {system("cls");return;}
- }
- Character* LoadGame(){
- ifstream file;
- int zycie=0;
- int zyciemax=0;
- int gold=0;
- int atak=0;
- int ZWilk1=0;
- int QWilk1=0;
- bool QTWilk1;
- int skillss1;
- bool ifwepun;
- int wep1S;
- int iterat1;
- int mik1_ilosc;
- string nazwa="unknown";
- string typ="unknown";
- string wth1="";
- file.open("statystyki.txt",std::ifstream::in);
- if(!file.is_open()){
- system("cls");
- cout << "\nBlad! statystyki gracza nie istnieja!\n";
- cout << "Musisz zaczac gre od nowa!\n";
- Sleep(4500);
- system("cls");
- }else{
- file >> zycie;
- file >> zyciemax;
- file >> gold;
- file >> atak;
- file >> nazwa;
- file >> typ;
- file >> QWilk1;
- file >> ZWilk1;
- file >> QTWilk1;
- file >> ifwepun;
- file >> wep1S;
- file >> iterat1;
- file >> wth1;
- file >> mik1_ilosc;
- file >> skillss1;
- }
- file.close();
- if(typ=="Wojownik"){
- system("cls");
- cout << "Laduje prosze czekac...";
- Sleep(4500);
- Warrior* wojownik = new Warrior(100,100,5,0,nazwa);
- wojownik->setGold(gold);
- wojownik->setHealth(zycie);
- wojownik->setMaxHealth(zyciemax);
- wojownik->setAttack(atak);
- wojownik->name = nazwa;
- wojownik->setType(typ);
- wojownik->PolowanieMWilk=QWilk1;
- wojownik->ZabiteMWilk=ZWilk1;
- ValueBools[0]=QTWilk1;
- wojownik->eqiuppedWep = ifwepun;
- wojownik->iteruj=iterat1;
- wojownik->EqWep = static_cast<EqBron>(wep1S);
- wojownik->skills1 = skillss1;
- if(mik1_ilosc != 0){
- EkwipunekG[1] = wth1;
- wojownik->Mikstura_01_ilosc = mik1_ilosc;}
- return wojownik;
- }else if(typ=="Lucznik"){
- system("cls");
- cout << "Laduje prosze czekac...";
- Sleep(4500);
- Archery* Lucznik = new Archery(60,60,14,0,nazwa);
- Lucznik->setGold(gold);
- Lucznik->setHealth(zycie);
- Lucznik->setMaxHealth(zyciemax);
- Lucznik->setAttack(atak);
- Lucznik->name = nazwa;
- Lucznik->setType(typ);
- Lucznik->PolowanieMWilk=QWilk1;
- Lucznik->ZabiteMWilk=ZWilk1;
- ValueBools[0]=QTWilk1;
- Lucznik->eqiuppedWep = ifwepun;
- Lucznik->iteruj=iterat1;
- Lucznik->EqWep = static_cast<EqBron>(wep1S);
- Lucznik->skills1 = skillss1;
- if(mik1_ilosc != 0){
- EkwipunekG[1] = wth1;
- Lucznik->Mikstura_01_ilosc = mik1_ilosc;}
- return Lucznik;
- }else if(typ=="Mag"){
- system("cls");
- cout << "Laduje prosze czekac...";
- Sleep(4500);
- Archery* Mag = new Archery(60,60,14,0,nazwa);
- Mag->setGold(gold);
- Mag->setHealth(zycie);
- Mag->setMaxHealth(zyciemax);
- Mag->setAttack(atak);
- Mag->name = nazwa;
- Mag->setType(typ);
- Mag->PolowanieMWilk=QWilk1;
- Mag->ZabiteMWilk=ZWilk1;
- ValueBools[0]=QTWilk1;
- Mag->eqiuppedWep = ifwepun;
- Mag->iteruj=iterat1;
- Mag->EqWep = static_cast<EqBron>(wep1S);
- Mag->skills1 = skillss1;
- if(mik1_ilosc != 0){
- EkwipunekG[1] = wth1;
- Mag->Mikstura_01_ilosc = mik1_ilosc;}
- return Mag;
- }else return NULL;
- }
- void Battle(Character* chr,Character* target){
- char wybor=0;
- system("cls");
- cout << "statystyki przeciwnika:\n";
- target->showStats();
- cout << "statystyki twoje:\n";
- chr->showStats();
- Sleep(3000);
- cout <<endl<<endl;
- for(int i=5;i>=0;i--){
- cout << "za [" << i <<"] zacznie sie walka"<<endl;
- Sleep(1000);
- }
- system("cls");
- //system walki
- int hp=0; // zmienna przechowuje tymczasowe zycie naszej postaci
- int mhp=0; // tymaczasowe potwora zycie
- int tura=1; // liczy tury co koniec rundy
- int Speedhits=0; // jezeli zaatakowalismy przeciwnika i mialismy go na strzala ustawiamy zmienna na 1 / odwrotnie przeciwnik mial nas na strzala
- cout << "rozpoczela sie walka pomiedzy\n";
- cout << chr->name<<" vs "<<target->name<<"!"<<endl;
- Sleep(3000);
- system("cls");
- do{
- system("cls");
- cout << "1)uzyj zwyklego ataku\n";
- cout << "2)uzyj skilla\n";
- cout << "3) opusc walke\n";
- cout << "Enter: ";
- wybor=getch();
- switch(wybor){
- case '1': {cout << "Atak zwykly";Sleep(3000);system("cls");break;}
- case '2': {chr->useSkills(target);break;}
- case '3': {system("cls");cout << "stchorzyles!";Sleep(3500);delete target;target=NULL;system("cls");return;}
- default: {cout << "nieznana opcja!";Sleep(3000);system("cls");}
- }
- if(target->getHealth()<=0){mhp=0;target->setHealth(mhp);Speedhits=1;Sleep(2500);break;}
- //zadawanie obrazen i wyswietlenie na ekranie
- if((chr->getBoolSkill() == false && chr->getSkillID() <= 0) || (chr->getBoolSkill() == true && chr->getSkillID() == 1)){
- cout << chr->name << " zaatakowal " << target->name<< " z sila "<<chr->getAttack()<<"!"<<endl;
- mhp = target->getHealth();
- mhp -= chr->getAttack();
- target->setHealth(mhp);
- if(target->getHealth()<=0){mhp=0;target->setHealth(mhp);Speedhits=1;Sleep(2500);break;}
- Sleep(2500);
- cout<<endl;}
- cout << target->name << " zaatakowal " << chr->name<< " z sila "<<target->getAttack()<<"!"<<endl;
- hp = chr->getHealth();
- hp -= target->getAttack();
- chr->setHealth(hp);
- if(chr->getHealth()<=0){hp=0;chr->setHealth(hp);Speedhits=1;Sleep(2500);break;}
- cout<<endl<<endl;
- Sleep(2500);
- // wyswietlamy informacje
- cout <<"Koniec tury: "<<tura<<endl;
- cout << "twoje zycie: "<<chr->getHealth()<<endl;
- cout << "przeciwnika zycie: "<<target->getHealth()<<endl;
- cout << "-------------------\n";
- Sleep(5000);
- cout <<endl <<endl;
- tura++; // inkrementujemy ture co koniec walki
- if(chr->cooldownSkill > 0)chr->cooldownSkill--;
- if(chr->getSkillID() == 1 || chr->getSkillID() == 2){chr->setBoolSkills(false);chr->setSkillID(0);}
- }while((chr->getHealth())>0 && (target->getHealth())>0);
- // tutaj jest koncowa tura jezeli trafilismy przeciwnika na strzala
- // lub przeciwnik trafil nas na strzala
- if(Speedhits == 1){
- cout<<endl;
- cout <<"Koniec tury: "<<tura<<endl;
- cout << "twoje zycie: "<<chr->getHealth()<<endl;
- cout << "przeciwnika zycie: "<<target->getHealth()<<endl;
- cout << "-------------------\n";
- Sleep(6000);
- }
- if(chr->getHealth() <= 0){
- system("cls");
- cout << "Przegrales!\n";
- cout << "Sprobuj innym razem!\n";
- chr->setBoolSkills(false);
- chr->setSkillID(0);
- chr->cooldownSkill = 0;
- delete target;
- }else if(target->getHealth() <= 0){
- system("cls");
- int numsrand = target->getGold();
- int goldmy=0;
- numsrand = rand()%numsrand+1;
- cout << "wygrales!\n";
- cout << "oto nagroda: "<<numsrand<<" zlota!"<<endl;
- goldmy = chr->getGold();
- goldmy += numsrand;
- chr->setGold(goldmy);
- chr->setBoolSkills(false);
- chr->setSkillID(0);
- chr->cooldownSkill=0;
- if(ValueBools[0] == true)chr->ZabiteMWilk++;
- if(target->getType() == "MlodyWilk" )ValueBools[0]=true;
- delete target;
- }
- target=NULL;
- cout << "Nacisnij dowolny klawisz...";
- wybor=getch();
- system("cls");
- }
- void ChooseDiffArena(Character* chr){
- system("cls");
- char wybor;
- int ran = 0;
- int hp;
- int atk;
- int gold;
- cout << "1)Easy\n";
- cout << "2)Medium\n";
- cout << "3)Hard\n";
- cout << "------\n";
- cout << "Enter: ";
- wybor=getch();
- switch(wybor){
- case '1': {
- ran = rand()%2+1;
- hp = rand()%(chr->getHealth()-10)+10;
- atk = rand()%(chr->getAttack()-1)+1;
- gold = rand()%10+3;
- if(ran == 1){
- Warrior* object1 = new Warrior(hp,hp,atk,gold,"Apocaliptus");
- Battle(chr,object1);
- }else if(ran == 2){
- hp = rand()%(chr->getHealth()-10)+10;
- atk = rand()%(chr->getAttack()-1)+1;
- gold = rand()%10+3;
- Archery* object1 = new Archery(hp,hp,atk,gold,"Nipetilus");
- Battle(chr,object1);
- }else if(ran == 3){
- hp = rand()%(chr->getHealth()-10)+10;
- atk = rand()%(chr->getAttack()-1)+1;
- gold = rand()%10+3;
- Mage* object1 = new Mage(hp,hp,atk,gold,"Elipse");
- Battle(chr,object1);
- }
- break;
- }
- // tutaj mozesz dodac kolejne poziomy trudnosci
- // bazujac na tym gorze...
- default: {system("cls");cout << "nieznana opcja!";Sleep(3000);system("cls");return;}
- }
- }
- void ChoiceBattle(Character* chr){
- system("cls");
- char wybor=0;
- Character* target=NULL;
- cout<<"WYBOR PRZECIWNIKA:\n";
- cout <<"-----------------\n";
- cout <<"1)Mlody Wilk\n";
- cout<<"Enter: ";
- wybor=getch();
- switch(wybor){
- case '1': {Wolf* youngWolf = new Wolf(60,60,3,10,"Mlody Wilk");target=youngWolf;Battle(chr,target);break;}
- default: {cout<<"nieprawidlowa opcja!\n";}
- }
- }
- void GameStart(Character* acc){
- char wybor=0;
- do{
- LogicQuests(acc);
- acc->showStats();
- cout << "----------"<<endl;
- cout <<"0) wyjsc z gry\n";
- cout <<"1)Walcz z potworami\n";
- cout <<"2)Arena"<<endl;
- cout <<"3)Ekwipunek"<<endl;
- cout << "4)Skille"<<endl;
- cout <<"5)Zadania"<<endl;
- cout <<"6)Sklep"<<endl;
- cout <<"7)Zapisz gre\n"<<endl;
- cout << "----------"<<endl;
- cout << "Enter: ";
- wybor=getch();
- switch(wybor){
- case '0':{system("cls");cout<<"Pomyslnie wyszedles z gry!\n";delete acc;exit(0);}
- case '1':{ChoiceBattle(acc);break;}
- case '2':{ChooseDiffArena(acc);break;}
- case '3':{Equipment(acc);break;}
- case '4':{Skills(acc);break;}
- case '5':{Quests(acc);break;}
- case '6':{Shop(acc);break;}
- case '7':{SaveGame(acc);break;}
- default: {system("cls");cout << "nieprawidlowa opcja!\n";}
- }
- }while(wybor!='0');
- }
- Character* character_selection(){
- char znak = 0;
- string name;
- cout << "witamy w rpg\n";
- cout << "aby stworzyc postac nacisnij na klawiaturze\n";
- cout << "podana liczbe na dole...\n";
- cout <<endl<<endl;
- cout<<"-------------\n";
- cout <<"Prosze podac najpierw \n";
- cout << "nazwe postaci\n";
- cout << "od 4 do 10 liter\n";
- cout << "nie moze przekraczac\n";
- cout << "Enter: ";
- cin >> name;
- // obsluga nazwy gracza
- if(name.length() >= 0 && name.length() <= 3){cout <<"za mala nazwe postaci podales!\n";exit(0);}
- else if(name.length() >= 10){cout << "za dluga nazwe postaci podales!\n";exit(0);}
- else if(!cin){
- cout << "failed name!\n";
- cout << "returned 0!\n";
- exit(0);
- }
- //petla ta wybiera i zwraca obiekt klasy
- do{
- cout<<"-------------\n";
- cout<<"0)aby wyjsc calkowicie\n";
- cout<<"1)Wojownik\n";
- cout<<"2)Lucznik\n";
- cout<<"3)Mag\n";
- cout <<"4)Wczytaj gre\n";
- cout << "Enter: ";
- znak = getch();
- cout << znak <<endl;
- switch(znak){
- case '0': {system("cls");cout<<"Pomyslnie wyszedles z gry!";break;}
- case '1':{Warrior* wojownik = new Warrior(100,100,10,0,name);return wojownik;}
- case '2':{Archery* lucznik = new Archery(50,50,18,0,name);return lucznik;}
- case '3':{Mage* Mag1 = new Mage(30,30,25,0,name);return Mag1;}
- case '4':{return LoadGame();}
- default: {system("cls");cout << "nieprawidlowa opcja!\n";}
- }
- }while(znak!='0');
- // jezeli 0 wybralismy wychodzimy z calego programu
- if(znak == '0')exit(0);
- // przeciwnym wypadku zwroc null
- return NULL;
- }
- int main(){
- Character* wsk; // glowny wskaznik na obiekt gracza ktorego bedziemy operowali we funkcjach
- wsk = character_selection(); // tworzymy najpierw obiekt klasy [Wojownik] lub [Lowca] lub [Mag] i wskazujemy wskaznikiem wsk na obiekt utworzony
- if(wsk == NULL){
- system("cls");
- cout << "Blad w wczytaniu postaci\n";
- cout << "lub anulowales\n";
- exit(0);
- }
- system("cls");
- // glowna mechanika gry w tej funkcja ponizej
- GameStart(wsk);
- // jezeli jakims cudem wyszedlismy z funkcji gameStart zwaliamy pamiec wsk
- delete wsk;
- return 0;
- }
- ///////////////////////////////////////
- // [2] //
- ///////////////////////////////////////
- #ifndef elo
- #define elo
- #include <iostream>
- #include <windows.h>
- #include <cstdlib>
- #include <time.h>
- #include <ctime>
- #include <conio.h> // obsluga klawiatury
- #include <fstream> // biblioteka sluzy do zapisywania plikow
- #include <map>
- #include <sstream>
- #include <vector>
- using namespace std;
- extern map<int,string>EkwipunekG;
- extern map<int,string>::iterator it;
- extern vector<bool>ValueBools;
- enum EqBron {uneqiupped=0,eq1=1};
- class Character{
- protected:
- bool skill;
- int hp;
- int hpMax;
- int attack;
- int gold;
- int skillID;
- string type;
- public:
- EqBron EqWep;
- bool quest1;
- bool eqiuppedWep;
- int PolowanieMWilk;
- int ZabiteMWilk;
- int cooldownSkill;
- // iterator po ekwipunku
- int iteruj;
- int Mikstura_01_ilosc;
- int Mikstura_01_koszt;
- int wepDmg;
- int skills1;
- int skills2;
- int skills1_koszt;
- string nameWep1;
- string name;
- string SkillName1;
- string SkillName2;
- // czysta metoda wirtualna
- virtual ~Character(){};
- virtual void showStats()=0;
- virtual int getHealth()=0;
- virtual void setHealth(int)=0;
- virtual int getAttack()=0;
- virtual int getGold()=0;
- virtual void setGold(int)=0;
- virtual bool getBoolSkill(){return false;}
- virtual void setBoolSkills(bool){};
- virtual int getSkillID(){return 0;}
- virtual void useSkills(Character*){};
- virtual void setSkillID(int){};
- virtual int getMaxHealth(){return 0;};
- virtual void setType(string){};
- virtual string getType(){return "";}
- virtual void setAttack(int){};
- virtual void setMaxHealth(int){};
- virtual void LogicEQ(string,int){};
- virtual void SkillsInfo(){};
- };
- class Warrior :public Character{
- public:
- Warrior(int,int,int,int,string);
- void showStats();
- int getHealth();
- void setHealth(int);
- int getAttack();
- int getGold();
- void setGold(int);
- void useSkills(Character*);
- bool getBoolSkill();
- void setBoolSkills(bool);
- int getSkillID();
- void setSkillID(int);
- int getMaxHealth();
- void setType(string);
- void setAttack(int);
- void setMaxHealth(int);
- string getType();
- void LogicEQ(string,int);
- void SkillsInfo();
- };
- class Archery :public Character{
- public:
- Archery(int,int,int,int,string);
- void showStats();
- int getHealth();
- void setHealth(int);
- int getAttack();
- int getGold();
- void setGold(int);
- void useSkills(Character*);
- bool getBoolSkill();
- void setBoolSkills(bool);
- int getSkillID();
- void setSkillID(int);
- int getMaxHealth();
- void setType(string);
- void setAttack(int);
- void setMaxHealth(int);
- string getType();
- void LogicEQ(string,int);
- void SkillsInfo();
- };
- class Mage :public Character{
- public:
- Mage(int,int,int,int,string);
- void showStats();
- int getHealth();
- void setHealth(int);
- int getAttack();
- int getGold();
- void setGold(int);
- void useSkills(Character*);
- bool getBoolSkill();
- void setBoolSkills(bool);
- int getSkillID();
- void setSkillID(int);
- int getMaxHealth();
- void setType(string);
- void setAttack(int);
- void setMaxHealth(int);
- string getType();
- void LogicEQ(string,int);
- void SkillsInfo();
- };
- class Wolf :public Character{
- public:
- Wolf(int,int,int,int,string);
- virtual void showStats();
- int getHealth();
- void setHealth(int);
- int getAttack();
- int getGold();
- void setGold(int);
- string getType();
- };
- #endif // elo
- ///////////////////////////////////////
- // [3] //
- ///////////////////////////////////////
- #include "Class.h"
- Warrior::Warrior(int h,int hm,int a,int g,string n){
- hp=h;
- hpMax=hm;
- attack=a;
- gold=g;
- name=n;
- type="Wojownik";
- eqiuppedWep=false;
- nameWep1="Bron nowicjuszy";
- cooldownSkill=0;
- skill=false;
- skillID=-1;
- SkillName1 = "Podwojny atak";
- SkillName2 = "Uzdrow siebie";
- quest1=false;
- PolowanieMWilk = 3;
- ZabiteMWilk = 0;
- ValueBools.push_back(false);
- iteruj=0;
- EkwipunekG[0] = nameWep1;
- Mikstura_01_ilosc=0;
- Mikstura_01_koszt=10;
- skills1_koszt=10;
- // wlasciwosci skille
- // (dmg - moc)
- skills1 = 10;
- skills2 = 20;
- wepDmg = 10;
- EqWep = uneqiupped;
- }
- void Warrior::showStats(){
- cout << "Nazwa: "<<name<<endl;
- cout << "Zycie: "<<hp<<"/"<<hpMax<<endl;
- cout << "atak: "<<attack<<endl;
- cout << "Zloto: "<<gold<<endl;
- cout << "Klasa: "<<type;
- cout<<endl;
- }
- int Warrior::getHealth(){
- return hp;
- }
- void Warrior::setHealth(int n){
- hp=n;
- }
- int Warrior::getAttack(){
- return attack;
- }
- int Warrior::getGold(){
- return gold;
- }
- void Warrior::setGold(int n){
- gold=n;
- }
- void Warrior::useSkills(Character* target){
- char wybor=0;
- int mhp=0;
- system("cls");
- cout << "Menu Skilli:\n";
- cout << "1)Podwojny atak\n";
- cout << "2)Uzdrow siebie(moc: "<<this->skills1<<")\n";
- cout << "Enter: ";
- wybor=getch();
- // if we have cooldownSkill = 0 we can use skills
- if(this->cooldownSkill==0){
- switch(wybor){
- case '1': {cout<<"Podwojny atak";Sleep(3000);this->skill=true;this->skillID=1;break;}
- case '2': {cout<<"Uzdrow siebie";Sleep(3000);this->skill=true;this->skillID=2;break;}
- default: {cout <<"nieznana opcja!\n";Sleep(4000);return;}
- }
- if(this->skill==true && this->skillID == 1){
- system("cls");
- cout << this->name << " zaatakowal " << target->name<< " z sila "<<this->getAttack()<<"!"<<endl;
- mhp = target->getHealth();
- mhp -= this->getAttack();
- target->setHealth(mhp);
- cout <<endl;cooldownSkill=3;}else if(this->skill==true && this->skillID == 2){
- system("cls");
- if(this->hp < this->hpMax){
- cout << "gracz "<<this->name<<" uzyl zaklecia uzdrow siebie!\n";
- this->hp += skills1;
- if(this->hp > this->hpMax)this->hp=this->hpMax;
- }
- else if(this->hp >= this->hpMax)cout<<"Masz pelne zycie!\n";
- cout << "twoje hp: "<<this->hp<<endl;
- this->cooldownSkill=5;
- Sleep(3000);
- system("cls");
- }
- }else {cout << "Nie mozesz teraz uzywac skillow poczekaj jeszcze: "<<this->cooldownSkill<<" tury!"<<endl;Sleep(3000);system("cls");}
- Sleep(2500);
- }
- bool Warrior::getBoolSkill(){
- return skill;
- }
- void Warrior::setBoolSkills(bool b){
- skill = b;
- }
- int Warrior::getSkillID(){
- return skillID;
- }
- void Warrior::setSkillID(int s){
- skillID = s;
- }
- int Warrior::getMaxHealth(){
- return hpMax;
- }
- void Warrior::setType(string n){
- type=n;
- }
- void Warrior::setAttack(int n){
- attack = n;
- }
- void Warrior::setMaxHealth(int n){
- hpMax = n;
- }
- string Warrior::getType(){
- return type;
- }
- void Warrior::LogicEQ(string nazwa,int id){
- if(nazwa == "MalaMiksturaZycia"){
- string wybor;
- cout << "Informacje:\n";
- cout << "-----------------\n";
- cout << "Nazwa przedmiotu: "<<nazwa<<endl;
- cout << "Ilosc: " << this->Mikstura_01_ilosc<<endl;
- cout << "Leczy: 20 punktow zycia\n";
- cout << "-----------------\n";
- cout << "czy chcesz uzyc przedmiotu?\n";
- cout << "(tak/Tak) lub (nie/Nie)\n";
- cout << "Enter: ";
- cin >> wybor;
- if(!cin){cin.clear();cin.sync();system("cls");cout<<"Blad!\n";Sleep(2500);system("cls");return;}
- if(wybor == "tak" || wybor == "Tak"){
- this->hp+=20;
- this->Mikstura_01_ilosc--;
- if(this->hp > this->hpMax){
- system("cls");
- cout << "Masz pelne zycie!\n";
- this->hp=hpMax;
- Sleep(3000);
- system("cls");
- }else if(this->hp <= this->hpMax) cout << "Uzyles przedmiotu!\n";
- if(this->Mikstura_01_ilosc == 0){
- EkwipunekG.erase(id);
- this->iteruj--;
- }
- }else return;
- }
- if(nazwa == "Bron nowicjuszy"){
- system("cls");
- char wybor;
- cout << "Informacje:\n";
- cout << "-----------------\n";
- cout << "Nazwa przedmiotu: "<<this->nameWep1<<endl;
- cout << "atak: " << this->wepDmg<<endl;
- cout << "-----------------\n";
- cout << "0)wyjdz\n";
- cout << "1)zalozyc\n";
- cout << "2)zdjac\n";
- cout << "Enter: ";
- wybor=getch();
- if(wybor == '0'){
- system("cls");return;
- }else if (wybor == '1'){
- if(eqiuppedWep == false && EqWep == 0){
- EqWep = eq1;
- eqiuppedWep = true;
- this->attack+=wepDmg;
- cout << "Pomyslnie zalozyles bron!\n";
- Sleep(3000);
- system("cls");
- }else {cout<<"Masz juz bron na siebie zalozona!\n";Sleep(3000);system("cls");}
- }
- else if(wybor == '2'){
- if(eqiuppedWep == true && EqWep != 0){
- if(EqWep == 1){
- this->attack-=wepDmg;
- }
- EqWep = uneqiupped;
- eqiuppedWep = false;
- cout << "Pomyslnie zdjales bron!\n";
- Sleep(3000);
- system("cls");
- }else {cout << "Nie masz zadnej broni zalozonej na siebie!\n";Sleep(3000);system("cls");return;}
- }else {cout << "prowadz poprawna opcje!\n";Sleep(3000);system("cls");return;}
- }
- }
- void Warrior::SkillsInfo(){
- };
- Archery::Archery(int h,int hm,int a,int g,string n){
- hp=h;
- hpMax=hm;
- attack=a;
- gold=g;
- name=n;
- type="Lucznik";
- eqiuppedWep=false;
- nameWep1="Luk nowicjuszy";
- cooldownSkill=0;
- skill=false;
- skillID=-1;
- SkillName1 = "Podwojny atak";
- SkillName2 = "Uzdrow siebie";
- quest1=false;
- PolowanieMWilk = 3;
- ZabiteMWilk = 0;
- ValueBools.push_back(false);
- iteruj=0;
- EkwipunekG[0] = nameWep1;
- Mikstura_01_ilosc=0;
- Mikstura_01_koszt=10;
- skills1_koszt=10;
- // wlasciwosci skille
- // (dmg - moc)
- skills1 = 10;
- skills2 = 20;
- wepDmg = 10;
- EqWep = uneqiupped;
- }
- void Archery::showStats(){
- cout << "Nazwa: "<<name<<endl;
- cout << "Zycie: "<<hp<<"/"<<hpMax<<endl;
- cout << "atak: "<<attack<<endl;
- cout << "Zloto: "<<gold<<endl;
- cout << "Klasa: "<<type;
- cout<<endl;
- }
- int Archery::getHealth(){
- return hp;
- }
- void Archery::setHealth(int n){
- hp=n;
- }
- int Archery::getAttack(){
- return attack;
- }
- int Archery::getGold(){
- return gold;
- }
- void Archery::setGold(int n){
- gold=n;
- }
- void Archery::useSkills(Character* target){
- char wybor=0;
- int mhp=0;
- int s=0;
- system("cls");
- cout << "Menu Skilli:\n";
- cout << "1)Super Atak\n";
- cout << "2)Uzdrow siebie(moc: "<<this->skills1<<")\n";
- cout << "Enter: ";
- wybor=getch();
- // if we have cooldownSkill = 0 we can use skills
- if(this->cooldownSkill==0){
- switch(wybor){
- case '1': {cout<<"Super atak";Sleep(3000);this->skill=true;this->skillID=1;break;}
- case '2': {cout<<"Uzdrow siebie";Sleep(3000);this->skill=true;this->skillID=2;break;}
- default: {cout <<"nieznana opcja!\n";Sleep(4000);return;}
- }
- if(this->skill==true && this->skillID == 1){
- system("cls");
- cout << this->name << " zaatakowal " << target->name<< " z sila "<<(this->getAttack()) + (this->attack / 2) <<"!"<<endl;
- s = (this->attack / 2);
- mhp = target->getHealth();
- mhp -= (this->getAttack()) + s;
- target->setHealth(mhp);
- cout <<endl;cooldownSkill=3;}else if(this->skill==true && this->skillID == 2){
- system("cls");
- if(this->hp < this->hpMax){
- cout << "gracz "<<this->name<<" uzyl zaklecia uzdrow siebie!\n";
- this->hp += skills1;
- if(this->hp > this->hpMax)this->hp=this->hpMax;
- }
- else if(this->hp >= this->hpMax)cout<<"Masz pelne zycie!\n";
- cout << "twoje hp: "<<this->hp<<endl;
- this->cooldownSkill=5;
- Sleep(3000);
- system("cls");
- }
- }else {cout << "Nie mozesz teraz uzywac skillow poczekaj jeszcze: "<<this->cooldownSkill<<" tury!"<<endl;Sleep(3000);system("cls");}
- Sleep(2500);
- }
- bool Archery::getBoolSkill(){
- return skill;
- }
- void Archery::setBoolSkills(bool b){
- skill = b;
- }
- int Archery::getSkillID(){
- return skillID;
- }
- void Archery::setSkillID(int s){
- skillID = s;
- }
- int Archery::getMaxHealth(){
- return hpMax;
- }
- void Archery::setType(string n){
- type=n;
- }
- void Archery::setAttack(int n){
- attack = n;
- }
- void Archery::setMaxHealth(int n){
- hpMax = n;
- }
- string Archery::getType(){
- return type;
- }
- void Archery::LogicEQ(string nazwa,int id){
- if(nazwa == "MalaMiksturaZycia"){
- string wybor;
- cout << "Informacje:\n";
- cout << "-----------------\n";
- cout << "Nazwa przedmiotu: "<<nazwa<<endl;
- cout << "Ilosc: " << this->Mikstura_01_ilosc<<endl;
- cout << "Leczy: 20 punktow zycia\n";
- cout << "-----------------\n";
- cout << "czy chcesz uzyc przedmiotu?\n";
- cout << "(tak/Tak) lub (nie/Nie)\n";
- cout << "Enter: ";
- cin >> wybor;
- if(!cin){cin.clear();cin.sync();system("cls");cout<<"Blad!\n";Sleep(2500);system("cls");return;}
- if(wybor == "tak" || wybor == "Tak"){
- this->hp+=20;
- this->Mikstura_01_ilosc--;
- if(this->hp > this->hpMax){
- system("cls");
- cout << "Masz pelne zycie!\n";
- this->hp=hpMax;
- Sleep(3000);
- system("cls");
- }else if(this->hp <= this->hpMax) cout << "Uzyles przedmiotu!\n";
- if(this->Mikstura_01_ilosc == 0){
- EkwipunekG.erase(id);
- this->iteruj--;
- }
- }else return;
- }
- if(nazwa == "Luk nowicjuszy"){
- system("cls");
- char wybor;
- cout << "Informacje:\n";
- cout << "-----------------\n";
- cout << "Nazwa przedmiotu: "<<this->nameWep1<<endl;
- cout << "atak: " << this->wepDmg<<endl;
- cout << "-----------------\n";
- cout << "0)wyjdz\n";
- cout << "1)zalozyc\n";
- cout << "2)zdjac\n";
- cout << "Enter: ";
- wybor=getch();
- if(wybor == '0'){
- system("cls");return;
- }else if (wybor == '1'){
- if(eqiuppedWep == false && EqWep == 0){
- EqWep = eq1;
- eqiuppedWep = true;
- this->attack+=wepDmg;
- cout << "Pomyslnie zalozyles bron!\n";
- Sleep(3000);
- system("cls");
- }else {cout<<"Masz juz bron na siebie zalozona!\n";Sleep(3000);system("cls");}
- }
- else if(wybor == '2'){
- if(eqiuppedWep == true && EqWep != 0){
- if(EqWep == 1){
- this->attack-=wepDmg;
- }
- EqWep = uneqiupped;
- eqiuppedWep = false;
- cout << "Pomyslnie zdjales bron!\n";
- Sleep(3000);
- system("cls");
- }else {cout << "Nie masz zadnej broni zalozonej na siebie!\n";Sleep(3000);system("cls");return;}
- }else {cout << "prowadz poprawna opcje!\n";Sleep(3000);system("cls");return;}
- }
- }
- void Archery::SkillsInfo(){
- };
- Mage::Mage(int h,int hm,int a,int g,string n){
- hp=h;
- hpMax=hm;
- attack=a;
- gold=g;
- name=n;
- type="Mag";
- eqiuppedWep=false;
- nameWep1="Rozdzka nowicjuszy";
- cooldownSkill=0;
- skill=false;
- skillID=-1;
- SkillName1 = "Podwojny atak";
- SkillName2 = "Uzdrow siebie";
- quest1=false;
- PolowanieMWilk = 3;
- ZabiteMWilk = 0;
- ValueBools.push_back(false);
- iteruj=0;
- EkwipunekG[0] = nameWep1;
- Mikstura_01_ilosc=0;
- Mikstura_01_koszt=10;
- skills1_koszt=10;
- // wlasciwosci skille
- // (dmg - moc)
- skills1 = 30;
- skills2 = 20;
- wepDmg = 5;
- EqWep = uneqiupped;
- }
- void Mage::showStats(){
- cout << "Nazwa: "<<name<<endl;
- cout << "Zycie: "<<hp<<"/"<<hpMax<<endl;
- cout << "atak: "<<attack<<endl;
- cout << "Zloto: "<<gold<<endl;
- cout << "Klasa: "<<type;
- cout<<endl;
- }
- int Mage::getHealth(){
- return hp;
- }
- void Mage::setHealth(int n){
- hp=n;
- }
- int Mage::getAttack(){
- return attack;
- }
- int Mage::getGold(){
- return gold;
- }
- void Mage::setGold(int n){
- gold=n;
- }
- void Mage::useSkills(Character* target){
- char wybor=0;
- int mhp=0;
- system("cls");
- cout << "Menu Skilli:\n";
- cout << "1)Podwojny atak\n";
- cout << "2)Uzdrow siebie(moc: "<<this->skills1<<")\n";
- cout << "Enter: ";
- wybor=getch();
- // if we have cooldownSkill = 0 we can use skills
- if(this->cooldownSkill==0){
- switch(wybor){
- case '1': {cout<<"Podwojny atak";Sleep(3000);this->skill=true;this->skillID=1;break;}
- case '2': {cout<<"Uzdrow siebie";Sleep(3000);this->skill=true;this->skillID=2;break;}
- default: {cout <<"nieznana opcja!\n";Sleep(4000);return;}
- }
- if(this->skill==true && this->skillID == 1){
- system("cls");
- cout << this->name << " zaatakowal " << target->name<< " z sila "<<this->getAttack()<<"!"<<endl;
- mhp = target->getHealth();
- mhp -= this->getAttack();
- target->setHealth(mhp);
- cout <<endl;cooldownSkill=3;}else if(this->skill==true && this->skillID == 2){
- system("cls");
- if(this->hp < this->hpMax){
- cout << "gracz "<<this->name<<" uzyl zaklecia uzdrow siebie!\n";
- this->hp += skills1;
- if(this->hp > this->hpMax)this->hp=this->hpMax;
- }
- else if(this->hp >= this->hpMax)cout<<"Masz pelne zycie!\n";
- cout << "twoje hp: "<<this->hp<<endl;
- this->cooldownSkill=5;
- Sleep(3000);
- system("cls");
- }
- }else {cout << "Nie mozesz teraz uzywac skillow poczekaj jeszcze: "<<this->cooldownSkill<<" tury!"<<endl;Sleep(3000);system("cls");}
- Sleep(2500);
- }
- bool Mage::getBoolSkill(){
- return skill;
- }
- void Mage::setBoolSkills(bool b){
- skill = b;
- }
- int Mage::getSkillID(){
- return skillID;
- }
- void Mage::setSkillID(int s){
- skillID = s;
- }
- int Mage::getMaxHealth(){
- return hpMax;
- }
- void Mage::setType(string n){
- type=n;
- }
- void Mage::setAttack(int n){
- attack = n;
- }
- void Mage::setMaxHealth(int n){
- hpMax = n;
- }
- string Mage::getType(){
- return type;
- }
- void Mage::LogicEQ(string nazwa,int id){
- if(nazwa == "MalaMiksturaZycia"){
- string wybor;
- cout << "Informacje:\n";
- cout << "-----------------\n";
- cout << "Nazwa przedmiotu: "<<nazwa<<endl;
- cout << "Ilosc: " << this->Mikstura_01_ilosc<<endl;
- cout << "Leczy: 20 punktow zycia\n";
- cout << "-----------------\n";
- cout << "czy chcesz uzyc przedmiotu?\n";
- cout << "(tak/Tak) lub (nie/Nie)\n";
- cout << "Enter: ";
- cin >> wybor;
- if(!cin){cin.clear();cin.sync();system("cls");cout<<"Blad!\n";Sleep(2500);system("cls");return;}
- if(wybor == "tak" || wybor == "Tak"){
- this->hp+=20;
- this->Mikstura_01_ilosc--;
- if(this->hp > this->hpMax){
- system("cls");
- cout << "Masz pelne zycie!\n";
- this->hp=hpMax;
- Sleep(3000);
- system("cls");
- }else if(this->hp <= this->hpMax) cout << "Uzyles przedmiotu!\n";
- if(this->Mikstura_01_ilosc == 0){
- EkwipunekG.erase(id);
- this->iteruj--;
- }
- }else return;
- }
- if(nazwa == "Rozdzka nowicjuszy"){
- system("cls");
- char wybor;
- cout << "Informacje:\n";
- cout << "-----------------\n";
- cout << "Nazwa przedmiotu: "<<this->nameWep1<<endl;
- cout << "atak: " << this->wepDmg<<endl;
- cout << "-----------------\n";
- cout << "0)wyjdz\n";
- cout << "1)zalozyc\n";
- cout << "2)zdjac\n";
- cout << "Enter: ";
- wybor=getch();
- if(wybor == '0'){
- system("cls");return;
- }else if (wybor == '1'){
- if(eqiuppedWep == false && EqWep == 0){
- EqWep = eq1;
- eqiuppedWep = true;
- this->attack+=wepDmg;
- cout << "Pomyslnie zalozyles bron!\n";
- Sleep(3000);
- system("cls");
- }else {cout<<"Masz juz bron na siebie zalozona!\n";Sleep(3000);system("cls");}
- }
- else if(wybor == '2'){
- if(eqiuppedWep == true && EqWep != 0){
- if(EqWep == 1){
- this->attack-=wepDmg;
- }
- EqWep = uneqiupped;
- eqiuppedWep = false;
- cout << "Pomyslnie zdjales bron!\n";
- Sleep(3000);
- system("cls");
- }else {cout << "Nie masz zadnej broni zalozonej na siebie!\n";Sleep(3000);system("cls");return;}
- }else {cout << "prowadz poprawna opcje!\n";Sleep(3000);system("cls");return;}
- }
- }
- void Mage::SkillsInfo(){
- };
- Wolf::Wolf(int h,int hm,int a,int g,string n){
- hp=h;
- hpMax=hm;
- attack=a;
- gold=g;
- name=n;
- type="MlodyWilk";
- cooldownSkill=0;
- skill=false;
- skillID=-1;
- }
- void Wolf::showStats(){
- cout << "Nazwa: "<<name<<endl;
- cout << "Zycie: "<<hp<<"/"<<hpMax<<endl;
- cout << "atak: "<<attack<<endl;
- cout << "Klasa: "<<type<<endl;
- cout<<endl;
- }
- int Wolf::getHealth(){
- return hp;
- }
- void Wolf::setHealth(int n){
- hp=n;
- }
- int Wolf::getAttack(){
- return attack;
- }
- int Wolf::getGold(){
- return gold;
- }
- void Wolf::setGold(int n){
- gold=n;
- }
- string Wolf::getType(){
- return type;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement