position: Rename _Xxx_Piece()

This commit is contained in:
Calcitem 2020-08-31 23:42:31 +08:00
parent ed5227041c
commit 04ef3850d4
3 changed files with 13 additions and 13 deletions

View File

@ -660,14 +660,14 @@ out:
return true;
}
bool Position::_placePiece(File file, Rank rank)
bool Position::place_piece(File file, Rank rank)
{
Square s = Position::polar_to_square(file, rank);
return place_piece(s, true);
}
bool Position::_removePiece(File file, Rank rank)
bool Position::remove_piece(File file, Rank rank)
{
Square s = Position::polar_to_square(file, rank);
@ -802,7 +802,7 @@ bool Position::select_piece(Square s)
return false;
}
bool Position::_selectPiece(File file, Rank rank)
bool Position::select_piece(File file, Rank rank)
{
return select_piece(Position::polar_to_square(file, rank));
}
@ -865,8 +865,8 @@ bool Position::command(const char *cmd)
tm = mm * 60 + ss;
}
if (_selectPiece(file1, rank1)) {
return _placePiece(file2, rank2);
if (select_piece(file1, rank1)) {
return place_piece(file2, rank2);
}
return false;
@ -878,7 +878,7 @@ bool Position::command(const char *cmd)
if (mm >= 0 && ss >= 0)
tm = mm * 60 + ss;
}
return _removePiece(file1, rank1);
return remove_piece(file1, rank1);
}
args = sscanf(cmd, "(%1u,%1u) %2u:%2u", &file1, &rank1, &mm, &ss);
@ -887,7 +887,7 @@ bool Position::command(const char *cmd)
if (mm >= 0 && ss >= 0)
tm = mm * 60 + ss;
}
return _placePiece(file1, rank1);
return place_piece(file1, rank1);
}
args = sscanf(cmd, "Player%1u give up!", &t);

View File

@ -83,12 +83,12 @@ public:
// Properties of moves
bool select_piece(Square s);
bool select_piece(File file, Rank rank);
bool place_piece(Square s, bool updateCmdlist = false);
bool place_piece(File file, Rank rank);
bool remove_piece(Square s, bool updateCmdlist = false);
bool remove_piece(File file, Rank rank);
bool move_piece(Square from, Square to);
bool _selectPiece(File file, Rank rank);
bool _placePiece(File file, Rank rank);
bool _removePiece(File file, Rank rank);
// Doing and undoing moves
bool do_move(Move m);

View File

@ -783,7 +783,7 @@ bool GameController::actionPiece(QPointF pos)
switch (position.get_action()) {
case ACTION_PLACE:
if (position._placePiece(file, rank)) {
if (position.place_piece(file, rank)) {
if (position.get_action() == ACTION_REMOVE) {
// 播放成三音效
playSound(GAME_SOUND_MILL, position.side_to_move());
@ -802,7 +802,7 @@ bool GameController::actionPiece(QPointF pos)
piece = qgraphicsitem_cast<PieceItem *>(item);
if (!piece)
break;
if (position._selectPiece(file, rank)) {
if (position.select_piece(file, rank)) {
// 播放选子音效
playSound(GAME_SOUND_SELECT, position.side_to_move());
result = true;
@ -813,7 +813,7 @@ bool GameController::actionPiece(QPointF pos)
break;
case ACTION_REMOVE:
if (position._removePiece(file, rank)) {
if (position.remove_piece(file, rank)) {
// 播放音效
playSound(GAME_SOUND_REMOVE, position.side_to_move());
result = true;