commit
6cfb2056e9
@ -1,9 +1,48 @@
|
|||||||
|
|
||||||
|
using CoreLibrary.Joueurs;
|
||||||
|
using MauiSpark.Views;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
namespace MauiSpark.Pages;
|
namespace MauiSpark.Pages;
|
||||||
|
|
||||||
public partial class TableauScore : ContentPage
|
public partial class TableauScore : ContentPage
|
||||||
{
|
{
|
||||||
public TableauScore()
|
public TableauScore()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
SetDefaultClassement();
|
||||||
|
}
|
||||||
|
private void SetDefaultClassement()
|
||||||
|
{
|
||||||
|
CTableauScore.UpdateClassement(CTableauScore.GetClassementNbCoupParPartie);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuandNbCoutMoyenButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CTableauScore.UpdateClassement(CTableauScore.GetClassementNbCoupParPartie);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuandGagneeButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CTableauScore.UpdateClassement(CTableauScore.GetClassementPartieGagnee);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuandPerduButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CTableauScore.UpdateClassement(CTableauScore.GetClassementPartiePerdue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuandEgaliteButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CTableauScore.UpdateClassement(CTableauScore.GetClassementPartieEgalite);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuandAlphabetHautButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CTableauScore.UpdateClassement(CTableauScore.GetClassementAlphabetHaut);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuandAlphabetBasButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CTableauScore.UpdateClassement(CTableauScore.GetClassementAlphabetBas);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,14 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="MauiSpark.Views.CTableauScore">
|
x:Class="MauiSpark.Views.CTableauScore">
|
||||||
|
<Frame CornerRadius="5" Padding="0" VerticalOptions="Start" Margin="20,0,20,10" >
|
||||||
<Frame CornerRadius="5" Padding="0" VerticalOptions="Start" Margin="20,0,20,10" >
|
<ListView ItemsSource="{Binding}">
|
||||||
<Grid ColumnDefinitions="auto,*,auto,auto" ColumnSpacing="10">
|
<ListView.ItemTemplate>
|
||||||
<Label Grid.Column="0" Text="N°1" Margin="20" Style="{StaticResource TexteFrame}" />
|
<DataTemplate>
|
||||||
<Label Grid.Column="1" Text="Joueur 1" Margin="20" Style="{StaticResource TexteFrame}" />
|
<ViewCell>
|
||||||
<Label Grid.Column="2" Text="5" Margin="20" Style="{StaticResource TexteFrame}" />
|
<Grid ColumnDefinitions="auto,*,auto,auto,auto,auto">
|
||||||
<Label Grid.Column="3" Text="10000" Margin="20" Style="{StaticResource TexteFrame}"/>
|
<Label Grid.Column="0" Text="{Binding Place}" Margin="20,20,20,20" Style="{StaticResource TexteFrame}" />
|
||||||
</Grid>
|
<Label Grid.Column="1" Text="{Binding Joueur.Nom}" Margin="20,20,20,20" Style="{StaticResource TexteFrame}" />
|
||||||
</Frame>
|
<Label Grid.Column="2" Text="{Binding NbCoutMoyen}" Margin="20,20,100,20" Style="{StaticResource TexteFrame}" />
|
||||||
</ContentView>
|
<Label Grid.Column="3" Text="{Binding Joueur.NbPartieGagnee}" Margin="75,20,100,20" Style="{StaticResource TexteFrame}" />
|
||||||
|
<Label Grid.Column="4" Text="{Binding Joueur.NbPartiePerdue}" Margin="75,20,100,20" Style="{StaticResource TexteFrame}" />
|
||||||
|
<Label Grid.Column="5" Text="{Binding Joueur.NbPartieEgalite}" Margin="75,20,100,20" Style="{StaticResource TexteFrame}" />
|
||||||
|
</Grid>
|
||||||
|
</ViewCell>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</Frame>
|
||||||
|
</ContentView>
|
@ -1,9 +1,191 @@
|
|||||||
|
using CoreLibrary.Events;
|
||||||
|
using CoreLibrary.Joueurs;
|
||||||
|
using CoreLibrary.Manager;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace MauiSpark.Views;
|
namespace MauiSpark.Views;
|
||||||
|
|
||||||
public partial class CTableauScore : ContentView
|
public class JoueurClassementNbCoupParPartie
|
||||||
{
|
{
|
||||||
public CTableauScore()
|
private Manager manager;
|
||||||
|
private Joueur joueur;
|
||||||
|
|
||||||
|
public Joueur Joueur
|
||||||
|
{
|
||||||
|
get => joueur;
|
||||||
|
private set => joueur = value;
|
||||||
|
}
|
||||||
|
public int Place
|
||||||
|
{
|
||||||
|
get => manager.Joueurs
|
||||||
|
.OrderBy(joueur => joueur.NbCoutTotal/(joueur.NbPartiePerdue+joueur.NbPartieGagnee+joueur.NbPartieEgalite)).ToList()
|
||||||
|
.IndexOf(Joueur) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
|
||||||
|
|
||||||
|
public JoueurClassementNbCoupParPartie(Joueur joueur, Manager manager)
|
||||||
|
{
|
||||||
|
this.manager = manager;
|
||||||
|
this.joueur = joueur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JoueurClassementPartieGagnee
|
||||||
|
{
|
||||||
|
private Manager manager;
|
||||||
|
private Joueur joueur;
|
||||||
|
|
||||||
|
public Joueur Joueur
|
||||||
|
{
|
||||||
|
get => joueur;
|
||||||
|
private set => joueur = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Place
|
||||||
|
{
|
||||||
|
get => manager.Joueurs.OrderByDescending(joueur => joueur.NbPartieGagnee).ToList().IndexOf(Joueur) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
|
||||||
|
|
||||||
|
public JoueurClassementPartieGagnee(Joueur joueur, Manager manager)
|
||||||
|
{
|
||||||
|
this.manager = manager;
|
||||||
|
this.joueur = joueur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JoueurClassementPartieEgalite
|
||||||
|
{
|
||||||
|
private Manager manager;
|
||||||
|
private Joueur joueur;
|
||||||
|
|
||||||
|
public Joueur Joueur
|
||||||
|
{
|
||||||
|
get => joueur;
|
||||||
|
private set => joueur = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Place
|
||||||
|
{
|
||||||
|
get => manager.Joueurs.OrderByDescending(joueur => joueur.NbPartieEgalite).ToList().IndexOf(joueur)+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
|
||||||
|
|
||||||
|
public JoueurClassementPartieEgalite(Joueur joueur, Manager manager)
|
||||||
|
{
|
||||||
|
this.manager = manager;
|
||||||
|
this.joueur = joueur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JoueurClassementPartiePerdue
|
||||||
|
{
|
||||||
|
private Manager manager;
|
||||||
|
private Joueur joueur;
|
||||||
|
|
||||||
|
public Joueur Joueur
|
||||||
|
{
|
||||||
|
get => joueur;
|
||||||
|
private set => joueur = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Place
|
||||||
|
{
|
||||||
|
get => manager.Joueurs.OrderByDescending(joueur => joueur.NbPartiePerdue).ToList().IndexOf(joueur)+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
|
||||||
|
|
||||||
|
public JoueurClassementPartiePerdue(Joueur joueur, Manager manager)
|
||||||
|
{
|
||||||
|
this.manager = manager;
|
||||||
|
this.joueur = joueur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JoueurClassementAlphabet
|
||||||
|
{
|
||||||
|
private Manager manager;
|
||||||
|
private Joueur joueur;
|
||||||
|
|
||||||
|
public Joueur Joueur
|
||||||
|
{
|
||||||
|
get => joueur;
|
||||||
|
private set => joueur = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Place
|
||||||
|
{
|
||||||
|
get => manager.Joueurs
|
||||||
|
.OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite)).ToList()
|
||||||
|
.IndexOf(Joueur) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
|
||||||
|
|
||||||
|
public JoueurClassementAlphabet(Joueur joueur, Manager manager)
|
||||||
|
{
|
||||||
|
this.manager = manager;
|
||||||
|
this.joueur = joueur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class CTableauScore : ContentView
|
||||||
|
{
|
||||||
|
public IEnumerable<JoueurClassementNbCoupParPartie> GetClassementNbCoupParPartie()
|
||||||
|
{
|
||||||
|
return MauiProgram.Manager.Joueurs
|
||||||
|
.OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite))
|
||||||
|
.Select(joueur => new JoueurClassementNbCoupParPartie(joueur, MauiProgram.Manager));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<JoueurClassementPartieGagnee> GetClassementPartieGagnee()
|
||||||
|
{
|
||||||
|
return MauiProgram.Manager.Joueurs
|
||||||
|
.OrderByDescending(joueur => joueur.NbPartieGagnee)
|
||||||
|
.Select(joueur => new JoueurClassementPartieGagnee(joueur, MauiProgram.Manager));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<JoueurClassementPartieEgalite> GetClassementPartieEgalite()
|
||||||
|
{
|
||||||
|
return MauiProgram.Manager.Joueurs
|
||||||
|
.OrderByDescending(joueur => joueur.NbPartieEgalite)
|
||||||
|
.Select(joueur => new JoueurClassementPartieEgalite(joueur, MauiProgram.Manager));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<JoueurClassementPartiePerdue> GetClassementPartiePerdue()
|
||||||
|
{
|
||||||
|
return MauiProgram.Manager.Joueurs
|
||||||
|
.OrderByDescending(joueur => joueur.NbPartiePerdue)
|
||||||
|
.Select(joueur => new JoueurClassementPartiePerdue(joueur, MauiProgram.Manager));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<JoueurClassementAlphabet> GetClassementAlphabetHaut()
|
||||||
|
{
|
||||||
|
return MauiProgram.Manager.Joueurs
|
||||||
|
.OrderBy(joueur => joueur.Nom)
|
||||||
|
.Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manager));
|
||||||
|
}
|
||||||
|
public IEnumerable<JoueurClassementAlphabet> GetClassementAlphabetBas()
|
||||||
|
{
|
||||||
|
return MauiProgram.Manager.Joueurs
|
||||||
|
.OrderByDescending(joueur => joueur.Nom)
|
||||||
|
.Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manager));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CTableauScore()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateClassement(Func<IEnumerable<object>> getClassement)
|
||||||
|
{
|
||||||
|
BindingContext = getClassement();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue