balance: adjust values for GROW, MOVE, and SPORE

This commit is contained in:
2026-02-05 16:28:21 +08:00
parent b10dc25457
commit 56a900686d
6 changed files with 61 additions and 10 deletions

View File

@@ -213,4 +213,13 @@ bool Board::changeATK(int row, int col, int num) {
}
m_grid[pieceID]->changeATK(num);
return true;
}
bool Board::setPieceInfo(int row, int col, PieceInfo pieceInfo) {
int pieceID = getPieceID(row, col);
if (!m_grid[pieceID]) {
return false;
}
m_grid[pieceID]->setInfo(pieceInfo);
return true;
}

View File

@@ -57,4 +57,6 @@ public:
bool changeHP(int row, int col, int num);
bool changeATK(int row, int col, int num);
bool setPieceInfo(int row, int col, PieceInfo pieceInfo);
};

View File

@@ -61,10 +61,23 @@ bool GameSession::executeAction(int toRow, int toCol) {
auto [fromRow, fromCol] = *m_seletedPiece;
if (m_currentActionType == ActionType::GROW) {
if (Rule::canGrow(m_board.get(), fromRow, fromCol, toRow, toCol, m_currentPlayer)) {
auto fromPiece = m_board->getPieceAt(fromRow, fromCol);
auto toPiece = m_board->getPieceAt(toRow, toCol);
auto fromInfo = fromPiece->getPieceInfo();
if (fromInfo.HP / 2 == 0) {
// 因为每个玩家结束全部棋子恢复2HP所以理论来说是不可能GROW死的
m_gamePieceEventCallback(GamePieceEvent::REMOVE_PIECE, fromRow, fromCol, -1, -1);
m_board->removePieceAt(fromRow, fromCol);
markComponentAsUsed(getOldComponentID(fromRow, fromCol));
return true;
}
fromInfo.HP /= 2;
fromInfo.ATK += 2;
m_gamePieceEventCallback(GamePieceEvent::PLACE_PIECE, toRow, toCol, -1, -1);
m_gamePieceEventCallback(GamePieceEvent::GROW_PIECE, fromRow, fromCol, toRow, toCol);
m_board->placePieceAt(toRow, toCol, m_currentPlayer);
m_board->setPieceInfo(fromRow, fromCol, fromInfo);
m_board->setPieceInfo(toRow, toCol, fromInfo);
// 如果执行了操作就擦除
markComponentAsUsed(getOldComponentID(fromRow, fromCol));
@@ -86,8 +99,11 @@ bool GameSession::executeAction(int toRow, int toCol) {
if (!toPiece) {
m_gamePieceEventCallback(GamePieceEvent::MOVE_PIECE, fromRow, fromCol, toRow, toCol);
auto fromInfo = fromPiece->getPieceInfo();
m_board->removePieceAt(fromRow, fromCol);
m_board->placePieceAt(toRow, toCol, m_currentPlayer);
m_board->setPieceInfo(toRow, toCol, fromInfo);
//m_board->changeHP(toRow, toCol, -5);
markComponentAsUsed(getOldComponentID(fromRow, fromCol));
return true;
}
@@ -105,8 +121,11 @@ bool GameSession::executeAction(int toRow, int toCol) {
if (fromPiece->getHP() > 0) {
m_gamePieceEventCallback(GamePieceEvent::MOVE_PIECE, fromRow, fromCol, toRow, toCol);
auto fromInfo = fromPiece->getPieceInfo();
m_board->removePieceAt(fromRow, fromCol);
m_board->placePieceAt(toRow, toCol, m_currentPlayer);
m_board->setPieceInfo(toRow, toCol, fromInfo);
}
}
@@ -121,9 +140,14 @@ bool GameSession::executeAction(int toRow, int toCol) {
m_gamePieceEventCallback(GamePieceEvent::REMOVE_PIECE, fromRow, fromCol, -1, -1);
m_gamePieceEventCallback(GamePieceEvent::PLACE_PIECE, toRow, toCol, -1, -1);
m_gamePieceEventCallback(GamePieceEvent::MOVE_PIECE, fromRow, fromCol, toRow, toCol);
auto fromPiece = m_board->getPieceAt(fromRow, fromCol);
auto toPiece = m_board->getPieceAt(toRow, toCol);
auto fromInfo = fromPiece->getPieceInfo();
m_board->removePieceAt(fromRow, fromCol);
m_board->placePieceAt(toRow, toCol, m_currentPlayer);
m_board->setPieceInfo(toRow, toCol, fromInfo);
m_board->changeHP(toRow, toCol, -2);
markComponentAsUsed(getOldComponentID(fromRow, fromCol));
return true;
}

View File

@@ -75,5 +75,5 @@ public:
}
PieceInfo getPieceInfo(int row, int col) const;
};

View File

@@ -1,7 +1,8 @@
#include "Piece.h"
Piece::Piece(PlayerID ID) : m_owner(ID) {
m_pieceInfo.ATK = 10;
m_pieceInfo.HP = 20;
}
Piece::~Piece() {

View File

@@ -5,24 +5,39 @@
class Piece {
private:
PlayerID m_owner;
int HP = 20;
int ATK = 10;
PieceInfo m_pieceInfo;
public:
Piece(PlayerID ID);
~Piece();
PlayerID getPieceOwner() const;
void changeHP(int num) {
HP += num;
m_pieceInfo.HP += num;
}
void changeATK(int num) {
ATK += num;
m_pieceInfo.ATK += num;
}
int getHP() const {
return HP;
return m_pieceInfo.HP;
}
int getATK() const {
return ATK;
return m_pieceInfo.ATK;
}
PieceInfo getPieceInfo() const {
return m_pieceInfo;
}
void setHP(int HP) {
m_pieceInfo.HP = HP;
}
void setATK(int ATK) {
m_pieceInfo.ATK = ATK;
}
void setInfo(PieceInfo pieceInfo) {
m_pieceInfo = pieceInfo;
}
};