fusion Nouveau core vers doc
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
commit
8897ca4076
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:pages="clr-namespace:MauiSpark.Pages"
|
||||
x:Class="MauiSpark.Pages.ClassementPage"
|
||||
xmlns:vues="clr-namespace:MauiSpark.Vues"
|
||||
Title="ClassementPage">
|
||||
|
||||
<ScrollView>
|
||||
<VerticalStackLayout>
|
||||
<FlexLayout Direction="Row" JustifyContent="SpaceAround" AlignContent="Center" VerticalOptions="Center" Margin="10, 50" >
|
||||
<Image Source="star.png" WidthRequest="100" HorizontalOptions="End" VerticalOptions="Center" Margin="0"/>
|
||||
<vues:TitreVue Texte="classement"/>
|
||||
<Image Grid.Row="1" Source="star.png" WidthRequest="100" HorizontalOptions="Start" VerticalOptions="Center" Margin="0"/>
|
||||
</FlexLayout>
|
||||
|
||||
<Grid RowDefinitions="*" ColumnDefinitions="*, 2*, *" Padding="50">
|
||||
<Button x:Name="DiminuerRegles" Text="<" Clicked="ChangerReglesPresse" VerticalOptions="Center" HorizontalOptions="Center"/>
|
||||
<Label Grid.Column="1" x:Name="ReglesDifficiles" Text="{Binding Regles.Nom}" FontSize="Large" VerticalOptions="Center" HorizontalOptions="Center"/>
|
||||
<Button x:Name="AugmenterRegles" Grid.Column="2" Text=">" Clicked="ChangerReglesPresse" VerticalOptions="Center" HorizontalOptions="Center"/>
|
||||
</Grid>
|
||||
|
||||
<ScrollView Orientation="Horizontal">
|
||||
<VerticalStackLayout>
|
||||
<Border Margin="20" StrokeThickness="2" StrokeShape="RoundRectangle 10">
|
||||
<StackLayout
|
||||
Orientation="Horizontal"
|
||||
BindableLayout.ItemsSource="{Binding Titres}">
|
||||
|
||||
<BindableLayout.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Label Text="{Binding .}" FontSize="Medium" Margin="0, 20" WidthRequest="250" HorizontalTextAlignment="Center">
|
||||
<Label.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="StatistiquePressee"/>
|
||||
</Label.GestureRecognizers>
|
||||
</Label>
|
||||
</DataTemplate>
|
||||
</BindableLayout.ItemTemplate>
|
||||
</StackLayout>
|
||||
</Border>
|
||||
|
||||
<StackLayout BindableLayout.ItemsSource="{Binding Enfants}">
|
||||
<BindableLayout.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Margin="20, 0" StrokeThickness="2" StrokeShape="RoundRectangle 10" Padding="0,20">
|
||||
<StackLayout
|
||||
Orientation="Horizontal"
|
||||
BindableLayout.ItemsSource="{Binding Objets}">
|
||||
|
||||
<BindableLayout.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Label Text="{Binding .}" FontSize="Micro" WidthRequest="250" HorizontalTextAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
</BindableLayout.ItemTemplate>
|
||||
</StackLayout>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</BindableLayout.ItemTemplate>
|
||||
</StackLayout>
|
||||
</VerticalStackLayout>
|
||||
</ScrollView>
|
||||
</VerticalStackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
@ -0,0 +1,137 @@
|
||||
using CoreLibrary.Joueurs;
|
||||
using CoreLibrary.Statistiques;
|
||||
using CoreLibrary.Regles;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace MauiSpark.Pages
|
||||
{
|
||||
partial class Enfant
|
||||
{
|
||||
private readonly Classement classement;
|
||||
|
||||
public Joueur Joueur { get; set; }
|
||||
public int Place => classement.Enfants.ToList().IndexOf(this) + 1;
|
||||
public IEnumerable<int> Statistiques => Enum.GetValues<Statistique>()
|
||||
.Select(statistique => Joueur.Statistique(classement.Regles, statistique));
|
||||
|
||||
public IEnumerable<string> Objets => new List<string>([$"{Place}", Joueur.Nom])
|
||||
.Concat(Statistiques.Select(statistique => $"{statistique}"));
|
||||
|
||||
public Enfant(Joueur joueur, Classement classement)
|
||||
{
|
||||
this.classement = classement;
|
||||
Joueur = joueur;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null || obj is not Enfant)
|
||||
return false;
|
||||
|
||||
return Joueur == ((Enfant)obj).Joueur;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Joueur.GetHashCode();
|
||||
}
|
||||
|
||||
partial class Classement : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public void QuandProprieteChangee([CallerMemberName] string? propriete = null) =>
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propriete));
|
||||
|
||||
private int indiceRegles = 0;
|
||||
public IRegles Regles => ClassementPage.ToutesRegles.ElementAt(indiceRegles);
|
||||
|
||||
private Statistique statistique = Enum.GetValues<Statistique>().First();
|
||||
public Statistique Statistique
|
||||
{
|
||||
get => statistique;
|
||||
set
|
||||
{
|
||||
statistique = value;
|
||||
QuandProprieteChangee(nameof(Enfants));
|
||||
}
|
||||
}
|
||||
|
||||
private bool inverser = true;
|
||||
public bool Inverser {
|
||||
get => inverser;
|
||||
set
|
||||
{
|
||||
inverser = value;
|
||||
QuandProprieteChangee(nameof(Enfants));
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> Titres => new List<string>(["Place", "Nom"]).Concat(
|
||||
Enum.GetValues<Statistique>().Select(
|
||||
statistique => string.Concat((Enum.GetName(typeof(Statistique), statistique) ?? "").Select(
|
||||
(lettre, indice) => indice > 0 && char.IsUpper(lettre) ? $" {lettre}" : $"{lettre}")
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public IEnumerable<Enfant> Enfants => Inverser ?
|
||||
MauiProgram.Manageur.Joueurs
|
||||
.OrderBy(joueur => joueur.Statistique(Regles, Statistique))
|
||||
.Select(joueur => new Enfant(joueur, this)).Reverse() :
|
||||
MauiProgram.Manageur.Joueurs
|
||||
.OrderBy(joueur => joueur.Statistique(Regles, Statistique))
|
||||
.Select(joueur => new Enfant(joueur, this));
|
||||
|
||||
public void IncrementerRegles(int valeur)
|
||||
{
|
||||
if ((indiceRegles += valeur) < 0)
|
||||
indiceRegles = ClassementPage.ToutesRegles.Count() - 1;
|
||||
else if (indiceRegles >= ClassementPage.ToutesRegles.Count())
|
||||
indiceRegles = 0;
|
||||
|
||||
QuandProprieteChangee(nameof(Regles));
|
||||
QuandProprieteChangee(nameof(Enfants));
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ClassementPage : ContentPage
|
||||
{
|
||||
public static IEnumerable<IRegles> ToutesRegles => typeof(IRegles).Assembly.GetTypes()
|
||||
.Where(type => typeof(IRegles).IsAssignableFrom(type) && type.IsClass)
|
||||
.Select(type => (Activator.CreateInstance(type) as IRegles)!)
|
||||
.OrderBy(regles => regles.Indice);
|
||||
|
||||
public ClassementPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
|
||||
BindingContext = new Classement();
|
||||
}
|
||||
|
||||
public void ChangerReglesPresse(object sender, EventArgs e)
|
||||
{
|
||||
((Classement)BindingContext).IncrementerRegles(sender == DiminuerRegles ? -1 : 1);
|
||||
}
|
||||
|
||||
public void StatistiquePressee(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is not Label || !Enum.IsDefined(typeof(Statistique), ((Label)sender).Text.Replace(" ", "")))
|
||||
return;
|
||||
|
||||
Statistique statistique = Enum.Parse<Statistique>(((Label)sender).Text.Replace(" ", ""));
|
||||
Classement classement = (Classement)BindingContext;
|
||||
|
||||
if (classement.Statistique == statistique)
|
||||
{
|
||||
classement.Inverser = !classement.Inverser;
|
||||
return;
|
||||
}
|
||||
|
||||
classement.Inverser = true;
|
||||
classement.Statistique = statistique;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +1,25 @@
|
||||
using CoreLibrary;
|
||||
using CoreLibrary.Regles;
|
||||
|
||||
using CoreLibrary.Regles;
|
||||
|
||||
namespace MauiSpark.Pages;
|
||||
|
||||
/// <summary>
|
||||
/// Page de sélection des modes de jeux.
|
||||
/// </summary>
|
||||
public partial class ModePage : ContentPage
|
||||
public partial class ModePage : ContentPage
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructeur de la page mode.
|
||||
/// Initialise les paramètres de navigation et les composants de la page.
|
||||
/// </summary>
|
||||
public ModePage()
|
||||
{
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public ModePage()
|
||||
{
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
|
||||
/// <summary>
|
||||
/// Méthode déclenchée lorsque le bouton des règles est pressé.
|
||||
/// Crée une nouvelle partie selon les règles sélectionnées et démarre le jeu.
|
||||
/// </summary>
|
||||
/// <param name="sender">L'objet qui appelle l'événement ; ici le bouton des règles.</param>
|
||||
/// <param name="e">L'instance de l'événement EventArgs créée par le système.</param>
|
||||
private void QuandReglesPresse(Object sender, EventArgs e)
|
||||
{
|
||||
Partie partie;
|
||||
|
||||
if (sender.Equals(ReglesClassiques))
|
||||
partie = MauiProgram.Manageur.NouvellePartie(new ReglesClassiques());
|
||||
else
|
||||
return;
|
||||
|
||||
partie.PartieDemanderJoueur += new ConnexionPage().QuandDemanderNom;
|
||||
partie.PartieNouveauTour += new PlateauPage().QuandNouveauTour;
|
||||
partie.PartiePartieTerminee += new VictoirePage().QuandPartieTerminee;
|
||||
|
||||
partie.Jouer();
|
||||
}
|
||||
BindingContext = typeof(IRegles).Assembly.GetTypes()
|
||||
.Where(type => typeof(IRegles).IsAssignableFrom(type) && type.IsClass)
|
||||
.Select(type => (Activator.CreateInstance(type) as IRegles)!)
|
||||
.OrderBy(regles => regles.Indice);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:pages="clr-namespace:MauiSpark.Pages"
|
||||
x:Class="MauiSpark.Pages.TableauScore"
|
||||
Title="TableauScore">
|
||||
|
||||
<ScrollView>
|
||||
<VerticalStackLayout>
|
||||
<FlexLayout Direction="Row" JustifyContent="SpaceAround" AlignContent="Center" VerticalOptions="Center" Margin="10, 50" >
|
||||
<Image Source="star.png" WidthRequest="100" HorizontalOptions="End" VerticalOptions="Center" Margin="0"/>
|
||||
<Label Text="Scoreboard" Style="{StaticResource TexteTitre}" Margin="0" />
|
||||
<Image Grid.Row="1" Source="star.png" WidthRequest="100" HorizontalOptions="Start" VerticalOptions="Center" Margin="0"/>
|
||||
</FlexLayout>
|
||||
</VerticalStackLayout>
|
||||
</ScrollView>
|
||||
|
||||
</ContentPage>
|
@ -1,11 +0,0 @@
|
||||
namespace MauiSpark.Pages;
|
||||
|
||||
public partial class TableauScore : ContentPage
|
||||
{
|
||||
public TableauScore()
|
||||
{
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="MauiSpark.Vues.IndicateurVue"
|
||||
x:Name="indicateurVue">
|
||||
|
||||
<Grid
|
||||
x:Name="Grid"
|
||||
SizeChanged="QuandTailleChangee"
|
||||
VerticalOptions="FillAndExpand"
|
||||
HorizontalOptions="FillAndExpand">
|
||||
<Rectangle
|
||||
x:Name="Carre"
|
||||
Fill="{Binding Couleur, Source={x:Reference indicateurVue}}">
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
</ContentView>
|
@ -0,0 +1,28 @@
|
||||
using CoreLibrary.Core;
|
||||
using MauiSpark.Convertisseurs;
|
||||
using System.Globalization;
|
||||
|
||||
namespace MauiSpark.Vues;
|
||||
|
||||
public partial class IndicateurVue : ContentView
|
||||
{
|
||||
public static readonly BindableProperty CouleurProperty = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(IndicateurVue), default(Color));
|
||||
|
||||
public Color Couleur
|
||||
{
|
||||
get => (Color)GetValue(CouleurProperty);
|
||||
|
||||
set => SetValue(CouleurProperty, value);
|
||||
}
|
||||
public IndicateurVue()
|
||||
{
|
||||
InitializeComponent();
|
||||
BindingContext = this;
|
||||
}
|
||||
|
||||
private void QuandTailleChangee(object sender, EventArgs e)
|
||||
{
|
||||
double taille = Math.Min(Grid.Width, Grid.Height) / 2;
|
||||
Carre.WidthRequest = Carre.HeightRequest = taille;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="MauiSpark.Vues.ModeVue"
|
||||
x:Name="modeVue">
|
||||
|
||||
<Button
|
||||
Text="{Binding Regles.Nom, Source={x:Reference modeVue}}"
|
||||
Clicked="QuandReglesPresse"
|
||||
Margin="0, 50"/>
|
||||
</ContentView>
|
@ -0,0 +1,32 @@
|
||||
using CoreLibrary;
|
||||
using CoreLibrary.Regles;
|
||||
using MauiSpark.Pages;
|
||||
|
||||
namespace MauiSpark.Vues;
|
||||
|
||||
public partial class ModeVue : ContentView
|
||||
{
|
||||
public static readonly BindableProperty ReglesProperty = BindableProperty.Create(nameof(Regles), typeof(IRegles), typeof(ModeVue), null);
|
||||
|
||||
public IRegles Regles
|
||||
{
|
||||
get => (IRegles)GetValue(ReglesProperty);
|
||||
set => SetValue(ReglesProperty, value);
|
||||
}
|
||||
|
||||
public ModeVue()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void QuandReglesPresse(Object sender, EventArgs e)
|
||||
{
|
||||
Partie partie = MauiProgram.Manageur.NouvellePartie(Regles);
|
||||
|
||||
partie.PartieDemanderJoueur += new ConnexionPage().QuandDemanderNom;
|
||||
partie.PartiePartieTerminee += new VictoirePage().QuandPartieTerminee;
|
||||
partie.PartieNouveauTour += new PlateauPage().QuandNouveauTour;
|
||||
|
||||
partie.Jouer();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue