Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <Windows.h>
- #include <vector>
- #include <string>
- #include <ctime>
- #include <conio.h>
- //#include "Entity.h"
- using namespace std;
- class World {};
- class Human;
- class Vampire;
- class Werewolf;
- //Press N to start, while console is open
- bool debug = true;
- int turn = 0;
- int people = 2000;
- int people_was = people;
- int sity = 1;//see sity_state()
- bool threat_awareness = false;
- class Obj : public World
- {};
- class Build : public Obj{};
- class House : public Build
- {};
- class Entity : public World
- {
- private:
- public:
- //string type;
- //virtual void suck() = 0;
- //virtual void convert() = 0;
- };
- vector<Vampire> vamps(0);
- vector<Human> humans(0);
- vector<Werewolf> wolfs(0);
- class Car : public Obj
- {};
- bool attack(double attacker, double defender)
- {
- double allforce;
- allforce = attacker + defender;
- int chance;
- int percent = allforce / 100;
- chance = allforce - defender;
- bool TrueFalse = (rand() % 100) < chance;
- return TrueFalse;
- }
- class Human : public Entity
- {
- private:
- double force;
- string type = "civil";
- bool alive = true;
- bool hystorical_figure = false;
- public:
- Human(){}
- Human(string in_type)
- {
- force = 1;
- if (in_type == "civil")
- {
- type = "civil";
- }
- if (in_type == "soldier")
- {
- force *= 3;
- type = "soldier";
- }
- if (in_type == "police")
- {
- force *= 2;
- type = "police";
- }
- humans.push_back(*this);
- }
- void set_aware(){ force *= 1.5; }
- string get_type()
- {
- return type;
- }
- double get_force()
- {
- return force;
- }
- bool is_alive()
- {
- return alive;
- }
- bool is_hystorical_figure()
- {
- return hystorical_figure;
- }
- void make_hystorical_figure()
- {
- hystorical_figure = true;
- }
- void kill()
- {
- alive = false;
- }
- void attack_vampire(Vampire &v)
- {
- bool succes = attack(get_force(), v.get_force());
- if(succes == true)
- {
- v.kill();
- }
- else kill();
- }
- void attack_werewolf(Werewolf &w)
- {
- bool succes = attack(get_force(), w.get_force());
- if (succes == true)
- {
- w.kill();
- }
- else kill();
- }
- };
- template <class Pick>
- int pick(vector<Pick> vec)
- {
- int out = 0 + rand() % vec.size();
- return out;
- }
- int vampire_coolness = 10;
- class Vampire : public Entity
- {
- private:
- int hunger; int generate = 1; double force;
- bool alive = true;
- //Vampire parent;
- public:
- Vampire(){ }
- Vampire(int gen)
- {
- //generate = v.generate;
- generate = gen + 1;
- force = 1 * (vampire_coolness/generate);//not 1 - it must have a human type force
- vamps.push_back(*this);
- //vamps.push_back(*this);
- //inc_generation();
- }
- void suck(Human &h)
- {
- //people--;
- if (h.is_alive() == true)
- {
- h.kill();
- }
- }
- double get_force()
- {
- return force;
- }
- void inc_generation(int gen)
- {
- generate = gen++;
- }
- int generation()
- {
- return generate;
- }
- bool is_alive()
- {
- return alive;
- }
- void kill()
- {
- alive = false;
- }
- void convert(Human &h)
- {
- //people--;
- if (h.is_alive() == true)
- {
- h.kill();
- Vampire *vamp = new Vampire(generate);
- }//vamp->inc_generation(generate); //vamp->generation() = v.generation(); }
- //vamp->inc_generation(); //vamp->inc_generation();
- //vamp->generation += 1;
- }
- void attack_human(Human &h)
- {
- bool succes = attack(get_force(), h.get_force());
- if (succes == true)
- {
- h.kill();
- }
- else kill();
- }
- void attack_werewolf(Werewolf &w)
- {
- bool succes = attack(get_force(), w.get_force());
- if (succes == true)
- {
- w.kill();
- }
- else kill();
- }
- };
- class Werewolf : public Entity
- {
- private:
- double force;
- bool alive = true;
- public:
- Werewolf()
- {
- force = 5;
- wolfs.push_back(*this);
- }
- double get_force()
- {
- return force;
- }
- bool is_alive()
- {
- return alive;
- }
- void kill()
- {
- alive = false;
- }
- void attack_human(Human &h)
- {
- bool succes = attack(get_force(), h.get_force());
- if (succes == true)
- {
- h.kill();
- }
- else kill();
- }
- void attack_vampire(Vampire &v)
- {
- bool succes = attack(get_force(), v.get_force());
- if (succes == true)
- {
- v.kill();
- }
- else kill();
- }
- };
- int hystorical_figures(char in_char)
- {
- int count = 0;
- for (int i = 0; i < humans.size(); i++)
- {
- if (in_char == 'a')
- {
- count++;
- }
- if (in_char == 'd')
- {
- count++;
- }
- }
- return count;
- }
- int humans_count(string in_string)
- {
- int count = 0;
- for (int i = 0; i < humans.size(); i++)
- {
- if (in_string == "all")
- {
- count++;
- }
- if (in_string == "alive")
- {
- if(humans[i].is_alive() == true)
- count++;
- }
- if (in_string == "dead")
- {
- if (humans[i].is_alive() == false)
- count++;
- }
- if (in_string == "civil")
- {
- if(humans[i].get_type() == "civil" && humans[i].is_alive() == true)
- count++;
- }
- if (in_string == "police")
- {
- if (humans[i].get_type() == "police" && humans[i].is_alive() == true)
- count++;
- }
- if (in_string == "soldier")
- {
- if (humans[i].get_type() == "soldier" && humans[i].is_alive() == true)
- count++;
- }
- }
- return count;
- }
- int vampire_count()
- {
- int count=0;
- for (int i = 0; i < vamps.size(); i++)
- {
- if(vamps[i].is_alive() == true)
- count++;
- }
- return count;
- }
- int werewolf_count()
- {
- int count = 0;
- for (int i = 0; i < wolfs.size(); i++)
- {
- if (wolfs[i].is_alive() == true)
- count++;
- }
- return count;
- }
- void game_turn()
- {
- int vamps_cpy = vamps.size();
- int wolfs_cpy = wolfs.size();
- srand(time(0));
- int act;// , pick;
- for (int i = 0; i < vamps_cpy; i++)
- {
- if (vamps[i].is_alive() == true)
- {
- if (threat_awareness == true)
- act = 1 + rand() % 2;
- else act = 1;
- if (act == 1)
- {
- act = 1 + rand() % 2;
- //pick = 0 + rand() % humans.size();
- if (act == 1 && vamps[i].generation() < 10)
- vamps[i].convert(humans[pick(humans)]);
- if (act == 2)
- vamps[i].suck(humans[pick(humans)]);
- }
- if (act == 2)
- {
- act = 1 + rand() % 2;
- if (act == 1)
- {
- vamps[i].attack_human(humans[pick(humans)]);
- }
- if (act == 2)
- {
- vamps[i].attack_werewolf(wolfs[pick(wolfs)]);
- }
- }
- }
- }
- for (int i = 0; i < wolfs_cpy; i++)
- {
- act = 1 + rand() % 2;
- if (wolfs[i].is_alive() == true)
- {
- if (act == 1)
- {
- wolfs[i].attack_human(humans[pick(humans)]);
- }
- if (act == 2)
- {
- wolfs[i].attack_vampire(vamps[pick(vamps)]);
- }
- }
- }
- if (threat_awareness == true)
- {
- for (int i = 0; i < humans.size(); i++)
- {
- if ((humans[i].get_type() == "police" || humans[i].get_type() == "soldier") && humans[i].is_alive() == true)
- {
- act = 1 + rand() % 2;
- if (act == 1)
- {
- humans[i].attack_vampire(vamps[pick(vamps)]);
- }
- if (act == 2)
- {
- humans[i].attack_werewolf(wolfs[pick(wolfs)]);
- }
- }
- }
- }
- turn++;
- }
- void sity_state()
- {
- int percents;
- int percent = people_was / 100;
- percents = humans_count("alive") / percent;
- cout << percents << "% people alive - ";
- if(percents > 90)
- {
- sity = 1;
- cout << "all still" << endl;
- }
- if (percents < 90 && percents > 61)
- {
- sity = 2;
- cout << "police panic" << endl;
- }
- if (percents < 60 && percents > 31)
- {
- sity = 3;
- if(threat_awareness == false)
- {
- for (int i = 0; i < people / 10; i++)
- {
- Human *civil = new Human("soldier");
- }
- }
- threat_awareness = true;
- cout << "massive army forses invade into sity" << endl;
- }
- if (percents < 31 )
- {
- sity = 4;
- cout << "Apocalypse come" << endl;
- }
- }
- void results()
- {}
- void game_process()
- {
- while (humans_count("alive") > 0)
- {
- system("cls");
- cout << "Turn: " << turn << endl;
- cout << "Humans: " << humans_count("alive") << "(" << " Civils: " << humans_count("civil") << " Police: " << humans_count("police") << "cars: " << " Army: " << humans_count("soldier")<< " armored vechines: " << " aviation: " << ")" << " Humans dead: " << humans_count("dead") << endl;
- cout << "Vamps: " << vampire_count()<<endl;
- cout << "Werewolfs:" << werewolf_count() << endl;
- sity_state();
- if (debug == true)
- {
- //events()
- //hystorical figures()
- for (int i = 1; i < 11; i++)
- {
- int k = 0;
- cout << "Vamps of " << i << "'st generation count: ";
- for (int j = 0; j < vamps.size(); j++)
- {
- if (vamps[j].generation() == i)
- k++;
- }
- cout << k << endl;
- }
- }
- Sleep(1000);
- game_turn();
- }
- cout << endl << "game over" << endl;
- results();
- }
- void game_init()
- {
- for (int i = 0; i < people; i++)
- {
- Human *civil = new Human("civil");
- //civil->set_type("civil");
- }
- for (int i = 0; i < people/100; i++)
- {
- Human *civil = new Human("police");
- //civil->set_type("police");
- }
- for (int i = 0; i < people/150; i++)
- {
- Human *civil = new Human("soldier");
- //civil->set_type("soldier");
- }
- Vampire *cain = new Vampire(0);
- Werewolf *wolfy = new Werewolf;
- game_process();
- }
- int menu()
- {
- cout << "n - new game" << endl;
- cout << "l - load" << endl;
- cout << "a - about" << endl;
- cout << "x - exit" << endl;
- char input = _getch();
- if (input == 'n')
- {
- return 1;
- }
- if (input == 'l')
- {
- return 2;
- }
- if (input == 'a')
- {
- return 3;
- }
- if (input == 'x')
- {
- return 0;
- }
- }
- void game()
- {
- switch (menu())
- {
- case 0:
- break;
- case 1:
- game_init();
- break;
- case 2:
- cout << "This feature for future";
- break;
- case 3:
- cout << "This feature for future";
- break;
- default:
- cout << "error, please try again; you input must be in english languagagagage" << endl;
- game();
- break;
- }
- }
- int main()
- {
- srand(time(0));
- game();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement