Ultimately, it is a design issue, both can fit well with the OOP paradigm.
I try to place methods in the class that are most intelligently understood semantically. In this case, this means Player::walkif the card does not do something to make the “players” move (that is, in the game with flippers, the game board makes the ball [aka 'player]] move), and then it can be more meaningful have this object, for example Board::movePlayer.
You must give a copy of the card to the player if you are going for design Player::walk. So you get Player::walk(Map &map /*more parameters here, maybe a direction or vector speed?*/).
Another thing is that you should try to tell more than you ask. This means that instead of:
if (map.cells[wantToWalkTo] == 0) {
map.cells[wantToWalkTo] = this.playerId;
}
You should do something like:
bool moved = map.moveTo(position, this);
source
share