I get a dictionary from a bunch of game items with three properties:
Address = Location in the game section
Offset = Offset to the left of where the game is connected.
Width = width of the game fragment (one, two or three wide)
The game plan itself has 6 wide and 5 high (a total of 30 possible positions)
25 26 27 28 29 30
19 20 21 22 23 24
13 14 15 16 17 18
07 08 09 10 11 12
01 02 03 04 05 06
Each number is a corresponding address on the board.
I would like to be able to add all these parts to the collection, for example ObservableCollection<GameRow> GameRows , where
public class GameRow { public ObservableCollection<GamePiece> Row { get; set; } public GameRow(ArrayList<GamePiece> gamePieces) { Row = new ObservableCollection<GamePiece>(); foreach (GamePiece gamePiece in gamePieces) { Row.Add(gamePiece); } } }
and
public class GamePiece { public string Width { get; set; } public string Color { get; set; } public int Address {get; set} }
I also need to create a game element for any unused area on the board, which is one width and color gray (other parts of the game should be yellow).
Here's what the game pieces look like:
One wide:
X (offset = 0)
Two Wide:
0X (offset = 1)
Three wide 0X0 (offset = 1)
X = What is called the address for this part
0 = empty space that it occupies.
I am trying to come up with a way to parse this dictionary of the parts of the game that I get in GameRows.
Example:
Let's say that I get three parts. {Address = 2, Width = 1, Offset = 0}, {Address = 12, Width = 2, Offset = 1}, {Address = 23, Width = 3, Offset = 1}
I know that address 2 will be in the first row and will take position 02, and the rest of the game for this board should be empty gameplay with a width of 1. The piece that is address 12 will be in the second row and occupy positions 11 and 12. Piece, which is address 23, will be in the 4th row and will occupy positions 22, 23, 24. In the ObservableCollection GameRows there will be five GameRow objects in it. The GameRow object for line 4 will contain 4 objects in the Row collection. The first 3 being empty will be {Width = 1, Color = Gray}, and the last part will be {Width = 3, Color = Yellow}