// See https://aka.ms/new-console-template for more information



using Models;
using Models.Game;
using Models.Rules;


Cell pos01 = new Cell(0,0);
Cell pos02 = new Cell(1,0);
Cell pos03 = new Cell(2,0);
Cell pos04 = new Cell(3,0);
Cell pos05 = new Cell(4,0); //4

Cell pos11 = new Cell(0, 1);
Cell pos12 = new Cell(1, 1);
Cell pos13 = new Cell(2, 1); //8
Cell pos14 = new Cell(3, 1);
Cell pos15 = new Cell(4, 1); //4

Cell pos21 = new Cell(0, 2); //8
Cell pos22 = new Cell(1, 2);
Cell pos23 = new Cell(2, 2);
Cell pos24 = new Cell(3, 2);
Cell pos25 = new Cell(4, 2); //4

Cell pos31 = new Cell(0, 3); //8
Cell pos32 = new Cell(1, 3);
Cell pos33 = new Cell(2, 3);
Cell pos34 = new Cell(3, 3);
Cell pos35 = new Cell(4, 3); //4


List<Cell> list = new List<Cell>();
list.Add(pos01);
list.Add(pos02);
list.Add(pos03);
list.Add(pos04);
list.Add(pos05);

list.Add(pos11);
list.Add(pos12);
list.Add(pos13);
list.Add(pos14);
list.Add(pos15);

list.Add(pos21);
list.Add(pos22);
list.Add(pos23);
list.Add(pos24);
list.Add(pos25);

list.Add(pos31);
list.Add(pos32);
list.Add(pos33);
list.Add(pos34);
list.Add(pos35);

Player p2 = new Player("Luka");

Game game = new Game(p2, new Map("background"));

game.UsedMap.Boards = list;

game.PlaceResult(pos02, 5);
game.PlaceResult(pos03, 5);
game.PlaceResult(pos32, 5);

game.PlaceResult(pos31, 8);
game.PlaceResult(pos21, 8);
game.PlaceResult(pos21, 8);
game.PlaceResult(pos13, 8);

game.PlaceResult(pos05, 4);
game.PlaceResult(pos15, 4);
game.PlaceResult(pos25, 4);
game.PlaceResult(pos35, 4);

int cpt = 0;
/*
foreach (var item in game.UsedMap.Boards)
{
    Console.Write(" | ");
    Console.Write(item.Value);
    cpt++;
    if (cpt % 4 == 0) Console.Write(" |\n");
}
*/

for (int i = 0; i<game.UsedMap.Boards.Count; i++)
{
    Console.Write(" | ");
    Console.Write(game.UsedMap.Boards[i].Value);
    cpt++;
    if (cpt % 5 == 0) Console.Write(" |\n");
}

Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos02, game.UsedMap));

Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos13, game.UsedMap));
Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos31, game.UsedMap));
Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos13, game.UsedMap));

//foreach(var oui in game.GameRules.EveryAdjacentCells(pos13, game.UsedMap.Boards))  //du débug
//{
//    Console.WriteLine(oui.Value);
//}

Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos32, game.UsedMap));
Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos33, game.UsedMap));

Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos05, game.UsedMap));
Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos15, game.UsedMap));
Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos25, game.UsedMap));
Console.WriteLine(game.GameRules.IsZoneValidAndAddToZones(pos35, game.UsedMap));


//affichage des zones
foreach (var item in game.UsedMap.Zones)
{
    foreach (var cell in item)
    {
        Console.WriteLine(cell.Value);
    }
    Console.Write(" |\n");
}

Console.WriteLine(game.GameRules.FinalCalculusOfZones(game.UsedMap.Zones));