diff --git a/source/Trek-12/Models/Game/Cell.cs b/source/Trek-12/Models/Game/Cell.cs
index 49fe4bb..2548cfe 100644
--- a/source/Trek-12/Models/Game/Cell.cs
+++ b/source/Trek-12/Models/Game/Cell.cs
@@ -26,6 +26,9 @@
///
private bool IsDangerous { get; set; }
+ public bool Valid { get; set; }
+
+
///
/// Atribute to know if the cell is a penalty cell.
///
@@ -41,6 +44,7 @@
{
IsDangerous = isDangerous;
Penalty = false;
+ Valid = false;
}
///
diff --git a/source/Trek-12/Models/Game/Game.cs b/source/Trek-12/Models/Game/Game.cs
index bb07919..23a20a2 100644
--- a/source/Trek-12/Models/Game/Game.cs
+++ b/source/Trek-12/Models/Game/Game.cs
@@ -119,7 +119,7 @@ namespace Models.Game
/// The result of the dice operation to be placed in the cell.
private void PlaceResult(Cell playerChoice, int result)
{
- if (Turn == 1 || GameRules.NearCellIsValid(playerChoice, UsedMap.Boards))
+ if (Turn == 1 || GameRules.NearCellIsValid(playerChoice, UsedMap.Boards.ToList()))
{
playerChoice.Value = result;
BoardUpdated?.Invoke(this, EventArgs.Empty);
@@ -226,14 +226,14 @@ namespace Models.Game
throw new InvalidCellCoordinatesException("Invalid cell coordinates. Please choose again.");
}
- if (!GameRules.IsCellValid(cell, UsedMap.Boards))
+ if (!GameRules.IsCellValid(cell, UsedMap.Boards.ToList()))
{
throw new InvalidCellException("Cell is not valid. Please choose again.");
}
PlaceResult(cell, result);
GameRules.IsZoneValidAndAddToZones(cell, UsedMap);
- AddToRopePath(cell, GameRules.EveryAdjacentCells(cell, UsedMap.Boards));
+ AddToRopePath(cell, GameRules.EveryAdjacentCells(cell, UsedMap.Boards.ToList()));
CellChosen?.Invoke(this, new CellChosenEventArgs(cell, result));
BoardUpdated?.Invoke(this, EventArgs.Empty);
}
diff --git a/source/Trek-12/Models/Game/Map.cs b/source/Trek-12/Models/Game/Map.cs
index e1399bb..ff2f935 100644
--- a/source/Trek-12/Models/Game/Map.cs
+++ b/source/Trek-12/Models/Game/Map.cs
@@ -11,7 +11,8 @@ namespace Models.Game
///
/// It is the list of cells on the map.
///
- public List Boards { get; private set; }
+ public ReadOnlyObservableCollection Boards { get; private set; }
+ ObservableCollection board = new ObservableCollection();
///
/// It is the backgrond image of the map
@@ -40,7 +41,8 @@ namespace Models.Game
/// The background of the map.
public Map(string background)
{
- Boards = InitializeBoards();
+ Boards = new ReadOnlyObservableCollection(board);
+ InitializeBoards(board);
Background = background;
OperationGrid = new ReadOnlyObservableCollection(operationGrid);
InitializeOperationGrid(operationGrid);
@@ -52,14 +54,31 @@ namespace Models.Game
/// Initializes the boards of the map.
/// |
/// Return the boards
- private List InitializeBoards()
+ private void InitializeBoards(ObservableCollection board)
{
- var boards = new List();
- for (int i = 0; i < 36; i++) // 6x6 board
+ for (int i = 0; i < 49; i++) // 6x6 board
{
- boards.Add(new Cell(i / 6, i % 6));
+ board.Add(new Cell(i / 7, i % 7));
}
- return boards;
+ board[1].Valid = true;
+ board[3].Valid = true;
+ board[4].Valid = true;
+ board[5].Valid = true;
+ board[9].Valid = true;
+ board[12].Valid = true;
+ board[15].Valid = true;
+ board[16].Valid = true;
+ board[17].Valid = true;
+ board[21].Valid = true;
+ board[24].Valid = true;
+ board[25].Valid = true;
+ board[28].Valid = true;
+ board[30].Valid = true;
+ board[31].Valid = true;
+ board[32].Valid = true;
+ board[40].Valid = true;
+ board[41].Valid = true;
+ board[48].Valid = true;
}
///
diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs
index 8a7dc43..8482653 100644
--- a/source/Trek-12/Models/Rules/Rules.cs
+++ b/source/Trek-12/Models/Rules/Rules.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -95,7 +96,7 @@ namespace Models.Rules
List adjacentCells = new List();
- adjacentCells = EveryAdjacentCells(chosenCell, map.Boards);
+ adjacentCells = EveryAdjacentCells(chosenCell, map.Boards.ToList());
foreach(var cells in adjacentCells)
{
diff --git a/source/Trek-12/Trek-12/Views/PageBoard.xaml b/source/Trek-12/Trek-12/Views/PageBoard.xaml
index a571d0f..6527854 100644
--- a/source/Trek-12/Trek-12/Views/PageBoard.xaml
+++ b/source/Trek-12/Trek-12/Views/PageBoard.xaml
@@ -5,10 +5,33 @@
Title="Board">
+
+
+
+
+
+
+
+
| | | | | | | | |