public Cell GetTheNeighbouringCell(NeighbouringCell neighbouringCell) { return(neighbouringCell switch { NeighbouringCell.Right => GetTheNeighbouringCell(1, 0), NeighbouringCell.Left => GetTheNeighbouringCell(-1, 0), NeighbouringCell.Top => GetTheNeighbouringCell(0, -1), NeighbouringCell.Bottom => GetTheNeighbouringCell(0, 1), _ => throw new ArgumentOutOfRangeException(nameof(neighbouringCell), neighbouringCell, null) });
private static void MovePlayer(GameMap gameMap, MoveDirection moveDirection, NeighbouringCell neighbouringCell) { var neighbourCell = gameMap.Player.Cell.GetTheNeighbouringCell(neighbouringCell); if (neighbourCell.IsCellFree()) { gameMap.Player.MovePlayer(moveDirection); } else { var hasTheItemInCellBeenHandled = gameMap.Player.HandleWhatIsInTheCell(neighbourCell.Actor); if (hasTheItemInCellBeenHandled) { neighbourCell.ClearCell(); gameMap.Player.MovePlayer(moveDirection); } } }