diff --git a/8303/Rudko/Lab1.pro b/8303/Rudko/Lab1.pro
new file mode 100644
index 000000000..5f8431352
--- /dev/null
+++ b/8303/Rudko/Lab1.pro
@@ -0,0 +1,32 @@
+TEMPLATE = app
+CONFIG += console c++11
+CONFIG -= app_bundle
+CONFIG -= qt
+
+SOURCES += \
+ base.cpp \
+ facade.cpp \
+ gfield.cpp \
+ log.cpp \
+ main.cpp \
+ memento.cpp \
+ ruls.cpp \
+ unit.cpp
+
+HEADERS += \
+ base.h \
+ deathcard.h \
+ facade.h \
+ forest.h \
+ gfield.h \
+ land.h \
+ landscape.h \
+ log.h \
+ memento.h \
+ negativecard.h \
+ neutralobkect.h \
+ positivecard.h \
+ ruls.h \
+ swamp.h \
+ transformationcard.h \
+ unit.h
diff --git a/8303/Rudko/Lab1.pro.user b/8303/Rudko/Lab1.pro.user
new file mode 100644
index 000000000..3838dcfe9
--- /dev/null
+++ b/8303/Rudko/Lab1.pro.user
@@ -0,0 +1,335 @@
+
+
+
+
+
+ EnvironmentId
+ {bb09a948-71ad-4074-8d70-741e8da24e7f}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ true
+ false
+ 0
+ true
+ true
+ 0
+ 8
+ true
+ 1
+ true
+ true
+ true
+ false
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ true
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop Qt 5.12.2 GCC 64bit
+ Desktop Qt 5.12.2 GCC 64bit
+ qt.qt5.5122.gcc_64_kit
+ 0
+ 0
+ 0
+
+ /home/dan/Proects_2_kurs/PI/OOP/build-Lab1-Desktop_Qt_5_12_2_GCC_64bit-Debug
+
+
+ true
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ true
+
+ false
+ false
+ false
+
+
+ true
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Сборка
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Очистка
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Отладка
+ Отладка
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+ true
+
+
+ /home/dan/Proects_2_kurs/PI/OOP/build-Lab1-Desktop_Qt_5_12_2_GCC_64bit-Release
+
+
+ true
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+
+ false
+ false
+ true
+
+
+ true
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Сборка
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Очистка
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Выпуск
+ Выпуск
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ true
+
+
+ /home/dan/Proects_2_kurs/PI/OOP/build-Lab1-Desktop_Qt_5_12_2_GCC_64bit-Profile
+
+
+ true
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ true
+
+ false
+ true
+ true
+
+
+ true
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+
+ false
+
+
+ false
+
+ 2
+ Сборка
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+
+ true
+ clean
+
+ false
+
+ 1
+ Очистка
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Профилирование
+ Профилирование
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ true
+
+ 3
+
+
+ 0
+ Установка
+
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ Конфигурация установки
+
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+
+ dwarf
+
+ cpu-cycles
+
+
+ 250
+ -F
+ true
+ 4096
+ false
+ false
+ 1000
+
+ true
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ kcachegrind
+ 1
+ 25
+
+ 1
+ true
+ false
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ 2
+
+ Lab1
+
+ Qt4ProjectManager.Qt4RunConfiguration:/home/dan/Proects_2_kurs/PI/OOP/Lab1/Lab1.pro
+
+ 3768
+ false
+ true
+ true
+ false
+ false
+ true
+
+ /home/dan/Proects_2_kurs/PI/OOP/build-Lab1-Desktop_Qt_5_12_2_GCC_64bit-Debug
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 21
+
+
+ Version
+ 21
+
+
diff --git a/8303/Rudko/base.cpp b/8303/Rudko/base.cpp
new file mode 100644
index 000000000..0a895fe29
--- /dev/null
+++ b/8303/Rudko/base.cpp
@@ -0,0 +1,198 @@
+#include "base.h"
+#include
+
+Base::Base(int x, int y, GField* field){
+ this->field = field;
+ if(field->map1[x][y]->type == "landscape" && !flag_base){
+ Unit* BASE = new Unit;
+ BASE->x = x;
+ BASE->y = y;
+ base_x = x;
+ base_y = y;
+ base_helth = 1000;
+ BASE->health = 1000;
+ BASE->type = "base";
+ BASE->name = "BASE";
+ field->map1[x][y] = BASE;
+ flag_base = 1;
+ }
+}
+
+void Base::CreatureUnit(int x, int y, std::string Name){
+ Unit* unit;
+ //std::vector> map = field->getMap();
+ if(Name == "scorpio") { unit = new Scorpio(); }//num++; }
+ if(Name == "mammoth") { unit = new Mammoth(); }//num++; }
+ if(Name == "frog") { unit = new Frog(); }//num++; }
+ if(Name == "kangaroo"){ unit = new Kangaroo(); }//num++; }
+ if(Name == "swallow") { unit = new Swallow(); }//num++; }
+ if(Name == "hawk") { unit = new Hawk(); }//num++; }
+ if(field->map1[x][y]->type == "landscape"){
+ counter++;
+ if(counter > 7)
+ std::cout << "На поле максимальное количество юнитов" << std::endl;
+ else
+ field->addUnit(unit, x, y);
+ }
+}
+
+void Base::Condition(){
+ std::cout << "Coordinats = " << base_x << ' ' << base_y << std::endl;
+ std::cout << "Helth = " << base_helth << std::endl;
+ std::cout << "People on the field = " << counter << std::endl;
+}
+
+int Base::Control(int x, int y, std::string answer, int num){
+ //std::cout << x << ' ' << y << std::endl;
+ if(x >= field->getLength() || y >= field->getLength() || x < 0 || y < 0){
+ std::cout << "Ввседите координаты удовлетворяющие полю" << std::endl;
+ }
+ else {
+ if(num == 2){
+ srand(time(NULL));
+ int j = rand()% 666;
+ if(j % 4 == 0){ answer = 'L'; }
+ if(j % 4 == 1){ answer = 'U'; }
+ if(j % 4 == 2){ answer = 'R'; }
+ if(j % 4 == 3){ answer = 'D'; }
+ }
+ std::cout << answer << std::endl;
+ if(answer != "L" && answer != "R" && answer != "U" && answer != "D")
+ std::cout << "Введите существующие команды" << std::endl;
+ else {
+ if(answer == "L"){
+ if(field->map1[x][y-1]->type == "landscape"){
+ if(field->getLand()->isMoved(field->map1[x][y]))
+ if(field->getLand()->isDamage(field->map1[x][y])){
+ field->map1[x][y]->health -= 3;
+ std::cout << "! Воин получил урон в размере 3 едениц !" << std::endl;
+ field->moveUnite(field->map1[x][y], x, y-1);
+ return 0;
+ }else {
+ field->moveUnite(field->map1[x][y], x, y-1);
+ return 0;
+ }
+ else{
+ std::cout << "Воин не может передвигаться по даннаму типу ландшафта" << std::endl;
+ return 0;
+ }
+ }//s
+ else {
+ if(field->map1[x][y-1]->type == "base" && num){
+ field->map1[x][y-1]->health -= field->map1[x][y]->health;
+ if(field->map1[x][y-1]->health <= 0)
+ {
+ std::cout << "База уничтожена!" << std::endl;
+ return 1;
+ }
+ }
+ std::cout << field->map1[x][y-1]->type << std::endl;
+ return 0;
+ }
+ }
+ if(answer == "R"){
+ if(field->map1[x][y+1]->type == "landscape"){
+ if(field->getLand()->isMoved(field->map1[x][y]))
+ if(field->getLand()->isDamage(field->map1[x][y])){
+ field->map1[x][y]->health -= 3;
+ std::cout << "! Воин получил урон в размере 3 едениц !" << std::endl;
+ field->moveUnite(field->map1[x][y], x, y+1);
+ return 0;
+ }else {
+ field->moveUnite(field->map1[x][y], x, y+1);
+ return 0;
+ }
+ else{
+ std::cout << "Воин не может передвигаться по даннаму типу ландшафта" << std::endl;
+ return 0;
+ }
+ }
+ else {
+ if(field->map1[x][y+1]->type == "base" && num){
+ field->map1[x][y+1]->health -= field->map1[x][y]->health;
+ if(field->map1[x][y+1]->health <= 0)
+ {
+ std::cout << "База уничтожена!" << std::endl;
+ return 1;
+ }
+ }
+ return 0;
+ }
+ }
+ if(answer == "U"){
+ if(field->map1[x-1][y]->type == "landscape"){
+ if(field->getLand()->isMoved(field->map1[x][y]))
+ if(field->getLand()->isDamage(field->map1[x][y])){
+ field->map1[x][y]->health -= 3;
+ std::cout << "! Воин получил урон в размере 3 едениц !" << std::endl;
+ field->moveUnite(field->map1[x][y], x-1, y);
+ return 0;
+ }else {
+ field->moveUnite(field->map1[x][y], x-1, y);
+ return 0;
+ }
+ else{
+ std::cout << "Воин не может передвигаться по даннаму типу ландшафта" << std::endl;
+ return 0;
+ }
+ }
+ else {
+ if(field->map1[x-1][y]->type == "base" && num){
+ field->map1[x-1][y]->health -= field->map1[x][y]->health;
+ if(field->map1[x-1][y]->health <= 0)
+ {
+ std::cout << "База уничтожена!" << std::endl;
+ return 1;
+ }
+ }
+ return 0;
+ }
+ }
+ if(answer == "D"){
+ if(field->map1[x+1][y]->type == "landscape"){
+ if(field->getLand()->isMoved(field->map1[x][y])){
+ if(field->getLand()->isDamage(field->map1[x][y])){
+ field->map1[x][y]->health -= 3;
+ std::cout << "! Воин получил урон в размере 3 едениц !" << std::endl;
+ field->moveUnite(field->map1[x][y], x+1, y);
+ return 0;
+ }else {
+ //std::cout << field->map1[x][y]->x << ' ' << field->map1[x][y]->y << std::endl;
+ //std::cout << x << ' ' << y << std::endl;
+ field->moveUnite(field->map1[x][y], x+1, y);
+ return 0;
+ }
+ }
+ else{
+ std::cout << "Воин не может передвигаться по даннаму типу ландшафта" << std::endl;
+ return 0;
+ }
+ }
+ else {
+ std::cout << field->map1[x+1][y]->type << std::endl;
+ if(field->map1[x+1][y]->type == "base" && num){
+ std::cout << "TUT" << std::endl;
+ field->map1[x+1][y]->health -= field->map1[x][y]->health;
+ this->base_helth -= field->map1[x][y]->health;
+ if(field->map1[x+1][y]->health <= 0)
+ {
+ std::cout << "База уничтожена!" << std::endl;
+ return 1;
+ }
+ }
+ return 0;
+ }
+ }
+ std::cout << "Клетка игрового поля занята" << std::endl;
+ return 0;
+ }
+ }
+
+}
+
+int Base::getCount(){
+ return counter;
+}
+int Base::getHealth(){
+ return base_helth;
+}
diff --git a/8303/Rudko/base.h b/8303/Rudko/base.h
new file mode 100644
index 000000000..373e6cff6
--- /dev/null
+++ b/8303/Rudko/base.h
@@ -0,0 +1,26 @@
+#ifndef BASE_H
+#define BASE_H
+
+#include "unit.h"
+#include "gfield.h"
+#include
+
+class Base
+{
+private:
+ GField* field;
+ int base_helth;
+ int base_x, base_y;
+ bool flag_base = 0;
+
+public:
+ int counter = 0;
+ Base(int, int, GField*);
+ void CreatureUnit(int, int, std::string);
+ int getCount();
+ int getHealth();
+ void Condition();
+ int Control(int, int, std::string, int);
+};
+
+#endif // BASE_H
diff --git a/8303/Rudko/deathcard.h b/8303/Rudko/deathcard.h
new file mode 100644
index 000000000..d2978cce1
--- /dev/null
+++ b/8303/Rudko/deathcard.h
@@ -0,0 +1,25 @@
+#ifndef DEATHCARD_H
+#define DEATHCARD_H
+
+#include "neutralobkect.h"
+#include "gfield.h"
+
+class DeathCard : public Neutral
+{
+private:
+ std::string name_death;
+ GField* field;
+public:
+ DeathCard(GField* field){}
+ std::string name() override{
+ name_death = "death_card";
+
+ }
+ void operator /(Unit* unit){
+ this->field = field;
+ field->deleteUnite(unit);
+ }
+
+};
+
+#endif // DEATHCARD_H
diff --git a/8303/Rudko/facade.cpp b/8303/Rudko/facade.cpp
new file mode 100644
index 000000000..3616f3523
--- /dev/null
+++ b/8303/Rudko/facade.cpp
@@ -0,0 +1,132 @@
+#include "facade.h"
+
+void Facade::NewGame(int length, int initial_quantity){
+ l = new log;
+ l1 = new log(1);
+ field = new GField(length, length);
+ field->addLabdscape();
+ field->addNeutralObject("positive card");
+ field->addNeutralObject("negative card");
+ field->addNeutralObject("transform card");
+ base = new Base(1, 1, this->field);
+ if(initial_quantity == 3){
+ base->CreatureUnit(0, 2, "scorpio");
+ l1->logt("base", 3, 0, 2, "scorpio");
+ base->CreatureUnit(0, 4, "frog");
+ l1->logt("base", 3, 0, 4, "frog");
+ base->CreatureUnit(0, 6, "swallow");
+ l1->logt("base", 3, 0, 6, "swallow");
+ Play(2);
+ }
+ else {
+ base->CreatureUnit(0, 2, "scorpio");
+ l1->logt("base", 3, 0, 2, "scorpio");
+ base->CreatureUnit(0, 4, "frog");
+ l1->logt("base", 3, 0, 4, "frog");
+ base->CreatureUnit(0, 6, "swallow");
+ l1->logt("base", 3, 0, 6, "swallow");
+ base->CreatureUnit(0, 5, "kangaroo");
+ l1->logt("base", 3, 0, 5, "kangaroo");
+ base->CreatureUnit(0, 3, "mammoth");
+ l1->logt("base", 3, 0, 3, "mammoth");
+ base->CreatureUnit(0, 7, "hawk");
+ l1->logt("base", 3, 0, 7, "hawk");
+ Play(1);
+ }
+}
+
+void Facade::Play(int num){
+ std::cout << "Now playning" << std::endl;
+ std::string answer;
+ std::string name;
+ int x,y;
+ int k = 0;
+ while(answer != "exit"){
+ std::cout << "> ";
+ std::cin >> answer;
+ if(answer != "exit")
+ if(answer != "save")
+ if(answer != "display")
+ if(answer != "base")
+ if(answer != "new")
+ std::cin >> x >> y;
+ if(answer != "exit"){
+ if(answer == "base"){
+ l->logf(answer, 1, 0, 0, "chek");
+ l->logf(answer, 3, 0, 0, "base");
+ base->Condition();
+ }
+ else {
+ if(answer == "add"){
+ l->logf(answer, 1, 0, 0, "add");
+ std::cin >> name;
+ l->logf(answer, 3, 0, 0, name);
+ l->logf(answer, 2, x, y, name);
+ base->CreatureUnit(x, y, name);
+ field->printField();
+ }
+ else {
+ if(answer == "save"){
+ l->logf(answer, 1, 0, 0, "save");
+ std::string p = "Save.txt";
+ s = new Memento(p);
+ s->record(field);
+ s->~Memento();
+ }
+ else {
+ if(answer == "display"){
+ l->logf(answer, 1, 0, 0, "display");
+ s = new Memento;
+ s->display();
+ s->~Memento();
+ }
+ else {
+ if(answer == "new"){
+ l->logf(answer, 1, 0, 0, "new");
+ std::cout << "Выберите вариант игры, 1 или 2" << std::endl;
+ int number;
+ std::cin >> number;
+ while(1){
+ if(number != 1 && number != 2){
+ std::cout << "Выберите 1 или 2" << std::endl;
+ std::cin >> number;
+ }
+ else {
+ break;
+ }
+ }
+ if(number == 1)
+ NewGame(10, 6);
+ if(number == 2)
+ NewGame(7, 3);
+
+ }
+ else {
+ std::string n = field->map1[x][y]->name;
+ l->logf(answer, 2, x, y, n);
+ int f = base->Control(x, y, answer, num);
+ k++;
+ std::cout << "f = " << f << std::endl;
+ if(f){
+ l->logf("Destroy", 3, 0, 0, "base");
+ std::cout << "Вы проиграли" << std::endl;
+ answer = "exit";
+ }
+ if(num && k > 13 && base->getHealth() > 0){
+ l->logf("Win", 3, 0, 0, "base");
+ std::cout << "Вы выиграли! Победа!" << std::endl;
+ answer = "exit";
+ }
+
+ field->printField();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ l->logf(answer, 1, 0, 0, "exit");
+ l->~log();
+ std::cout << "Всего хорошего!" << std::endl;
+}
diff --git a/8303/Rudko/facade.h b/8303/Rudko/facade.h
new file mode 100644
index 000000000..3b00d4b8e
--- /dev/null
+++ b/8303/Rudko/facade.h
@@ -0,0 +1,26 @@
+#ifndef FACADE_H
+#define FACADE_H
+
+#include "unit.h"
+#include "gfield.h"
+#include "base.h"
+#include "memento.h"
+#include "log.h"
+
+#include
+
+class Facade
+{
+private:
+ GField* field;
+ Base* base;
+ Memento* s;
+ log* l;
+ log* l1;
+
+public:
+ void NewGame(int, int);
+ void Play(int);
+};
+
+#endif // FACADE_H
diff --git a/8303/Rudko/forest.h b/8303/Rudko/forest.h
new file mode 100644
index 000000000..001563c71
--- /dev/null
+++ b/8303/Rudko/forest.h
@@ -0,0 +1,34 @@
+#ifndef FOREST_H
+#define FOREST_H
+
+#include "landscape.h"
+
+class Forest: public Landscape, public Unit
+{
+public:
+ Forest(){
+ this->type = "landscape";
+ this->name = "forest";
+ };
+
+
+ bool isMoved(Unit* unit) override{
+ if(unit->type == "MeleeWarrior")
+ return true;
+ if(unit->type == "MediumWarrior")
+ return true;
+ if(unit->type == "DistanceWarrior")
+ return true;
+ }
+
+ bool isDamage(Unit* unit) override{
+ if(unit->type == "MeleeWarrior")
+ return true;
+ if(unit->type == "MediumWarrior")
+ return true;
+ if(unit->type == "DistanceWarrior")
+ return false;
+ }
+};
+
+#endif // FOREST_H
diff --git a/8303/Rudko/gfield.cpp b/8303/Rudko/gfield.cpp
new file mode 100644
index 000000000..a11b69f28
--- /dev/null
+++ b/8303/Rudko/gfield.cpp
@@ -0,0 +1,137 @@
+#include "gfield.h"
+
+using namespace std;
+
+GField::GField(int x, int y) {
+ x = max(x,y);
+ this->length = x;
+ this->width = x;
+ this->numberUnit = 0;
+
+ //map = new Unit** [this->length];
+ map1.resize(this->width);
+ for (int i = 0; i < this->width; i++)
+ {
+ //map[i] = new Unit* [x];
+ map1[i].resize(this->length);
+ for (int j = 0; j < this->length; j++){
+ //map[i][j] = nullptr;
+ map1[i][j] = nullptr;
+ }
+ }
+
+
+}
+
+GField::GField(const GField &gfield) {}
+
+
+
+void GField::addUnit(Unit* unite, int x, int y) {
+ if (x < this->length && y < this->width ){
+ map1[x][y] = unite;
+ unite->x = x;
+ unite->y = y;
+ }
+ }
+
+void GField::moveUnite(Unit* unite, int newx, int newy) {
+ if (map1[newx][newy]->type == "landscape") {
+ int a = unite->x, b = unite->y;
+ land = new Land;
+ addUnit(land, a, b);
+ unite->move(newx, newy);
+ unite->x = newx;
+ unite->y = newy;
+ map1[unite->x][unite->y] = unite;
+ }
+ else {
+ std::cout << "Клетка игрового поля занята" << std::endl;
+ }
+ }
+
+void GField::deleteUnite(Unit* unite) {
+ int x = unite->x;
+ int y = unite->y;
+ delete map1[unite->x][unite->y];
+ map1[x][y] = new Land();
+ this->numberUnit--;
+ }
+
+void GField::printField() {
+ for (int i = 0; i < this->length; i++) {
+ for (int j = 0; j < this->width; j++){
+ if (map1[i][j]->type != "landscape" && map1[i][j]->type !="neutral") {
+ cout << map1[i][j]->name << " ";
+ }
+ else {
+ cout << "X ";
+ }
+ }
+ cout << endl;
+ }
+}
+
+void GField::addLabdscape(){
+ for (int i = 0; i < this->length; i++)
+ for (int j = 0; j < this->length; j++){
+ land = new Land;
+ addUnit(land, i,j);
+ }
+ for(int i = 0; i < this->length / 2; i++){
+ srand(time(NULL));
+ int randomLandscape_x = rand()% 10;
+ srand(time(NULL));
+ int randomLandscape_y = rand()% 10;
+ map1[randomLandscape_x][randomLandscape_y] = new Swamp;
+ }
+ for(int i = 0; i < this->length / 3; i++){
+ srand(time(NULL));
+ int randomLandscape_x = rand()% this->length;
+ srand(time(NULL));
+ int randomLandscape_y = rand()% this->length;
+ map1[randomLandscape_x][randomLandscape_y] = new Forest;
+ }
+}
+
+void GField::addNeutralObject(std::string name_object){
+ int k = 0;
+ while(k<1){
+ srand(time(NULL));
+ int randomLandscape_x = rand()% this->length;
+ srand(time(NULL));
+ int randomLandscape_y = rand()% this->length;
+ if(map1[randomLandscape_x][randomLandscape_y]->type == "landscape"){
+ if(name_object == "positive card")
+ map1[randomLandscape_x][randomLandscape_y] = new PositiveCard;
+ if(name_object == "negative card")
+ map1[randomLandscape_x][randomLandscape_y] = new NegativeCard;
+ if(name_object == "c card")
+ map1[randomLandscape_x][randomLandscape_y] = new TransformationCard;
+ k++;
+ }
+ }
+}
+
+std::vector> GField::getMap(){
+ return map1;
+}
+void GField::setMap(std::vector> map){
+ map1 = map;
+}
+int GField::getMaxUnit(){
+ return maxnumberUnit;
+}
+int GField::getNumUnit(){
+ return numberUnit;
+}
+int GField::getLength(){
+ return length;
+}
+void GField::setNumUnit(int num){
+ numberUnit = num;
+}
+Land* GField::getLand(){
+ return land;
+}
+
diff --git a/8303/Rudko/gfield.h b/8303/Rudko/gfield.h
new file mode 100644
index 000000000..a5c2d20d1
--- /dev/null
+++ b/8303/Rudko/gfield.h
@@ -0,0 +1,51 @@
+#ifndef GFIELD_H
+#define GFIELD_H
+
+#include "unit.h"
+#include "landscape.h"
+#include "land.h"
+#include "swamp.h"
+#include "forest.h"
+#include "positivecard.h"
+#include "negativecard.h"
+//#include "deathcard.h"
+#include "transformationcard.h"
+#include
+
+class GField{
+private:
+ int length, width;
+ int numberUnit;
+ Landscape* landscape;
+ Land* land;
+ Swamp* swamp;
+ PositiveCard* positivcard;
+ NegativeCard* negativcard;
+ TransformationCard* transformationcard;
+ //DeathCard* deathcard;
+ Forest* forest;
+ const int maxnumberUnit = 7;
+ //Unit*** map;
+
+
+public:
+ std::vector> map1;
+ GField(const GField &gfield);
+ GField(int , int );
+ void addUnit(Unit*, int, int);
+ void moveUnite(Unit* , int , int);
+ void deleteUnite(Unit*);
+ void printField();
+ int getMaxUnit();
+ int getNumUnit();
+ void setNumUnit(int);
+ std::vector> getMap();
+ void setMap(std::vector>);
+ void addLabdscape();
+ void addNeutralObject(std::string);
+ int getLength();
+ Land* getLand();
+ Landscape* getLandscape();
+};
+
+#endif // GFIELD_H
diff --git a/8303/Rudko/land.h b/8303/Rudko/land.h
new file mode 100644
index 000000000..3e0b0dce2
--- /dev/null
+++ b/8303/Rudko/land.h
@@ -0,0 +1,33 @@
+#ifndef LAND_H
+#define LAND_H
+
+#include "landscape.h"
+
+class Land: public Landscape, public Unit
+{
+public:
+ Land(){
+ this->type = "landscape";
+ this->name = "land";
+ };
+
+ bool isMoved(Unit* unit) override{
+ if(unit->type == "MeleeWarrior")
+ return true;
+ if(unit->type == "MediumWarrior")
+ return true;
+ if(unit->type == "DistanceWarrior")
+ return true;
+ }
+
+ bool isDamage(Unit* unit) override{
+ if(unit->type == "MeleeWarrior")
+ return false;
+ if(unit->type == "MediumWarrior")
+ return false;
+ if(unit->type == "DistanceWarrior")
+ return false;
+ }
+};
+
+#endif // LAND_H
diff --git a/8303/Rudko/landscape.cpp b/8303/Rudko/landscape.cpp
new file mode 100644
index 000000000..62b18b3d9
--- /dev/null
+++ b/8303/Rudko/landscape.cpp
@@ -0,0 +1,6 @@
+#include "landscape.h"
+
+Landscape::Landscape()
+{
+
+}
diff --git a/8303/Rudko/landscape.h b/8303/Rudko/landscape.h
new file mode 100644
index 000000000..513583bef
--- /dev/null
+++ b/8303/Rudko/landscape.h
@@ -0,0 +1,13 @@
+#ifndef LANDSCAPE_H
+#define LANDSCAPE_H
+
+#include "unit.h"
+
+class Landscape
+{
+public:
+ virtual bool isMoved(Unit* ) = 0;
+ virtual bool isDamage(Unit* ) = 0;
+};
+
+#endif // LANDSCAPE_H
diff --git a/8303/Rudko/log.cpp b/8303/Rudko/log.cpp
new file mode 100644
index 000000000..53f1a7c79
--- /dev/null
+++ b/8303/Rudko/log.cpp
@@ -0,0 +1,85 @@
+#include "log.h"
+
+
+log::log(){
+ file.open("logs.txt", std::ios::app);
+}
+
+log::log(int flag){
+
+}
+
+log::~log(){
+ if(this->file.is_open()){
+ this->file.close();
+ }
+}
+
+void log::logf(std::string str, int flag, int x, int y, std::string name){
+ if(this->file.is_open()){
+ std::string cur;
+ time_t now = time(0);
+ std::string d = ctime(&now);
+ if(flag == 1){
+ cur = "log ";
+ cur += d;
+ cur += "\tПользователь ввел команду ";
+ cur += str;
+ this->file << cur << '\n';
+ }
+ if(flag == 2){
+ if(str == "add"){
+ cur = "log "; cur += d;
+ cur += "\tДобавлен воин ";
+ cur += name;
+ cur += " на ";
+ this->file << cur << x << ' ' << y << '\n';
+ }
+ else {
+ cur = "log "; cur += d; cur += "\tДвижение воина ";
+ cur += name;
+ cur += " (коорд. ";
+ this->file << cur << x << ", " << y << ")\n";
+
+ }
+ }
+ if(flag == 3){
+ if(str == "base"){
+ cur = "log "; cur += d;
+ cur += "\tВыведено состояние базы\n";
+ this->file << cur;
+ }
+ else {
+ if(str == "Destroy"){
+ cur = "log "; cur += d;
+ cur += "\tБаза уничтожена!\n";
+ this->file << cur;
+ }
+ else {
+ if(str == "win"){
+ cur = "log "; cur += d;
+ cur += "\tИгрок победил\n";
+ this->file << cur;
+ }
+ else {
+ cur = "log "; cur += d;
+ cur += "Создание воина " + name + " на базе\n";
+ this->file << cur;
+ }
+ }
+ }
+ }
+ }
+ else {
+ std::cout << "Ошибка открытия файла." << std::endl;
+ }
+}
+
+void log::logt(std::string str, int flag, int x, int y, std::string name){
+ time_t now = time(0);
+ std::string d = ctime(&now);
+ if(flag == 3){
+ std::cout << "log NEW" << d;
+ std::cout << "Создание воина " << name << " (коорд. " << x << ", " << y << ')' << std::endl;
+ }
+}
diff --git a/8303/Rudko/log.h b/8303/Rudko/log.h
new file mode 100644
index 000000000..5d01804e9
--- /dev/null
+++ b/8303/Rudko/log.h
@@ -0,0 +1,23 @@
+#ifndef LOG_H
+#define LOG_H
+
+#include "gfield.h"
+#include
+#include
+#include
+#include
+
+class log
+{
+private:
+ std::ofstream file;
+ GField* field;
+public:
+ log();
+ log(int);
+ ~log();
+ void logf(std::string, int, int, int , std::string);
+ void logt(std::string, int, int, int , std::string);
+};
+
+#endif // LOG_H
diff --git a/8303/Rudko/main.cpp b/8303/Rudko/main.cpp
new file mode 100644
index 000000000..8c24e68e9
--- /dev/null
+++ b/8303/Rudko/main.cpp
@@ -0,0 +1,66 @@
+#include
+#include "unit.h"
+#include "gfield.h"
+#include "base.h"
+#include "ruls.h"
+#include "facade.h"
+
+using namespace std;
+
+int main(){
+ Facade* facade = new Facade;
+ Ruls* ruls = new Ruls;
+ string answer;
+ cout << "\t\tСправка\n"
+ ">>>Управление игроками\n"
+ " Для управления введите координаты игрока и наравление движения.\n"
+ "\tL - шаг влево\n"
+ "\tR - шаг вправо\n"
+ "\tU - шаг вперед\n"
+ "\tD - шаг назад\n"
+ "\t|-------|\n"
+ "\t|-- U --|\n"
+ "\t|-L @ R-|\n"
+ "\t|-- D --|\n"
+ "\t|-------|\n"
+ " Для просмотра состоянийя базы введите base.\n"
+ " Для добавления война на поле введите add координты и имя война.\n"
+ " Для сохранения состояния программы в файл введиде save.\n"
+ " Для считывания инфармации из файла введите display.\n"<< endl;
+ cout << "Желаете начать игру?" << endl;
+ cin >> answer;
+ if(answer == "Да" || answer == "да" || answer == "la"){
+ int number;
+ cout << "Выберите вариант игры, 1 или 2" << endl;
+ cin >> number;
+ while(1){
+ if(number != 1 && number != 2){
+ cout << "Выберите 1 или 2" << endl;
+ cin >> number;
+ }
+ else {
+ break;
+ }
+ }
+ //facade->NewGame();
+ cout << "Чтобы начать введите play" << endl;
+ cout << "Для выхода введите exit" << endl;
+ cin >> answer;
+ if(answer == "play"){
+ if(number == 1)
+ ruls->Ruls1();
+ if(number == 2){
+ ruls->Ruls2();
+ }
+ //facade->Play();
+ }
+ else {
+ cout << "Всего хорошего!" << endl;
+ }
+ }
+ else {
+ cout << "Всего хорошего!" << endl;
+ }
+ return 0;
+}
+
diff --git a/8303/Rudko/memento.cpp b/8303/Rudko/memento.cpp
new file mode 100644
index 000000000..95c086fd6
--- /dev/null
+++ b/8303/Rudko/memento.cpp
@@ -0,0 +1,67 @@
+#include "memento.h"
+
+using namespace std;
+
+Memento::Memento(string s){
+ this->file.open("Save.txt");
+}
+
+Memento::Memento(){
+ this->file_in.open("Save.txt");
+}
+
+Memento::~Memento(){
+ if(this->file.is_open()){
+ this->file.close();
+ }
+ if(this->file_in.is_open()){
+ this->file_in.close();
+ }
+}
+
+void Memento::record(GField* field){
+ if(this->file.is_open())
+ {
+ int n = field->getLength();
+ for(int i = 0; i < n; i++)
+ for(int j = 0; j < n; j++){
+ if(field->map1[i][j]->type == "base"){
+ this->file << "> Base\n" ;//<< std::endl;
+ this->file << " Координаты:\n " << field->map1[i][j]->x << ' ' << field->map1[i][j]->y << '\n';//<< std::endl;
+ this->file << " HP:\n " << field->map1[i][j]->health << '\n';//<< std::endl;
+ this->file << "-------------------------------------------\n" ;//<< std::endl;
+ } else
+ if(field->map1[i][j]->type == "landscape" || field->map1[i][j]->type == "neutral"){
+ continue;
+ } else{
+ this->file << ">>>>>>>>>>>> " << field->map1[i][j]->type << '\n';//<< std::endl;
+ this->file << " Координаты:" << field->map1[i][j]->x << ' ' << field->map1[i][j]->y << '\n';//<< std::endl;
+ this->file << " Имя: " << field->map1[i][j]->name << '\n';//<< std::endl;
+ this->file << " Здоровие: " << field->map1[i][j]->health << '\n';//<< std::endl;
+ this->file << " Атака: " << field->map1[i][j]->attack << '\n';//<< std::endl;
+ this->file << " Защита: " << field->map1[i][j]->armor << '\n';//<< std::endl;
+ this->file << "-------------------------------------------\n";//<< std::endl;
+ }
+
+ }
+ //this->file << '!';
+ //cout << this->file.tellp()<< endl;
+ }
+ else {
+ cout << "Ошибка при открытие файла. " << endl;
+ }
+}
+
+void Memento::display(){
+ if(this->file_in.is_open()){
+ while(!this->file_in.eof()) {
+ char c;
+ this->file_in.get(c);
+ cout << c;
+ }
+ cout << endl;
+ }
+ else {
+ cout << "Ошибка при открытие файла." << endl;
+ }
+}
diff --git a/8303/Rudko/memento.h b/8303/Rudko/memento.h
new file mode 100644
index 000000000..8a8273372
--- /dev/null
+++ b/8303/Rudko/memento.h
@@ -0,0 +1,18 @@
+#ifndef MEMENTO_H
+#define MEMENTO_H
+
+#include "gfield.h"
+#include
+
+class Memento{
+private:
+ std::ofstream file;
+ std::ifstream file_in;
+public:
+ Memento(std::string);
+ Memento();
+ ~Memento();
+ void record(GField* );
+ void display();
+};
+#endif // MEMENTO_H
diff --git a/8303/Rudko/negativecard.h b/8303/Rudko/negativecard.h
new file mode 100644
index 000000000..14be25fdc
--- /dev/null
+++ b/8303/Rudko/negativecard.h
@@ -0,0 +1,26 @@
+#ifndef NEGATIVECARD_H
+#define NEGATIVECARD_H
+
+#include "neutralobkect.h"
+
+class NegativeCard : public Neutral, public Unit
+{
+private:
+ std::string name_minus;
+public:
+ NegativeCard(){
+ this->type = "neutral";
+ }
+ std::string name() override{
+ name_minus = "negative_card";
+
+ }
+ void operator -(Unit* unit){
+ unit->health -= 10;
+ unit->armor -= 10;
+ unit->attack -=10;
+ }
+
+};
+
+#endif // NEGATIVECARD_H
diff --git a/8303/Rudko/neutralobkect.h b/8303/Rudko/neutralobkect.h
new file mode 100644
index 000000000..6e5e147b1
--- /dev/null
+++ b/8303/Rudko/neutralobkect.h
@@ -0,0 +1,11 @@
+#ifndef NEUTRALOBKECT_H
+#define NEUTRALOBKECT_H
+
+#include "unit.h"
+
+class Neutral{
+public:
+ virtual std::string name() = 0;
+};
+
+#endif // NEUTRALOBKECT_H
diff --git a/8303/Rudko/positivecard.h b/8303/Rudko/positivecard.h
new file mode 100644
index 000000000..1d8a2869d
--- /dev/null
+++ b/8303/Rudko/positivecard.h
@@ -0,0 +1,26 @@
+#ifndef HELTHCARD_H
+#define HELTHCARD_H
+
+#include "neutralobkect.h"
+
+class PositiveCard : public Neutral, public Unit
+{
+private:
+ std::string name_plus;
+public:
+ PositiveCard(){
+ this->type = "neutral";
+ }
+ std::string name() override{
+ name_plus = "positive_card";
+
+ }
+ void operator +(Unit* unit){
+ unit->health += 10;
+ unit->armor += 10;
+ unit->attack +=10;
+ }
+
+};
+
+#endif // HELTHCARD_H
diff --git a/8303/Rudko/ruls.cpp b/8303/Rudko/ruls.cpp
new file mode 100644
index 000000000..bbb45f6eb
--- /dev/null
+++ b/8303/Rudko/ruls.cpp
@@ -0,0 +1,11 @@
+#include "ruls.h"
+
+void Ruls::Ruls1(){
+ facade = new Facade;
+ facade->NewGame(10, 6);
+}
+
+void Ruls::Ruls2(){
+ facade = new Facade;
+ facade->NewGame(7, 3);
+}
diff --git a/8303/Rudko/ruls.h b/8303/Rudko/ruls.h
new file mode 100644
index 000000000..f953bb08b
--- /dev/null
+++ b/8303/Rudko/ruls.h
@@ -0,0 +1,15 @@
+#ifndef RULS_H
+#define RULS_H
+
+#include "facade.h"
+
+class Ruls
+{
+private:
+ Facade* facade;
+public:
+ void Ruls1();
+ void Ruls2();
+};
+
+#endif // RULS_H
diff --git a/8303/Rudko/swamp.h b/8303/Rudko/swamp.h
new file mode 100644
index 000000000..676746117
--- /dev/null
+++ b/8303/Rudko/swamp.h
@@ -0,0 +1,33 @@
+#ifndef SWAMP_H
+#define SWAMP_H
+
+#include "landscape.h"
+
+class Swamp: public Landscape, public Unit
+{
+public:
+ Swamp(){
+ this->type = "landscape";
+ this->name = "swamp";
+ }
+
+ bool isMoved(Unit* unit) override{
+ if(unit->type == "MeleeWarrior")
+ return false;
+ if(unit->type == "MediumWarrior")
+ return false;
+ if(unit->type == "DistanceWarrior")
+ return true;
+ }
+
+ bool isDamage(Unit* unit) override{
+ if(unit->type == "MeleeWarrior")
+ return true;
+ if(unit->type == "MediumWarrior")
+ return true;
+ if(unit->type == "DistanceWarrior")
+ return false;
+ }
+};
+
+#endif // SWAMP_H
diff --git a/8303/Rudko/transformationcard.h b/8303/Rudko/transformationcard.h
new file mode 100644
index 000000000..f8d7e2d05
--- /dev/null
+++ b/8303/Rudko/transformationcard.h
@@ -0,0 +1,26 @@
+#ifndef TRANSFORMATIONCARD_H
+#define TRANSFORMATIONCARD_H
+
+#include "neutralobkect.h"
+
+class TransformationCard : public Neutral, public Unit
+{
+private:
+ std::string name_transform;
+public:
+ TransformationCard(){
+ this->type = "neutral";
+ }
+ std::string name() override{
+ name_transform = "transformation_card";
+
+ }
+
+ void operator*(Unit* unit){
+ unit->attack += 20;
+ unit->armor -= 10;
+ }
+
+};
+
+#endif // TRANSFORMATIONCARD_H
diff --git a/8303/Rudko/unit.cpp b/8303/Rudko/unit.cpp
new file mode 100644
index 000000000..139322b97
--- /dev/null
+++ b/8303/Rudko/unit.cpp
@@ -0,0 +1,54 @@
+#include "unit.h"
+
+void Unit::move(int x, int y) {
+ this->x = x;// - 1;
+ this->y = y;// - 1;
+}
+
+Scorpio::Scorpio() {
+ this->type = "MeleeWarrior";
+ this->name = "scorpio";
+ this->health = 1001;
+ this->armor = 50;
+ this->attack = 30;
+}
+
+Mammoth::Mammoth() {
+ this->type = "MeleeWarrior";
+ this->name = "mammoth";
+ this->health = 200;
+ this->armor = 70;
+ this->attack = 50;
+}
+
+Frog::Frog() {
+ this->type = "MediumWarrior";
+ this->name = "frog";
+ this->health = 100;
+ this->armor = 50;
+ this->attack = 10;
+}
+
+Kangaroo::Kangaroo() {
+ this->type = "MediumWarrior";
+ this->name = "kangaroo";
+ this->health = 100;
+ this->armor = 5;
+ this->attack = 67;
+}
+
+Swallow::Swallow() {
+ this->type = "DistanceWarrior";
+ this->name = "swallow";
+ this->health = 100;
+ this->armor = 50;
+ this->attack = 30;
+}
+
+Hawk::Hawk() {
+ this->type = "DistanceWarrior";
+ this->name = "hawk";
+ this->health = 100;
+ this->armor = 50;
+ this->attack = 30;
+}
diff --git a/8303/Rudko/unit.h b/8303/Rudko/unit.h
new file mode 100644
index 000000000..0b17a5359
--- /dev/null
+++ b/8303/Rudko/unit.h
@@ -0,0 +1,73 @@
+#ifndef UNIT_H
+#define UNIT_H
+
+#include
+#include
+
+class Unit {
+public:
+ int x, y;
+ int health;
+ int armor;
+ int attack;
+ std::string type = "";
+ std::string name;
+ void move(int, int);
+};
+
+class MeleeWarrior
+ :public Unit {
+protected:
+ int melee_r;
+};
+
+class MediumWarrior
+ :public Unit {
+protected:
+ int medium_r;
+};
+
+class DistanceWarrior
+ :public Unit {
+protected:
+ int distance_r;
+};
+
+class Scorpio
+ :public MeleeWarrior { //класс воинов "скорпион", ближний бой
+public:
+ Scorpio();
+};
+
+class Mammoth
+ :public MeleeWarrior { //класс воинов "мамонт", ближний бой
+public:
+ Mammoth();
+};
+
+class Frog
+ :public MediumWarrior { //класс воинов "лягушка", бой на средней дистанции
+public:
+ Frog();
+};
+
+class Kangaroo
+ :public MediumWarrior { //класс воинов "кенгуру", бой на средней дистанции
+public:
+ Kangaroo();
+};
+
+class Swallow
+ :public DistanceWarrior { //класс воинов "ласточка", дальний бой
+public:
+ Swallow();
+};
+
+class Hawk
+ :public DistanceWarrior { //класс воинов "ястреб", дальний бой
+public:
+ Hawk();
+};
+
+
+#endif // UNIT_H
diff --git "a/8303/Rudko/\320\236\320\277\320\270\321\201\320\260\320\275\320\270\320\265" "b/8303/Rudko/\320\236\320\277\320\270\321\201\320\260\320\275\320\270\320\265"
new file mode 100644
index 000000000..9160df844
--- /dev/null
+++ "b/8303/Rudko/\320\236\320\277\320\270\321\201\320\260\320\275\320\270\320\265"
@@ -0,0 +1,9 @@
+-----------
+Добавлен класс ruls отвечающий за правила игры
+Если пользователь выбрал 1 тип игры, то нужно уничтожить базу менее чем за 13 ходов.
+Если пользователь выбрал 2 тип игры, то нужно уничтожить базу менее чем за 13 ходов при условии, что направление движения воина выбирается случайным образом.
+-----------
+Изменены методы класса Facade
+-----------
+Изменен метод Control у класса Base
+