continuer page plateau
continuous-integration/drone/push Build is failing Details

master
Céleste BARBOSA 11 months ago
parent 643a15c879
commit d336cb4e92

@ -1,14 +1,20 @@
using CoreLibrary.Events;
using CoreLibrary.Joueurs;
using CoreLibrary.Persistance;
using System.Collections.Generic;
namespace CoreLibrary.Manager
{
public class Manageur
{
public List<Joueur> joueurs;
public List<Partie> parties;
private IPersistance persistance;
private readonly List<Joueur> joueurs;
private readonly List<Partie> parties;
private readonly IPersistance persistance;
private Partie? partie;
public IReadOnlyCollection<Joueur> Joueurs => joueurs;
public IReadOnlyCollection<Partie> Parties => parties;
public Partie? Partie => partie;
public Manageur(IPersistance persistance)
{
@ -19,6 +25,8 @@ namespace CoreLibrary.Manager
public void NouvellePartie(Partie partie)
{
this.partie = partie;
parties.Add(partie);
partie.PasserMain += (object? sender, PasserMainEventArgs e) =>

@ -15,7 +15,8 @@ namespace MauiSpark.Convertisseurs
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not Couleur) return Noir;
if (value is not Couleur)
return Noir;
switch (value)
{

@ -12,70 +12,66 @@
<conv:JetonVersTexte x:Key="JetonVersTexte"/>
</ContentPage.Resources>
<ContentPage.Content>
<Grid RowDefinitions="*" ColumnDefinitions="*, *">
<Grid RowDefinitions="*" ColumnDefinitions="*" Margin="50">
<Border
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
StrokeThickness="2"
StrokeShape="RoundRectangle 10"
HorizontalOptions="Center">
<FlexLayout
Direction="Column"
Wrap="Wrap"
JustifyContent="SpaceBetween"
AlignItems="Stretch"
BindableLayout.ItemsSource="{Binding Plateau}">
StrokeShape="RoundRectangle 10">
<StackLayout 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"
ColumnDefinitions="*, 3*"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<StackLayout
Orientation="Horizontal"
BindableLayout.ItemsSource="{Binding [1]}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label
Text="*"
TextColor="{Binding ., Converter={StaticResource IndicateurVersCouleurMAUI}}"
VerticalOptions="Center"
HorizontalOptions="Center" />
<Label Text="O"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
</StackLayout>
<FlexLayout
VerticalOptions="Center"
<StackLayout
Orientation="Horizontal"
Grid.Column="1"
Direction="Row"
Wrap="Wrap"
JustifyContent="SpaceAround"
AlignItems="Center"
BindableLayout.ItemsSource="{Binding [0]}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Path=Couleur, Converter={StaticResource conv:CouleurVersCouleurMAUI}}"/>
<vues:JetonVue
Couleur="{Binding Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
</StackLayout>
<BoxView Grid.Row="1" Grid.ColumnSpan="2" HeightRequest="1" VerticalOptions="End"/>
<BoxView
Grid.ColumnSpan="2"
Grid.Row="1"
HeightRequest="1"
VerticalOptions="End"/>
</Grid>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
</StackLayout>
</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"
@ -92,21 +88,21 @@
</Label.GestureRecognizers>
</Label>
<FlexLayout
VerticalOptions="Center"
<StackLayout
Orientation="Horizontal"
Grid.Column="1"
Grid.ColumnSpan="4"
Direction="Row"
Wrap="Wrap"
JustifyContent="SpaceAround"
AlignItems="Center"
BindableLayout.ItemsSource="{Binding Code.Jetons}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<vues:JetonVue Couleur="{Binding Couleur, Converter={StaticResource conv:CouleurVersCouleurMAUI}}"/>
<vues:JetonVue
Couleur="{Binding Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
</StackLayout>
<Label FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="5" Text="V">
<Label.GestureRecognizers>
@ -116,13 +112,13 @@
<BoxView Grid.Row="1" Grid.ColumnSpan="6" HeightRequest="1" VerticalOptions="Center"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Rouge}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Vert}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Bleu}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Rouge}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"></vues:JetonVue>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Vert}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Bleu}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Jaune}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Noir}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Blanc}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Jaune}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Noir}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Blanc}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2"/>
</Grid>
</Border>
@ -131,4 +127,5 @@
<vues:BoutonReglesVue Grid.Column="1" VerticalOptions="Start" HorizontalOptions="End"/>
</Grid>
</ContentPage.Content>
</ContentPage>

