diff --git a/Qwirkle/QwirkleViews/MainPage.xaml.cs b/Qwirkle/QwirkleViews/MainPage.xaml.cs
index 0a5ee92..e4bfe0f 100644
--- a/Qwirkle/QwirkleViews/MainPage.xaml.cs
+++ b/Qwirkle/QwirkleViews/MainPage.xaml.cs
@@ -3,6 +3,7 @@ using QwirkleClassLibrary;
using QwirkleClassLibrary.Games;
using Microsoft.Maui.Controls;
using Qwirkle.Pages;
+using QwirkleClassLibrary.Persistences;
namespace Qwirkle
{
@@ -22,9 +23,25 @@ namespace Qwirkle
Navigation.PushAsync(new SetPlayers());
}
- public void OnContinueClicked(object sender, EventArgs e)
+ public async void OnContinueClicked(object sender, EventArgs e)
{
- Navigation.PushAsync(new Gameboard("ContinueGame"));
+ IGamePersistence gameLoad = new GamePersistenceXml();
+ try
+ {
+ ((App)Application.Current!).Game = gameLoad.LoadGame();
+ await Navigation.PushAsync(new Gameboard());
+ }
+ catch
+ {
+ await DisplayAlert("Error", "No game found", "Got it !");
+ await Navigation.PopAsync();
+ }
+
+ if (!((App)Application.Current!).Game.GameRunning)
+ {
+ await DisplayAlert("Error", "No game found", "Got it !");
+ await Navigation.PopAsync();
+ }
}
public void OnRulesClicked(object sender, EventArgs e)
diff --git a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs
index 0ae1a57..85ad7ad 100644
--- a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs
+++ b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs
@@ -30,37 +30,14 @@ public partial class Gameboard : ContentPage
public Color ColorBC3 { get; set; } = Colors.Transparent;
public Color ColorBC4 { get; set; } = Colors.Transparent;
- public Gameboard(string caller)
+ public Gameboard()
{
InitializeComponent();
BindingContext = game;
ChangeColorBC();
- if (caller == "ContinueGame")
- {
- CheckContinuedGame();
- }
- }
-
- private async void CheckContinuedGame()
- {
- IGamePersistence gameLoad = new GamePersistenceXml();
- try
- {
- game = gameLoad.LoadGame();
- }
- catch
- {
- await DisplayAlert("Error", "No game found", "Got it !");
- await Navigation.PopAsync();
- }
- if (game.GameRunning == false)
- {
- await DisplayAlert("Error", "No game found", "Got it !");
- await Navigation.PopAsync();
- }
}
private async void Game_EndOfGameNotified(object? sender, EndOfGameNotifiedEventArgs e)
@@ -260,5 +237,10 @@ public partial class Gameboard : ContentPage
}
}
+ private void OnButtonBookClicked(object? sender, EventArgs e)
+ {
+ Navigation.PushAsync(new Rules());
+ }
+
}
diff --git a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml
index cd5d839..da93ebb 100644
--- a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml
+++ b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml
@@ -39,6 +39,8 @@
+
+