@@ -163,7 +163,7 @@ void GameManager::handleCapturePiece(const chk::PlayerPtr &hunter, const chk::Pl
163163 this ->forcedMoves .clear ();
164164 if (isKingBefore == isKingNow)
165165 {
166- GameManager:: identifyTargets (hunter, targetCell);
166+ this -> identifyTargets (hunter, targetCell);
167167 }
168168
169169 if (this ->forcedMoves .empty ())
@@ -226,7 +226,7 @@ bool GameManager::isHunterActive() const
226226}
227227
228228/* *
229- * Using cached gameMap, get the PieceId found at this cell_index
229+ * Using cached gameMap, get the piece_id found at this cell
230230 *
231231 * @param cell_idx the clicked cell
232232 * @return positive number or -1 if not found
@@ -242,7 +242,8 @@ short GameManager::getPieceFromCell(const int cell_idx) const
242242
243243/* *
244244 * Match cells to pieces at game launch, using position, and cache it to Hashmap
245- * @param pieceList vector of all pieces
245+ *
246+ * @param pieceList vector containing all pieces
246247 */
247248void GameManager::matchCellsToPieces (const std::vector<chk::PiecePtr> &pieceList)
248249{
@@ -308,13 +309,17 @@ void chk::GameManager::handleCellTap(const chk::PlayerPtr &hunter, const chk::Pl
308309 if (pieceId != -1 )
309310 {
310311 // YES, it has one! VERIFY IF THERE IS ANY PENDING "forced captures".
311- // If yes, ensure hunter is SELECTED!
312312 if (!this ->getForcedMoves ().empty () && this ->forcedMoves .find (pieceId) == forcedMoves.end ())
313313 {
314314 this ->showForcedMoves (hunter, cell);
315315 return ;
316316 }
317- // OTHERWISE, store it in buffer (for a SIMPLE/CAPTURE move next)!
317+ // Does current player own this piece?
318+ if (!hunter->hasThisPiece (pieceId))
319+ {
320+ return ;
321+ }
322+ // Store it in buffer (for a SIMPLE/CAPTURE move next!)
318323 buffer.addItem (pieceId);
319324 this ->setSourceCell (cell->getIndex ());
320325 cell->highlightActive ();
@@ -413,7 +418,7 @@ bool GameManager::awayFromEdge(const int cell_idx) const
413418/* *
414419 * Collect all possible next "forced captures" for this hunter.
415420 * @param hunter Current player
416- * @param singleCell if not NULL, only collect around this cell. Otherwise, loop ENTIRE board
421+ * @param singleCell if NOT null, then only collect around this cell. Otherwise, loop ENTIRE board
417422 */
418423void GameManager::identifyTargets (const PlayerPtr &hunter, const chk::Block &singleCell)
419424{
@@ -424,7 +429,7 @@ void GameManager::identifyTargets(const PlayerPtr &hunter, const chk::Block &sin
424429 const short pieceId = this ->getPieceFromCell (singleCell->getIndex ());
425430 if (gameMap.find (singleCell->getIndex ()) == gameMap.end () || !hunter->hasThisPiece (pieceId))
426431 {
427- // this CELL is not usable, OR piece not OWNED by hunter
432+ // this CELL is not usable, OR piece not owned to hunter
428433 return ;
429434 }
430435 this ->collectFrontLHS (hunter, singleCell);
0 commit comments