예제 #1
0
 public static void FillSquares(AppDbContext ctx, Domain.GameBoard ogboard, GameBoard tofillboard)
 {
     for (int i = 0; i < ogboard.Board.Count; i++)//p1 board
     {
         for (int j = 0; j < ogboard.Board[i].Count; j++)
         {
             var gameBoardSquare = new GameboardSquare()
             {
                 GameBoard = tofillboard, x = i, y = j, Value = ogboard.Board[i][j].ToString()
             };
             tofillboard.Squares.Add(gameBoardSquare);
             ctx.GameboardSquares.Add(gameBoardSquare);
         }
     }
 }
예제 #2
0
        public static void FillShips(AppDbContext ctx, Domain.GameBoard ogboard, GameBoard tofillboard)
        {
            foreach (var ship in ogboard.Ships)//p1
            {
                var lastship = new Ship()
                {
                    Health = ship.Health, Length = ship.Length
                };
                //ctx.BoardShips.Add(new BoardShips(){GameBoard = tofillboard, Ship = lastship});
                foreach (var location in ship.Locations)
                {
                    var loc = new ShipsLocation()
                    {
                        y = location[0], x = location[1], Ship = lastship
                    };
                    lastship.ShipsLocations.Add(loc);
                }

                lastship.GameBoard = tofillboard;
                tofillboard.Ships.Add(lastship);
            }
        }