Skip to content

Commit 0c45cce

Browse files
style: Adjust the code indentation
1 parent 5ca6bb3 commit 0c45cce

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

lib/gameboard.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ GameBoard::GameBoard(const int width, const int height, const int mineCount)
8989

9090
void GameBoard::revealCell(const int x, const int y)
9191
{
92-
if (this->board_[x][y].isRevealed())
93-
{
92+
if (this->board_[x][y].isRevealed())
93+
{
9494
return;
95-
}
96-
this->board_[x][y].reveal();
95+
}
96+
this->board_[x][y].reveal();
9797
}
9898

9999
void GameBoard::toggleFlag(const int x, const int y)
@@ -108,56 +108,56 @@ void GameBoard::toggleFlag(const int x, const int y)
108108

109109
bool GameBoard::isGameWon() const
110110
{
111-
for (const auto &row : board_)
112-
{
111+
for (const auto &row : board_)
112+
{
113113
for (const auto &cell : row)
114114
{
115115
if (!cell.hasMine() && !cell.isRevealed())
116116
{
117117
return false; // 非地雷格子没翻开,未胜利
118118
}
119119
}
120-
}
121-
return true; // 所有非雷格子都翻开了,胜利
120+
}
121+
return true; // 所有非雷格子都翻开了,胜利
122122
}
123123

124124
bool GameBoard::isGameLose() const
125125
{
126-
for (auto &row : this->board_)
127-
{
126+
for (auto &row : this->board_)
127+
{
128128
for (auto cell : row)
129129
{
130130
if (cell.isRevealed() && cell.hasMine())
131131
{
132132
return true;
133133
}
134134
}
135-
}
136-
return false;
135+
}
136+
return false;
137137
}
138138

139139
void GameBoard::display(const bool revealAll) const
140140
{
141-
const int height = this->getHeight();
142-
const int width = this->getWidth();
141+
const int height = this->getHeight();
142+
const int width = this->getWidth();
143143

144-
// 打印列号
145-
std::cout << " "; // 行号空白占位
146-
for (int col = 0; col < width; ++col)
147-
{
144+
// 打印列号
145+
std::cout << " "; // 行号空白占位
146+
for (int col = 0; col < width; ++col)
147+
{
148148
std::cout << std::setw(3) << col;
149-
}
150-
std::cout << std::endl;
149+
}
150+
std::cout << std::endl;
151151

152-
std::cout << " +";
153-
for (int col = 0; col < width; ++col)
154-
{
152+
std::cout << " +";
153+
for (int col = 0; col < width; ++col)
154+
{
155155
std::cout << "---";
156-
}
157-
std::cout << "+" << std::endl;
156+
}
157+
std::cout << "+" << std::endl;
158158

159-
for (int row = 0; row < height; ++row)
160-
{
159+
for (int row = 0; row < height; ++row)
160+
{
161161
std::cout << std::setw(3) << row << "|";
162162
for (int col = 0; col < width; ++col)
163163
{
@@ -182,50 +182,50 @@ void GameBoard::display(const bool revealAll) const
182182
}
183183
}
184184
std::cout << "|" << std::endl;
185-
}
185+
}
186186

187-
std::cout << " +";
188-
for (int col = 0; col < width; ++col)
189-
{
187+
std::cout << " +";
188+
for (int col = 0; col < width; ++col)
189+
{
190190
std::cout << "---";
191-
}
192-
std::cout << "+" << std::endl;
191+
}
192+
std::cout << "+" << std::endl;
193193
}
194194

195195
bool GameBoard::cellHasMine(const int x, const int y) const
196196
{
197-
return board_[x][y].hasMine();
197+
return board_[x][y].hasMine();
198198
}
199199

200200
bool GameBoard::cellHasAdjacentMines(const int x, const int y) const
201201
{
202-
return board_[x][y].hasAdjacentMines();
202+
return board_[x][y].hasAdjacentMines();
203203
}
204204

205205
// Check if the cell is revealed
206206
bool GameBoard::cellIsRevealed(const int x, const int y) const
207207
{
208-
return board_[x][y].isRevealed(); // Return if the cell is revealed
208+
return board_[x][y].isRevealed(); // Return if the cell is revealed
209209
}
210210

211211
bool GameBoard::cellIsFlagged(const int x, const int y) const
212212
{
213-
return board_[x][y].isFlagged();
213+
return board_[x][y].isFlagged();
214214
}
215215

216216
int GameBoard::getWidth() const
217217
{
218-
return this->width_;
218+
return this->width_;
219219
}
220220

221221
int GameBoard::getHeight() const
222222
{
223-
return this->height_;
223+
return this->height_;
224224
}
225225

226226
int GameBoard::getMineCount() const
227227
{
228-
return this->mineCount_;
228+
return this->mineCount_;
229229
}
230230

231231
int GameBoard::getMinesRemainCount() const {

0 commit comments

Comments
 (0)