@ -1,10 +1,7 @@
using CoreLibrary;
using CoreLibrary.Core;
using CoreLibrary.Events;
using CoreLibrary.Exceptions;
using CoreLibrary.Joueurs;
using MauiSpark.Convertisseurs;
using System.Globalization;
namespace MauiSpark.Pages;
@ -68,22 +65,6 @@ public partial class PlateauPage : ContentPage
BindingContext = new Tour(e);
}
private void CouleurPresee(Object sender, EventArgs e)
{
Label label = (Label)sender;
Couleur couleur = (Couleur)new CouleurVersCouleurMAUI().ConvertBack(label.TextColor, typeof(Couleur), null, CultureInfo.InvariantCulture);
try
{
if(code != null)
code.AjouterJeton(new Jeton(couleur));
}
catch (CodeCompletException)
{
DisplayAlert("Attention", "La code est plein", "OK");
}
}
private void SupprimerDernierJeton(Object sender, EventArgs e)
{
try

@ -15,7 +15,7 @@ public class JoueurClassementNbCoupParPartie
}
public int Place
{
get => manageur.joueurs
get => manageur.Joueurs
.OrderBy(joueur => joueur.NbCoutTotal/(joueur.NbPartiePerdue+joueur.NbPartieGagnee+joueur.NbPartieEgalite)).ToList()
.IndexOf(Joueur) + 1;
}
@ -42,7 +42,7 @@ public class JoueurClassementPartieGagnee
public int Place
{
get => manageur.joueurs.OrderByDescending(joueur => joueur.NbPartieGagnee).ToList().IndexOf(Joueur) + 1;
get => manageur.Joueurs.OrderByDescending(joueur => joueur.NbPartieGagnee).ToList().IndexOf(Joueur) + 1;
}
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
@ -67,7 +67,7 @@ public class JoueurClassementPartieEgalite
public int Place
{
get => manageur.joueurs.OrderByDescending(joueur => joueur.NbPartieEgalite).ToList().IndexOf(joueur)+1;
get => manageur.Joueurs.OrderByDescending(joueur => joueur.NbPartieEgalite).ToList().IndexOf(joueur)+1;
}
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
@ -92,7 +92,7 @@ public class JoueurClassementPartiePerdue
public int Place
{
get => manageur.joueurs.OrderByDescending(joueur => joueur.NbPartiePerdue).ToList().IndexOf(joueur)+1;
get => manageur.Joueurs.OrderByDescending(joueur => joueur.NbPartiePerdue).ToList().IndexOf(joueur)+1;
}
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
@ -117,7 +117,7 @@ public class JoueurClassementAlphabet
public int Place
{
get => manageur.joueurs
get => manageur.Joueurs
.OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite)).ToList()
.IndexOf(Joueur) + 1;
}
@ -140,7 +140,7 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0)
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite))
.Select(joueur => new JoueurClassementNbCoupParPartie(joueur, MauiProgram.Manageur));
@ -148,7 +148,7 @@ public partial class CTableauScore : ContentView
else
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite))
.Select(joueur => new JoueurClassementNbCoupParPartie(joueur, MauiProgram.Manageur));
}
@ -159,14 +159,14 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0)
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.NbPartieGagnee)
.Select(joueur => new JoueurClassementPartieGagnee(joueur, MauiProgram.Manageur));
}
else
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.NbPartieGagnee)
.Select(joueur => new JoueurClassementPartieGagnee(joueur, MauiProgram.Manageur));
}
@ -178,14 +178,14 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0)
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.NbPartieEgalite)
.Select(joueur => new JoueurClassementPartieEgalite(joueur, MauiProgram.Manageur));
}
else
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.NbPartieEgalite)
.Select(joueur => new JoueurClassementPartieEgalite(joueur, MauiProgram.Manageur));
}
@ -197,14 +197,14 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0)
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.NbPartiePerdue)
.Select(joueur => new JoueurClassementPartiePerdue(joueur, MauiProgram.Manageur));
}
else
{
NbClique++;
; return MauiProgram.Manageur.joueurs
; return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.NbPartiePerdue)
.Select(joueur => new JoueurClassementPartiePerdue(joueur, MauiProgram.Manageur));
}
@ -216,14 +216,14 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0)
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.Nom)
.Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manageur));
}
else
{
NbClique++;
return MauiProgram.Manageur.joueurs
return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.Nom)
.Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manageur));
}

