persistence work now + rules
continuous-integration/drone/push Build is passing Details

old_branch_before_remy
Jérémy Mouyon 11 months ago
parent 285243756f
commit 40aa294bd9

@ -3,6 +3,7 @@ using QwirkleClassLibrary;
using QwirkleClassLibrary.Games; using QwirkleClassLibrary.Games;
using Microsoft.Maui.Controls; using Microsoft.Maui.Controls;
using Qwirkle.Pages; using Qwirkle.Pages;
using QwirkleClassLibrary.Persistences;
namespace Qwirkle namespace Qwirkle
{ {
@ -22,9 +23,25 @@ namespace Qwirkle
Navigation.PushAsync(new SetPlayers()); 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) public void OnRulesClicked(object sender, EventArgs e)

@ -30,37 +30,14 @@ public partial class Gameboard : ContentPage
public Color ColorBC3 { get; set; } = Colors.Transparent; public Color ColorBC3 { get; set; } = Colors.Transparent;
public Color ColorBC4 { get; set; } = Colors.Transparent; public Color ColorBC4 { get; set; } = Colors.Transparent;
public Gameboard(string caller) public Gameboard()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = game; BindingContext = game;
ChangeColorBC(); 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) 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());
}
} }

@ -39,6 +39,8 @@
</Image> </Image>
</Border> </Border>
<ImageButton Grid.Row="0" Grid.Column="2" Source="bookicon.png" Clicked="OnButtonBookClicked" HeightRequest="70"></ImageButton>
<Button <Button
HorizontalOptions="Start" HorizontalOptions="Start"
Grid.Row="0" Grid.Column="1" Grid.Row="0" Grid.Column="1"

@ -10,7 +10,8 @@
<Grid Style="{StaticResource GridMain}"> <Grid Style="{StaticResource GridMain}">
<controls:GoBack></controls:GoBack> <controls:GoBack></controls:GoBack>
<Label Text="Qwirkle Rules" <Label Text="Qwirkle Rules"
Style="{StaticResource Title}" /> Style="{StaticResource Title}"
/>
</Grid> </Grid>
<Label <Label

@ -53,7 +53,7 @@ public partial class SetPlayers : ContentPage
game.StartGame(); game.StartGame();
game.GiveTilesToPlayers(); game.GiveTilesToPlayers();
game.SetNextPlayer(); game.SetNextPlayer();
Navigation.PushAsync(new Gameboard("NewGame")); Navigation.PushAsync(new Gameboard());
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Loading…
Cancel
Save