Commit 238cacdd authored by Emil's avatar Emil

Fixes to next_pos function

parent e4368db6
......@@ -4,6 +4,7 @@
// engine interface
#include "basic_types.h"
namespace gameengine::utility
{
......
......@@ -28,22 +28,63 @@ namespace gameengine::utility
BitPos nextPosition(const BitPos& board_pos, const MoveDirection& dir)
{
switch (dir) {
case MoveDirection::N:
return gameengine::BitPos(board_pos.value()+8);
case MoveDirection::S:
return gameengine::BitPos(board_pos.value()-8);
case MoveDirection::E:
return gameengine::BitPos(board_pos.value()+1);
case MoveDirection::W:
return gameengine::BitPos(board_pos.value()-1);
case MoveDirection::SE:
return gameengine::BitPos(board_pos.value()-7);
case MoveDirection::SW:
return gameengine::BitPos(board_pos.value()-9);
case MoveDirection::NE:
return gameengine::BitPos(board_pos.value()+9);
case MoveDirection::NW:
return gameengine::BitPos(board_pos.value()+7);
case MoveDirection::N: //new position when moving North
if (board_pos.value()>55) {
}
else {
return gameengine::BitPos(board_pos.value()+8);
}
case MoveDirection::S: //new position when moving South
if (board_pos.value()>55) {
}
else {
return gameengine::BitPos(board_pos.value()-8);
}
case MoveDirection::E: //new position when moving East
if (board_pos.value()>55) {
}
else {
return gameengine::BitPos(board_pos.value()+1);
}
case MoveDirection::W: //new position when moving West
if (board_pos.value()>55) {
}
else {
return gameengine::BitPos(board_pos.value()-1);
}
case MoveDirection::SE: //new position when moving South_East
if (board_pos.value()>55) {
}
else {
return gameengine::BitPos(board_pos.value()-7);
}
case MoveDirection::SW: //new position when moving South-West
if (board_pos.value()>55) {
}
else {
return gameengine::BitPos(board_pos.value()-9);
}
case MoveDirection::NE: //new position when moving North-East
if (board_pos.value()>55) {
}
else {
return gameengine::BitPos(board_pos.value()+9);
}
case MoveDirection::NW: //new position when moving North-West
if (board_pos.value()>55) {
}
else {
return gameengine::BitPos(board_pos.value()+7);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment