Binding sur le déroulement d'une partie
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
30bad619ad
commit
84ca6115f3
@ -1,9 +1,14 @@
|
|||||||
|
using CoreLibrary;
|
||||||
|
using CoreLibrary.Events;
|
||||||
|
|
||||||
namespace MauiSpark.Pages;
|
namespace MauiSpark.Pages;
|
||||||
|
|
||||||
public partial class Defaite : ContentPage
|
public partial class Defaite : ContentPage
|
||||||
{
|
{
|
||||||
public Defaite()
|
public Defaite(Partie p, PartieTermineeEventArgs e)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
BindingContext = $"Aucun des deux joueurs, {e.Perdants.First().Nom} et {e.Perdants.Last().Nom} n'a trouvé le code secret";
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,151 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:conv="clr-namespace:MauiSpark.Convertisseurs"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="MauiSpark.Pages.Plateau"
|
x:Class="MauiSpark.Pages.Plateau"
|
||||||
Title="Plateau">
|
Title="Plateau">
|
||||||
|
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<conv:CouleurVersCouleurMAUI x:Key="CouleurVersCouleurMAUI"/>
|
||||||
|
<conv:IndicateurVersCouleurMAUI x:Key="IndicateurVersCouleurMAUI"/>
|
||||||
|
<conv:JetonVersTexte x:Key="JetonVersTexte"/>
|
||||||
|
</ContentPage.Resources>
|
||||||
|
|
||||||
|
<Grid RowDefinitions="*" ColumnDefinitions="*, *">
|
||||||
|
<Grid RowDefinitions="*" ColumnDefinitions="*" Margin="50">
|
||||||
|
<Border
|
||||||
|
Stroke="#000000"
|
||||||
|
StrokeThickness="2"
|
||||||
|
StrokeShape="RoundRectangle 10"
|
||||||
|
HorizontalOptions="Center">
|
||||||
|
<FlexLayout
|
||||||
|
Direction="Column"
|
||||||
|
Wrap="Wrap"
|
||||||
|
JustifyContent="SpaceBetween"
|
||||||
|
AlignItems="Stretch"
|
||||||
|
BindableLayout.ItemsSource="{Binding Plateau}">
|
||||||
|
<BindableLayout.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid
|
||||||
|
FlexLayout.Grow="1"
|
||||||
|
FlexLayout.AlignSelf="Stretch"
|
||||||
|
RowDefinitions="*, auto"
|
||||||
|
ColumnDefinitions="*, 5*">
|
||||||
|
<FlexLayout
|
||||||
|
VerticalOptions="Center"
|
||||||
|
Direction="Row"
|
||||||
|
Wrap="Wrap"
|
||||||
|
JustifyContent="SpaceAround"
|
||||||
|
AlignItems="Center"
|
||||||
|
BindableLayout.ItemsSource="{Binding [1]}">
|
||||||
|
<BindableLayout.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Label
|
||||||
|
Text="*"
|
||||||
|
TextColor="{Binding ., Converter={StaticResource IndicateurVersCouleurMAUI}}"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
HorizontalOptions="Center" />
|
||||||
|
</DataTemplate>
|
||||||
|
</BindableLayout.ItemTemplate>
|
||||||
|
</FlexLayout>
|
||||||
|
|
||||||
|
<FlexLayout
|
||||||
|
VerticalOptions="Center"
|
||||||
|
Grid.Column="1"
|
||||||
|
Direction="Row"
|
||||||
|
Wrap="Wrap"
|
||||||
|
JustifyContent="SpaceAround"
|
||||||
|
AlignItems="Center"
|
||||||
|
BindableLayout.ItemsSource="{Binding [0]}">
|
||||||
|
<BindableLayout.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Label Text="O"
|
||||||
|
TextColor="{Binding Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
HorizontalOptions="Center" />
|
||||||
|
</DataTemplate>
|
||||||
|
</BindableLayout.ItemTemplate>
|
||||||
|
</FlexLayout>
|
||||||
|
|
||||||
|
<BoxView Grid.Row="1" Grid.ColumnSpan="2" HeightRequest="1" BackgroundColor="#000000" VerticalOptions="End"/>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</BindableLayout.ItemTemplate>
|
||||||
|
</FlexLayout>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Column="1" RowDefinitions="*, 2*, *" ColumnDefinitions="*" Margin="50">
|
||||||
|
<Label Text="{Binding Joueur}" FontSize="Large" VerticalOptions="Center" HorizontalOptions="Center"/>
|
||||||
|
|
||||||
|
|
||||||
|
<Border
|
||||||
|
HorizontalOptions="FillAndExpand"
|
||||||
|
Grid.Row="1"
|
||||||
|
Stroke="#000000"
|
||||||
|
StrokeThickness="2"
|
||||||
|
StrokeShape="RoundRectangle 10">
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
RowDefinitions="*, auto, *, *"
|
||||||
|
ColumnDefinitions="*, *, *, *, *, *">
|
||||||
|
|
||||||
|
<Label FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text="X">
|
||||||
|
<Label.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="SupprimerDernierJeton"/>
|
||||||
|
</Label.GestureRecognizers>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<Label FontSize="Medium" HorizontalOptions="Center" VerticalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="1" TextColor="{Binding Code.Jetons[0].Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}" Text="{Binding Code.Jetons[0], Converter={StaticResource JetonVersTexte}}"/>
|
||||||
|
<Label FontSize="Medium" HorizontalOptions="Center" VerticalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="2" TextColor="{Binding Code.Jetons[1].Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}" Text="{Binding Code.Jetons[1], Converter={StaticResource JetonVersTexte}}"/>
|
||||||
|
<Label FontSize="Medium" HorizontalOptions="Center" VerticalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="3" TextColor="{Binding Code.Jetons[2].Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}" Text="{Binding Code.Jetons[2], Converter={StaticResource JetonVersTexte}}"/>
|
||||||
|
<Label FontSize="Medium" HorizontalOptions="Center" VerticalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="4" TextColor="{Binding Code.Jetons[3].Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}" Text="{Binding Code.Jetons[3], Converter={StaticResource JetonVersTexte}}"/>
|
||||||
|
|
||||||
|
<Label FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="5" Text="V">
|
||||||
|
<Label.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="ValiderCode"/>
|
||||||
|
</Label.GestureRecognizers>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
|
||||||
|
<BoxView Grid.Row="1" Grid.ColumnSpan="6" HeightRequest="1" BackgroundColor="#000000" VerticalOptions="Center"/>
|
||||||
|
|
||||||
|
<Label x:Name="JetonRouge" FontSize="Medium" TextColor="{x:Static conv:CouleurVersCouleurMAUI.Rouge}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Text="O">
|
||||||
|
<Label.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="CouleurPresee"/>
|
||||||
|
</Label.GestureRecognizers>
|
||||||
|
</Label>
|
||||||
|
<Label x:Name="JetonVert" FontSize="Medium" TextColor="{x:Static conv:CouleurVersCouleurMAUI.Vert}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2" Text="O">
|
||||||
|
<Label.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="CouleurPresee"/>
|
||||||
|
</Label.GestureRecognizers>
|
||||||
|
</Label>
|
||||||
|
<Label x:Name="JetonBleu" FontSize="Medium" TextColor="{x:Static conv:CouleurVersCouleurMAUI.Bleu}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="4" Grid.Row="2" Grid.ColumnSpan="2" Text="O">
|
||||||
|
<Label.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="CouleurPresee"/>
|
||||||
|
</Label.GestureRecognizers>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<Label x:Name="JetonJaune" FontSize="Medium" TextColor="{x:Static conv:CouleurVersCouleurMAUI.Jaune}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Text="O">
|
||||||
|
<Label.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="CouleurPresee"/>
|
||||||
|
</Label.GestureRecognizers>
|
||||||
|
</Label>
|
||||||
|
<Label x:Name="JetonNoir" FontSize="Medium" TextColor="{x:Static conv:CouleurVersCouleurMAUI.Noir}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2" Text="O">
|
||||||
|
<Label.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="CouleurPresee"/>
|
||||||
|
</Label.GestureRecognizers>
|
||||||
|
</Label>
|
||||||
|
<Label x:Name="JetonBlanc" FontSize="Medium" TextColor="{x:Static conv:CouleurVersCouleurMAUI.Blanc}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2" Text="O">
|
||||||
|
<Label.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="CouleurPresee"/>
|
||||||
|
</Label.GestureRecognizers>
|
||||||
|
</Label>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<Label Grid.Row="2" Text="{Binding Numero}" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
</ContentPage>
|
</ContentPage>
|
@ -1,15 +1,90 @@
|
|||||||
using CoreLibrary;
|
using CoreLibrary;
|
||||||
|
using CoreLibrary.Core;
|
||||||
using CoreLibrary.Events;
|
using CoreLibrary.Events;
|
||||||
|
using CoreLibrary.Exceptions;
|
||||||
|
using CoreLibrary.Joueurs;
|
||||||
|
using MauiSpark.Convertisseurs;
|
||||||
|
|
||||||
namespace MauiSpark.Pages;
|
namespace MauiSpark.Pages;
|
||||||
|
|
||||||
|
internal class Tour
|
||||||
|
{
|
||||||
|
public IEnumerable<(IEnumerable<Jeton>, IEnumerable<Indicateur>)> Plateau { get; private init; }
|
||||||
|
public Joueur Joueur { get; private init; }
|
||||||
|
public string Numero { get; private init; }
|
||||||
|
public Code Code { get; private init; }
|
||||||
|
|
||||||
|
public Tour(NouveauTourEventArgs e)
|
||||||
|
{
|
||||||
|
Numero = $"Tour {e.Tour}";
|
||||||
|
Joueur = e.Joueur;
|
||||||
|
Code = e.Code;
|
||||||
|
|
||||||
|
(IEnumerable<Jeton>, IEnumerable<Indicateur>)[] plateau = new (IEnumerable<Jeton>, IEnumerable<Indicateur>)[e.Grille.Count()];
|
||||||
|
for (int i = 0; i < e.Grille.Count(); ++i)
|
||||||
|
{
|
||||||
|
plateau[i] = (e.Grille.ElementAt(i).Where(x => x.HasValue).Select(x => x!.Value), e.Indicateurs.ElementAt(i));
|
||||||
|
}
|
||||||
|
Plateau = plateau;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public partial class Plateau : ContentPage
|
public partial class Plateau : ContentPage
|
||||||
{
|
{
|
||||||
|
private readonly Code code;
|
||||||
|
private readonly Joueur joueur;
|
||||||
|
|
||||||
public Plateau(Partie p, NouveauTourEventArgs e)
|
public Plateau(Partie p, NouveauTourEventArgs e)
|
||||||
{
|
{
|
||||||
|
NavigationPage.SetHasBackButton(this, false);
|
||||||
|
NavigationPage.SetHasNavigationBar(this, false);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
BindingContext = e;
|
code = e.Code;
|
||||||
|
joueur = e.Joueur;
|
||||||
|
|
||||||
|
BindingContext = new Tour(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CouleurPresee(Object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Label label = (Label)sender;
|
||||||
|
Couleur couleur = (Couleur)new CouleurVersCouleurMAUI().ConvertBack(label.TextColor, null, null, null);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
code.AjouterJeton(new Jeton(couleur));
|
||||||
|
}
|
||||||
|
catch (CodeCompletException ignored)
|
||||||
|
{
|
||||||
|
DisplayAlert("Attention", "La code est plein", "OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SupprimerDernierJeton(Object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
code.SupprimerDernierJeton();
|
||||||
|
}
|
||||||
|
catch(CodeVideException ignored)
|
||||||
|
{
|
||||||
|
DisplayAlert("Attention", "La code est vide", "OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValiderCode(Object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
joueur.Code(code);
|
||||||
|
}
|
||||||
|
catch (CodeIncompletException ignored)
|
||||||
|
{
|
||||||
|
DisplayAlert("Attention", "La code n'est pas complet", "OK");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,14 @@
|
|||||||
|
using CoreLibrary;
|
||||||
|
using CoreLibrary.Events;
|
||||||
|
|
||||||
namespace MauiSpark.Pages;
|
namespace MauiSpark.Pages;
|
||||||
|
|
||||||
public partial class Victoire : ContentPage
|
public partial class Victoire : ContentPage
|
||||||
{
|
{
|
||||||
public Victoire()
|
public Victoire(Partie partie, PartieTermineeEventArgs e)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
BindingContext = $"Le joueur {e.Gagnants.First().Nom} a gagné";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue