Debug information about positions of units

Random position for flag and enemy (function Random)
This commit is contained in:
2025-07-07 17:42:31 +03:00
parent 253e1cf423
commit 7da1909c76
7 changed files with 110 additions and 52 deletions

View File

@@ -5,6 +5,7 @@
constexpr auto SIZE = 10;
constexpr auto SIZE_FOR_ARRAY = SIZE - 1;
constexpr auto ARMY = 5;
class Game {
private:
@@ -17,13 +18,16 @@ public:
field[i][j] = '*';
}
}
gamers[0].set_name('P');
gamers[1].set_name('E');
};
void info();
void init();
void play();
private:
void Random(char);
void clearScreen();
void print_field();
};

View File

@@ -1,5 +1,11 @@
#pragma once
struct Infantry {
class Infantry {
private:
int x;
int y;
public:
Infantry(int _x, int _y) : x(_x), y(_y) {};
void get_coordinates();
void attack();
};

View File

@@ -9,13 +9,17 @@ private:
std::vector<std::unique_ptr<Infantry>> army;
double score;
public:
Player() {
score = 0.;
for (auto i = 0; i < 4; ++i) {
army.push_back(std::make_unique<Infantry>());
}
}
Player() : score(0.) {};
std::vector<std::unique_ptr<Infantry>>& get_army() {
return army;
}
void set_army(int x, int y) {
army.push_back(std::make_unique<Infantry>(x, y));
}
void set_name(char _name) {
name = _name;
}
};

View File

@@ -26,5 +26,6 @@ enum CELL_CHARS {
EMPTY_CELL = '*',
CURSOR_CELL = '?',
ENEMY_CELL = 'E',
PLAYER_CELL = 'I'
PLAYER_CELL = 'I',
FLAG_CELL = 'F'
};