mis en place la PR de simon sur les couleurs

This commit is contained in:
2025-02-28 18:42:04 +01:00
parent f0f391ade6
commit 26f501f7e8
29 changed files with 713 additions and 665 deletions

View File

@@ -4,17 +4,21 @@
#include "GameParameters.h"
#include "Action.h"
#include <Vector>
#include <vector>
#include <algorithm>
static const int SUBPX_PER_ROW = 60; // the number of position the active piece can take "between" two rows
static const int SOFT_DROP_SCORE = 1; // the score gained by line soft dropped
static const int HARD_DROP_SCORE = 2; // the score gained by line hard dropped
static const int SUBPX_PER_ROW = 60; // the number of position the active piece can take "between" two rows
static const int SOFT_DROP_SCORE = 1; // the score gained by line soft dropped
static const int HARD_DROP_SCORE = 2; // the score gained by line hard dropped
static const int LINE_CLEAR_BASE_SCORE = 100; // the score value of clearing a single line
static const int B2B_SCORE_MULTIPLIER = 2; // by how much havaing B2B on multiplies the score of the line clear
static const int B2B_MIN_LINE_NUMBER = 4; // the minimum number of lines needed to be cleared at once to gain B2B (without a spin)
static const int B2B_SCORE_MULTIPLIER = 2; // by how much havaing B2B on multiplies the score of the line clear
static const int B2B_MIN_LINE_NUMBER = 4; // the minimum number of lines needed to be cleared at once to gain B2B (without a spin)
Game::Game(Gamemode gamemode, const Player& controls, int boardWidth, int boardHeight, const std::vector<Piece>& bag) : parameters(gamemode, controls), board(boardWidth, boardHeight, bag, parameters.getNextQueueLength()) {
Game::Game(Gamemode gamemode, const Player& controls, int boardWidth, int boardHeight, const std::vector<Piece>& bag) :
parameters(gamemode, controls),
board(boardWidth, boardHeight, bag, parameters.getNextQueueLength()) {
// the game has not yet started
this->started = false;
this->lost = false;
@@ -221,17 +225,17 @@ void Game::lockPiece() {
this->parameters.clearLines(clear.lines);
// update B2B and score
bool B2BConditions = ((clear.lines > B2B_MIN_LINE_NUMBER) || clear.isSpin || clear.isMiniSpin);
bool B2BConditionsAreMet = ((clear.lines > B2B_MIN_LINE_NUMBER) || clear.isSpin || clear.isMiniSpin);
if (clear.lines > 0) {
/* clearing one more line is worth 2x more
clearing with a spin is worth as much as clearing 2x more lines */
long int clearScore = LINE_CLEAR_BASE_SCORE;
clearScore = clearScore << (clear.lines << (clear.isSpin));
if (this->B2BChain && B2BConditions) clearScore *= B2B_SCORE_MULTIPLIER;
if (this->B2BChain && B2BConditionsAreMet) clearScore *= B2B_SCORE_MULTIPLIER;
this->score += clearScore;
}
this->B2BChain = B2BConditions;
this->B2BChain = B2BConditionsAreMet;
// reset active piece
this->subVerticalPosition = 0;
@@ -286,7 +290,7 @@ Piece Game::getActivePiece() {
return this->board.getActivePiece();
}
Cell Game::getActivePiecePosition() {
Position Game::getActivePiecePosition() {
return this->board.getActivePiecePosition();
}