cleanup & architectural changes

This commit is contained in:
2026-05-26 16:26:14 +03:00
parent 680ef59e67
commit d596438a94
6 changed files with 43 additions and 43 deletions
+21 -20
View File
@@ -1,21 +1,5 @@
#include "field.h"
/*
Fields:
std::vector<std::vector<int>> field;
Private methods:
std::vector<Tile> processLine(const std::vector<Tile> &sourceLine);
std::vector<Tile> getRow(size_t idx);
std::vector<Tile> getColumn(size_t idx);
void setRow(size_t idx);
void setColumn(size_t idx);
Public methods:
bool move(Direction direction);
*/
// PRIVATE
Line Field::getRow(size_t rowIndex) const {
return this->field[rowIndex];
@@ -53,11 +37,27 @@ Field::Field(size_t fieldSize) : mt(std::random_device{}()), FieldSize(fieldSize
this->reset();
}
void printVector(const Line &arr) {
for (size_t i = 0; i < arr.size(); ++i) {
printf("%llu ", arr[i]);
void Field::updateScore() {
for (size_t i = 0; i < this->FieldSize; ++i) {
this->score += this->field[i].score;
}
}
Score Field::getScore() {
return this->score;
}
bool Field::canMove() const {
if (!this->getEmptyTiles().empty()) {
return true;
}
for (int x = 0; x < this->field.size(); ++x) {
for (int y = 0; y < this->field.size(); ++y) {
// TODO: implement
// if (x + 1 < )
}
}
printf("\n");
}
bool Field::move(Direction direction) {
@@ -136,4 +136,5 @@ void Field::debug() const {
}
printf("\n");
}
printf("Current score: %llu", this->score);
}
-6
View File
@@ -1,11 +1,5 @@
#include "line.h"
/*
Fields:
std::vector<Tile> line;
Score score;
*/
Line::Line() {
this->line.clear();
this->line.resize(0);