fin du joueur ia maui
continuous-integration/drone/push Build is failing Details

master
Céleste BARBOSA 11 months ago
parent 77dce5fdf2
commit 7f449c256d

@ -14,6 +14,11 @@ namespace CoreLibrary.Joueurs
{ {
} }
public Robot(string nom) :
base(nom)
{
}
public override void QuandDemanderJoueurJouer(object? sender, PartieDemanderJoueurJouerEventArgs e) public override void QuandDemanderJoueurJouer(object? sender, PartieDemanderJoueurJouerEventArgs e)
{ {
if (e.Nom != Nom) if (e.Nom != Nom)

@ -33,6 +33,7 @@ namespace CoreLibrary
private int courant = 0; private int courant = 0;
public IReadOnlyList<string> Joueurs => joueurs.Keys.ToList(); public IReadOnlyList<string> Joueurs => joueurs.Keys.ToList();
public IReadOnlyList<string> Robots => joueurs.Where(joueur => joueur.Value).Select(joueur => joueur.Key).ToList();
[DataMember] [DataMember]
public bool Termine { get; private set; } = false; public bool Termine { get; private set; } = false;
[DataMember] [DataMember]
@ -60,6 +61,9 @@ namespace CoreLibrary
partie.PartieNouveauTour = null; partie.PartieNouveauTour = null;
partie.PartiePasserLaMain = null; partie.PartiePasserLaMain = null;
partie.PartiePartieTerminee = null; partie.PartiePartieTerminee = null;
foreach (string joueur in Joueurs)
(joueurs[joueur] ? new Joueur(joueur) : new Robot(joueur)).JouerPartie(this);
} }
public void Jouer() public void Jouer()

@ -1,99 +1 @@
[ [ ]
{
"Nom": "A",
"statistiques": [
{
"Key": {
"Item1": {
"__type": "ReglesClassiques:#CoreLibrary.Regles"
},
"Item2": 3
},
"Value": 15
},
{
"Key": {
"Item1": {
"__type": "ReglesClassiques:#CoreLibrary.Regles"
},
"Item2": 0
},
"Value": 2
}
]
},
{
"Nom": "Céleste",
"statistiques": [
{
"Key": {
"Item1": {
"__type": "ReglesClassiques:#CoreLibrary.Regles"
},
"Item2": 3
},
"Value": 8
},
{
"Key": {
"Item1": {
"__type": "ReglesClassiques:#CoreLibrary.Regles"
},
"Item2": 1
},
"Value": 1
}
]
},
{
"Nom": "Pauline",
"statistiques": [
{
"Key": {
"Item1": {
"__type": "ReglesClassiques:#CoreLibrary.Regles"
},
"Item2": 3
},
"Value": 2
}
]
},
{
"Nom": "C",
"statistiques": [
{
"Key": {
"Item1": {
"__type": "ReglesClassiques:#CoreLibrary.Regles"
},
"Item2": 3
},
"Value": 10
},
{
"Key": {
"Item1": {
"__type": "ReglesClassiques:#CoreLibrary.Regles"
},
"Item2": 1
},
"Value": 1
}
]
},
{
"Nom": "Camille",
"statistiques": [
{
"Key": {
"Item1": {
"__type": "ReglesClassiques:#CoreLibrary.Regles"
},
"Item2": 3
},
"Value": 1
}
]
}
]

File diff suppressed because it is too large Load Diff

@ -112,13 +112,13 @@
<BoxView Grid.Row="1" Grid.ColumnSpan="6" HeightRequest="1" VerticalOptions="Center"/> <BoxView Grid.Row="1" Grid.ColumnSpan="6" HeightRequest="1" VerticalOptions="Center"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Rouge}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"/> <vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Rouge}" EstJoueur="{Binding Source={x:Reference plateauPage}, Path=BindingContext.EstJoueur}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Vert}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2"/> <vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Vert}" EstJoueur="{Binding Source={x:Reference plateauPage}, Path=BindingContext.EstJoueur}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Bleu}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="2" Grid.ColumnSpan="2"/> <vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Bleu}" EstJoueur="{Binding Source={x:Reference plateauPage}, Path=BindingContext.EstJoueur}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Jaune}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"/> <vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Jaune}" EstJoueur="{Binding Source={x:Reference plateauPage}, Path=BindingContext.EstJoueur}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Noir}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2"/> <vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Noir}" EstJoueur="{Binding Source={x:Reference plateauPage}, Path=BindingContext.EstJoueur}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Blanc}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2"/> <vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Blanc}" EstJoueur="{Binding Source={x:Reference plateauPage}, Path=BindingContext.EstJoueur}" Code="{Binding Source={x:Reference plateauPage}, Path=BindingContext.Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2"/>
</Grid> </Grid>
</Border> </Border>