@ -6,11 +6,19 @@
<Grid
x:Name="Grid"
SizeChanged="QuandTailleChangee">
SizeChanged="QuandTailleChangee"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<Ellipse
x:Name="Cercle"
Fill="{Binding Couleur, Source={x:Reference jetonVue}}"/>
Fill="{Binding Couleur, Source={x:Reference jetonVue}}">
<Ellipse.GestureRecognizers>
<TapGestureRecognizer Tapped="JetonPresse"/>
</Ellipse.GestureRecognizers>
</Ellipse>
</Grid>
</ContentView>

@ -1,15 +1,25 @@
using Microsoft.Maui.Controls.Shapes;
using CoreLibrary.Core;
using CoreLibrary.Exceptions;
using MauiSpark.Convertisseurs;
using System.Globalization;
namespace MauiSpark.Vues;
public partial class JetonVue : ContentView
{
public static readonly BindableProperty CouleurProperty = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(JetonVue), default(Color), propertyChanged: QuandCouleurChangee);
public static readonly BindableProperty CodeProperty = BindableProperty.Create(nameof(Code), typeof(Code), typeof(JetonVue), null, propertyChanged: QuandCodeChange);
public Color Couleur
{
get => (Color)GetValue(CouleurProperty);
set => SetValue(CouleurProperty, Color.FromRgb(0, 255, 0));
set => SetValue(CouleurProperty, value);
}
public Code? Code
{
get => (Code?)GetValue(CodeProperty);
set => SetValue(CodeProperty, value);
}
public JetonVue()
@ -25,7 +35,32 @@ public partial class JetonVue : ContentView
}
private static void QuandCouleurChangee(BindableObject bindable, object ancienneValeur, object nouvelleValeur)
{
if (((Color)nouvelleValeur).Red != 0 || ((Color)nouvelleValeur).Green != 0 || ((Color)nouvelleValeur).Blue != 0)
{
((JetonVue)bindable).Cercle.Fill = (Color)nouvelleValeur;
}
}
private static void QuandCodeChange(BindableObject bindable, object ancienneValeur, object nouvelleValeur)
{
}
private void JetonPresse(object sender, EventArgs e)
{
if (Cercle == null || !sender.Equals(Cercle) || Code == null || Application.Current == null || Application.Current.MainPage == null)
return;
Couleur couleur = (Couleur)new CouleurVersCouleurMAUI().ConvertBack(Cercle.Fill, typeof(Couleur), null, CultureInfo.InvariantCulture);
try
{
Code.AjouterJeton(new Jeton(couleur));
}
catch (CodeCompletException)
{
Application.Current.MainPage.DisplayAlert("Attention", "La code est plein", "OK");
}
}
}

@ -2,12 +2,13 @@ namespace MauiSpark.Vues;
public partial class TitreVue : ContentView
{
public static readonly BindableProperty TextePropriete = BindableProperty.Create(nameof(Texte), typeof(string), typeof(TitreVue), default(string));
public static readonly BindableProperty TexteProperty = BindableProperty.Create(nameof(Texte), typeof(string), typeof(TitreVue), default(string));
public string Texte
{
get => (string)GetValue(TextePropriete);
set => SetValue(TextePropriete, value.ToUpper());
get => (string)GetValue(TexteProperty);
set => SetValue(TexteProperty, value.ToUpper());
}
public TitreVue()

Loading…
Cancel
Save