Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAIN
- #include <iostream>
- #include "Postacie.h"
- int main(int argc, char *argv[]) {
- cout << "TEST" << endl;
- Healer resto;
- Tank guardian;
- Dps feral;
- Boss Smok(30, 18, 30, 30);
- cout << resto.opis() << endl;
- cout << guardian.opis() << endl;
- cout << feral.opis() << endl;
- //Ustalenie kolejności ataku
- int tab_zre[3] = {guardian.zre(), feral.zre(), Smok.zre()};
- int kolejnosc[3] = {1, 2, 3};
- for(int i = 0; i < 3; i++) {
- for(int j = 0; j < 2; j++) {
- if(tab_zre[j] < tab_zre[j+1]) {
- swap(tab_zre[j], tab_zre[j+1]);
- swap(kolejnosc[j], kolejnosc[j+1]);
- }
- }
- }
- for(int i = 0; i < 3; i++) cout << tab_zre[i] << " " << kolejnosc[i] << endl;
- while(Smok.hp() > 0) {
- static int x = 0;
- if(kolejnosc[x] == 1) {
- cout << "Atakuje guardian" << endl;
- Smok.dmg(rand()%10);
- }
- else if(kolejnosc[x] == 2) {
- cout << "Atakuje feral" << endl;
- Smok.dmg(rand()%10);
- }
- else if(kolejnosc[x] == 3) {
- cout << "Atakuje Smok" << endl;
- }
- if(x == 3) cout << "Leczy healer" << endl;
- x++;
- if(x == 3) x = 0; // każdy atakował -> kolejka od nowa
- }
- }
- Postacie.cpp
- #include "Postacie.h"
- #include <stdlib.h>
- #include <stdio.h>
- Bohater::Bohater() {
- srand(time(NULL));
- _intel = rand()%30;
- _sila = rand()%30;
- _wytrz = rand()%30;
- _zre = rand()%30;
- _kryt = rand()%30;
- }
- string Bohater::opis() {
- return "| Klasa | HP | ATAK | UNIK | BLOK |\n| " + _klasa + " | " + to_string(_hp) + " | " + to_string(_atak.moc) + " | " + to_string(_unik) + " | " + " |\n";
- }
- Healer::Healer() {
- _klasa = "Healer";
- _hp = _wytrz * 10;
- _atak.moc = _intel * 2;
- _atak.szansa = rand()%100;
- _unik = _zre * 2;
- }
- Tank::Tank() {
- _klasa = "Tank";
- _hp = _wytrz * 20;
- _atak.moc = _sila * 5;
- _atak.szansa = rand()%100;
- _unik = _zre * 5;
- _blok.moc = (_wytrz + _zre) * 2;
- _blok.szansa = rand()%100;
- }
- Dps::Dps() {
- _klasa = "Dps";
- _hp = _wytrz * 7;
- _atak.moc = (_sila + _zre) * 4;
- _atak.szansa = rand()%100;
- _unik = _zre * 8;
- }
- Boss::Boss(int sila, int zre, int hp, int ulti) {
- _sila = sila;
- _zre = zre;
- _hp = hp;
- _ulti = ulti;
- }
- Postacie.h
- #include <string>
- using namespace std;
- struct parametr {
- int moc, szansa;
- };
- class Bohater {
- protected:
- string _klasa;
- int _intel;
- int _sila;
- int _wytrz;
- int _zre;
- int _kryt;
- int _hp;
- parametr _atak;
- int _unik;
- parametr _blok;
- parametr _prowokacja;
- public:
- Bohater();
- string klasa() { return _klasa; }
- int intel() { return _intel; }
- int sila() { return _sila; }
- int wytrz() { return _wytrz; }
- int zre() { return _zre; }
- int kryt() { return _kryt; }
- int hp() { return _hp; }
- parametr atak() { return _atak; }
- int unik() { return _unik; }
- parametr blok() { return _blok; }
- int dmg(int ile) { _hp -= ile; }
- string opis();
- };
- class Healer :public Bohater { public: Healer(); };
- class Tank :public Bohater { public: Tank(); };
- class Dps :public Bohater { public: Dps(); };
- class Boss {
- int _sila;
- int _zre;
- int _hp;
- int _ulti; // szansa na użycie ulta
- public:
- Boss(int sila, int zre, int hp, int ulti);
- int sila() { return _sila; }
- int zre() { return _zre; }
- int hp() { return _hp; }
- int ulti() { return _ulti; }
- int dmg(int ile) { _hp -= ile; }
- };
- Makefile
- all:
- g++ -std=c++0x *.cpp -o Boss_fight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement