diff --git a/Qwirkle/Files/Game.xml b/Qwirkle/Files/Game.xml
index 3909ecb..b191d2f 100644
--- a/Qwirkle/Files/Game.xml
+++ b/Qwirkle/Files/Game.xml
@@ -1,1550 +1 @@
-
- true
-
-
-
- Red
- Square
-
-
- Blue
- Square
-
-
- Green
- Square
-
-
- Yellow
- Square
-
-
- Orange
- Square
-
-
- Purple
- Square
-
-
- Red
- Round
-
-
- Blue
- Round
-
-
- Green
- Round
-
-
- Orange
- Round
-
-
- Purple
- Round
-
-
- Green
- Rhombus
-
-
- Yellow
- Rhombus
-
-
- Purple
- Rhombus
-
-
- Red
- Club
-
-
- Blue
- Club
-
-
- Green
- Club
-
-
- Yellow
- Club
-
-
- Purple
- Club
-
-
- Red
- Shuriken
-
-
- Blue
- Shuriken
-
-
- Green
- Shuriken
-
-
- Purple
- Shuriken
-
-
- Red
- Star
-
-
- Blue
- Star
-
-
- Green
- Star
-
-
- Yellow
- Star
-
-
- Orange
- Star
-
-
- Purple
- Star
-
-
- Red
- Square
-
-
- Blue
- Square
-
-
- Green
- Square
-
-
- Yellow
- Square
-
-
- Blue
- Round
-
-
- Purple
- Round
-
-
- Red
- Rhombus
-
-
- Green
- Rhombus
-
-
- Yellow
- Rhombus
-
-
- Purple
- Rhombus
-
-
- Blue
- Club
-
-
- Green
- Club
-
-
- Yellow
- Club
-
-
- Purple
- Club
-
-
- Red
- Shuriken
-
-
- Green
- Shuriken
-
-
- Yellow
- Shuriken
-
-
- Orange
- Shuriken
-
-
- Purple
- Shuriken
-
-
- Red
- Star
-
-
- Blue
- Star
-
-
- Orange
- Star
-
-
- Purple
- Star
-
-
- Red
- Square
-
-
- Blue
- Square
-
-
- Yellow
- Square
-
-
- Orange
- Square
-
-
- Purple
- Square
-
-
- Blue
- Round
-
-
- Green
- Round
-
-
- Yellow
- Round
-
-
- Purple
- Round
-
-
- Red
- Rhombus
-
-
- Blue
- Rhombus
-
-
- Green
- Rhombus
-
-
- Yellow
- Rhombus
-
-
- Orange
- Rhombus
-
-
- Purple
- Rhombus
-
-
- Red
- Club
-
-
- Blue
- Club
-
-
- Green
- Club
-
-
- Yellow
- Club
-
-
- Orange
- Club
-
-
- Purple
- Club
-
-
- Red
- Shuriken
-
-
- Blue
- Shuriken
-
-
- Green
- Shuriken
-
-
- Yellow
- Shuriken
-
-
- Orange
- Shuriken
-
-
- Purple
- Shuriken
-
-
- Red
- Star
-
-
- Green
- Star
-
-
- Yellow
- Star
-
-
- Orange
- Star
-
-
- Purple
- Star
-
-
- Orange
- Round
-
-
- Orange
- Club
-
-
- Red
- Round
-
-
-
-
- 15
- 12
-
-
-
- Blue
- Rhombus
-
- 0
- 0
-
-
-
- 0
- 1
-
-
-
- Orange
- Round
-
- 0
- 2
-
-
-
- Yellow
- Round
-
- 0
- 3
-
-
-
- Red
- Round
-
- 0
- 4
-
-
-
- 0
- 5
-
-
-
- 0
- 6
-
-
-
- 0
- 7
-
-
-
- 0
- 8
-
-
-
- 0
- 9
-
-
-
- 0
- 10
-
-
-
- 0
- 11
-
-
-
- 0
- 12
-
-
-
- 0
- 13
-
-
-
- 0
- 14
-
-
-
- Red
- Rhombus
-
- 1
- 0
-
-
-
- Blue
- Rhombus
-
- 1
- 1
-
-
-
- Orange
- Rhombus
-
- 1
- 2
-
-
-
- 1
- 3
-
-
-
- 1
- 4
-
-
-
- 1
- 5
-
-
-
- 1
- 6
-
-
-
- 1
- 7
-
-
-
- 1
- 8
-
-
-
- 1
- 9
-
-
-
- 1
- 10
-
-
-
- 1
- 11
-
-
-
- 1
- 12
-
-
-
- 1
- 13
-
-
-
- 1
- 14
-
-
-
- 2
- 0
-
-
-
- Blue
- Star
-
- 2
- 1
-
-
-
- 2
- 2
-
-
-
- 2
- 3
-
-
-
- 2
- 4
-
-
-
- 2
- 5
-
-
-
- 2
- 6
-
-
-
- 2
- 7
-
-
-
- 2
- 8
-
-
-
- 2
- 9
-
-
-
- 2
- 10
-
-
-
- 2
- 11
-
-
-
- 2
- 12
-
-
-
- 2
- 13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
-
-
- 7
- 11
-
-
-
- 7
- 12
-
-
-
- 7
- 13
-
-
-
- 7
- 14
-
-
-
- 8
- 0
-
-
-
- 8
- 1
-
-
-
- 8
- 2
-
-
-
- 8
- 3
-
-
-
- 8
- 4
-
-
-
- 8
- 5
-
-
-
- 8
- 6
-
-
-
- 8
- 7
-
-
-
- 8
- 8
-
-
-
- 8
- 9
-
-
-
- 8
- 10
-
-
-
- 8
- 11
-
-
-
- 8
- 12
-
-
-
- 8
- 13
-
-
-
- 8
- 14
-
-
-
- 9
- 0
-
-
-
- 9
- 1
-
-
-
- 9
- 2
-
-
-
- 9
- 3
-
-
-
- 9
- 4
-
-
-
- 9
- 5
-
-
-
- 9
- 6
-
-
-
- 9
- 7
-
-
-
- 9
- 8
-
-
-
- 9
- 9
-
-
-
- 9
- 10
-
-
-
- 9
- 11
-
-
-
- 9
- 12
-
-
-
- 9
- 13
-
-
-
- 9
- 14
-
-
-
- 10
- 0
-
-
-
- 10
- 1
-
-
-
- 10
- 2
-
-
-
- 10
- 3
-
-
-
- 10
- 4
-
-
-
- 10
- 5
-
-
-
- 10
- 6
-
-
-
- 10
- 7
-
-
-
- 10
- 8
-
-
-
- 10
- 9
-
-
-
- 10
- 10
-
-
-
- 10
- 11
-
-
-
- 10
- 12
-
-
-
- 10
- 13
-
-
-
- 10
- 14
-
-
-
- 11
- 0
-
-
-
- 11
- 1
-
-
-
- 11
- 2
-
-
-
- 11
- 3
-
-
-
- 11
- 4
-
-
-
- 11
- 5
-
-
-
- 11
- 6
-
-
-
- 11
- 7
-
-
-
- 11
- 8
-
-
-
- 11
- 9
-
-
-
- 11
- 10
-
-
-
- 11
- 11
-
-
-
- 11
- 12
-
-
-
- 11
- 13
-
-
-
- 11
- 14
-
-
-
-
-
-
- true
- Jules
-
-
- Yellow
- Star
-
-
- Orange
- Club
-
-
- Orange
- Square
-
-
- Yellow
- Round
-
-
- Orange
- Rhombus
-
-
- Green
- Star
-
-
-
-
- false
- Jérémy
-
-
- Green
- Square
-
-
- Purple
- Square
-
-
- Red
- Club
-
-
- Green
- Round
-
-
- Yellow
- Shuriken
-
-
- Orange
- Shuriken
-
-
-
-
-
-
-
- 8
-
-
-
- 9
-
-
-
\ No newline at end of file
+false15120001020304050607080901001101201301410RedRound11RedSquare121314151617181911011111211311420OrangeRound21OrangeSquare222324252627282921021121221321430PurpleRound31PurpleSquare323334353637383931031131231331440BlueRound41BlueSquare424344454647484941041141241341450YellowRound51525354555657585951051151251351460GreenRound6162636465666768696106116126136147071727374757677787971071171271371480818283848586878889810811812813814909192939495969798999109119129139141001011021031041051061071081091010101110121013101411011111211311411511611711811911101111111211131114falseJulesGreenSquareYellowSquaretrueJérémy430
\ No newline at end of file
diff --git a/Qwirkle/Files/LeaderBoard.json b/Qwirkle/Files/LeaderBoard.json
index fbec232..d109a1c 100644
--- a/Qwirkle/Files/LeaderBoard.json
+++ b/Qwirkle/Files/LeaderBoard.json
@@ -1 +1,16 @@
-{"leaderboard":[]}
\ No newline at end of file
+{
+ "leaderboard": [
+ {
+ "Date": "\/Date(1717432093871+0200)\/",
+ "PlayerName": "Jérémy",
+ "Points": 30,
+ "Victories": 2
+ },
+ {
+ "Date": "\/Date(1717432093871+0200)\/",
+ "PlayerName": "Jules",
+ "Points": 4,
+ "Victories": 0
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Qwirkle/QwirkleClassLibrary/Players/Leaderboard.cs b/Qwirkle/QwirkleClassLibrary/Players/Leaderboard.cs
index 3a06518..db9a0b6 100644
--- a/Qwirkle/QwirkleClassLibrary/Players/Leaderboard.cs
+++ b/Qwirkle/QwirkleClassLibrary/Players/Leaderboard.cs
@@ -41,7 +41,7 @@ namespace QwirkleClassLibrary.Players
///
public void AddScoreInLead(ReadOnlyDictionary scoreBoard)
{
- DateTime now = DateTime.Today;
+ DateTime now = DateTime.Now;
bool first = true;
var sb = scoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
@@ -59,7 +59,10 @@ namespace QwirkleClassLibrary.Players
leaderboard[i].Victories++;
}
- leaderboard[i].Points = pair.Value;
+ if (pair.Value > leaderboard[i].Points)
+ {
+ leaderboard[i].Points = pair.Value;
+ }
}
else
diff --git a/Qwirkle/QwirkleClassLibrary/Tiles/TileBag.cs b/Qwirkle/QwirkleClassLibrary/Tiles/TileBag.cs
index fc6381a..e616b4e 100644
--- a/Qwirkle/QwirkleClassLibrary/Tiles/TileBag.cs
+++ b/Qwirkle/QwirkleClassLibrary/Tiles/TileBag.cs
@@ -29,17 +29,31 @@ namespace QwirkleClassLibrary.Tiles
throw new ArgumentException(nbSet.ToString());
}
- for (int i = 0; i < nbSet; i++)
- {
- foreach (Shape s in Enum.GetValues(typeof(Shape)))
- {
- foreach (Color c in Enum.GetValues(typeof(Color)))
- {
- Tile t = new Tile(s, c);
- tiles.Add(t);
- }
- }
- }
+ // for (int i = 0; i < nbSet; i++)
+ // {
+ // foreach (Shape s in Enum.GetValues(typeof(Shape)))
+ // {
+ // foreach (Color c in Enum.GetValues(typeof(Color)))
+ // {
+ // Tile t = new Tile(s, c);
+ // tiles.Add(t);
+ // }
+ // }
+ // }
+
+ tiles.Add(new Tile(Shape.Round, Color.Red));
+ tiles.Add(new Tile(Shape.Round, Color.Orange));
+ tiles.Add(new Tile(Shape.Round, Color.Yellow));
+ tiles.Add(new Tile(Shape.Round, Color.Green));
+ tiles.Add(new Tile(Shape.Round, Color.Blue));
+ tiles.Add(new Tile(Shape.Round, Color.Purple));
+
+ tiles.Add(new Tile(Shape.Square, Color.Red));
+ tiles.Add(new Tile(Shape.Square, Color.Orange));
+ tiles.Add(new Tile(Shape.Square, Color.Yellow));
+ tiles.Add(new Tile(Shape.Square, Color.Green));
+ tiles.Add(new Tile(Shape.Square, Color.Blue));
+ tiles.Add(new Tile(Shape.Square, Color.Purple));
Init();
}
diff --git a/Qwirkle/QwirkleConsoleApp/Program.cs b/Qwirkle/QwirkleConsoleApp/Program.cs
index 9961774..bd5f370 100644
--- a/Qwirkle/QwirkleConsoleApp/Program.cs
+++ b/Qwirkle/QwirkleConsoleApp/Program.cs
@@ -398,12 +398,10 @@ static void MainGame()
game.StartGame();
MainMenu(game);
- foreach (var player in game.PlayerList)
+ if (!game.GameRunning)
{
- if (game.CheckGameOver(player))
- {
- leaderboard.AddScoreInLead(game.ScoreBoard);
- }
+ leaderboard.AddScoreInLead(game.ScoreBoard);
+ break;
}
ILeaderboardPersistence leaderboardSave = new LeaderboardPersistenceJson();
@@ -422,8 +420,8 @@ static void MainGame()
}
catch
{
- ForegroundColor = ConsoleColor.Red;
- WriteLine("ERROR : No game saved ! Creating a new game !");
+ ForegroundColor = ConsoleColor.Yellow;
+ WriteLine("WARNING : No game saved ! Creating a new game !");
ResetColor();
loadedGame = new Game();
}
@@ -437,16 +435,28 @@ static void MainGame()
}
else
{
+ loadedGame = new Game();
+ ForegroundColor = ConsoleColor.Yellow;
+ WriteLine("WARNING : The previous saved game was over ! Creating a new game !");
+ ResetColor();
AddPlayers(loadedGame);
loadedGame.StartGame();
MainMenu(loadedGame);
}
- leaderboard.AddScoreInLead(loadedGame.ScoreBoard);
+ if (!loadedGame.GameRunning)
+ {
+ leaderboard.AddScoreInLead(loadedGame.ScoreBoard);
+ }
+
+ ILeaderboardPersistence leaderboardSave2 = new LeaderboardPersistenceJson();
+ leaderboardSave2.SaveLeaderboard(leaderboard);
break;
case 3:
+ ILeaderboardPersistence leaderboardLoad2 = new LeaderboardPersistenceJson();
+ leaderboard = leaderboardLoad2.LoadLeaderboard();
ShowLeaderboard(leaderboard);
break;