@ -10,12 +10,14 @@ internal class Tour
public string Joueur { get; private init; } public string Joueur { get; private init; }
public string Numero { get; private init; } public string Numero { get; private init; }
public Code Code { get; private init; } public Code Code { get; private init; }
public bool EstJoueur { get; private init; }
public Tour(PartieNouveauTourEventArgs e) public Tour(PartieNouveauTourEventArgs e)
{ {
Numero = $"Tour {e.Tour}"; Numero = $"Tour {e.Tour}";
Joueur = e.Nom; Joueur = e.Nom;
Code = e.Code; Code = e.Code;
EstJoueur = e.EstJoueur;
(IReadOnlyList<IReadOnlyList<Jeton>> jetons, IReadOnlyList < IReadOnlyList < Indicateur >> indicateurs) = e.Plateau.Grille; (IReadOnlyList<IReadOnlyList<Jeton>> jetons, IReadOnlyList < IReadOnlyList < Indicateur >> indicateurs) = e.Plateau.Grille;
@ -40,6 +42,7 @@ public partial class PlateauPage : ContentPage
{ {
private Code? code; private Code? code;
private Plateau? plateau; private Plateau? plateau;
private bool? estJoueur;
public PlateauPage() public PlateauPage()
{ {
@ -68,6 +71,7 @@ public partial class PlateauPage : ContentPage
code = e.Code; code = e.Code;
plateau = e.Plateau; plateau = e.Plateau;
estJoueur = e.EstJoueur;
BindingContext = new Tour(e); BindingContext = new Tour(e);
} }
@ -76,7 +80,7 @@ public partial class PlateauPage : ContentPage
{ {
try try
{ {
if(code != null) if(code != null && estJoueur.HasValue && estJoueur.Value)
code.SupprimerDernierJeton(); code.SupprimerDernierJeton();
} }
catch(CodeVideException) catch(CodeVideException)

@ -29,7 +29,7 @@
Margin="20" Margin="20"
Padding="20"> Padding="20">
<Label HorizontalOptions="Center" Text="{Binding Texte}"/> <Label FontSize="Large" HorizontalOptions="Center" Text="{Binding Texte}"/>
</Border> </Border>
<Button <Button

@ -9,6 +9,7 @@ public partial class JetonVue : ContentView
{ {
public static readonly BindableProperty CouleurProperty = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(JetonVue), default(Color)); public static readonly BindableProperty CouleurProperty = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(JetonVue), default(Color));
public static readonly BindableProperty CodeProperty = BindableProperty.Create(nameof(Code), typeof(Code), typeof(JetonVue), null); public static readonly BindableProperty CodeProperty = BindableProperty.Create(nameof(Code), typeof(Code), typeof(JetonVue), null);
public static readonly BindableProperty EstJoueurProperty = BindableProperty.Create(nameof(EstJoueur), typeof(bool), typeof(JetonVue), true);
public Color Couleur public Color Couleur
{ {
@ -22,6 +23,12 @@ public partial class JetonVue : ContentView
set => SetValue(CodeProperty, value); set => SetValue(CodeProperty, value);
} }
public bool EstJoueur
{
get => (bool)GetValue(EstJoueurProperty);
set => SetValue(EstJoueurProperty, value);
}
public JetonVue() public JetonVue()
{ {
InitializeComponent(); InitializeComponent();
@ -36,7 +43,7 @@ public partial class JetonVue : ContentView
private void JetonPresse(object sender, EventArgs e) private void JetonPresse(object sender, EventArgs e)
{ {
if (Cercle == null || !sender.Equals(Cercle) || Code == null || Application.Current == null || Application.Current.MainPage == null) if (Cercle == null || !sender.Equals(Cercle) || Code == null || Application.Current == null || Application.Current.MainPage == null || !EstJoueur)
return; return;
Couleur couleur = (Couleur)new CouleurVersCouleurMAUI().ConvertBack(((SolidColorBrush)Cercle.Fill).Color, typeof(Couleur), null, CultureInfo.InvariantCulture); Couleur couleur = (Couleur)new CouleurVersCouleurMAUI().ConvertBack(((SolidColorBrush)Cercle.Fill).Color, typeof(Couleur), null, CultureInfo.InvariantCulture);

Loading…
Cancel
Save