🚧 Binding des des avec l'evenement OndiceRolled
continuous-integration/drone/push Build is failing Details

pull/99/head
Lucas DUFLOT 11 months ago
parent 4d9b1f2e67
commit 74720d57b0

@ -84,7 +84,7 @@ namespace Models.Game
public Map UsedMap { get; private set; } public Map UsedMap { get; private set; }
public Dice Dice1 { get; private set; } public Dice Dice1 { get; private set;}
public Dice Dice2 { get; private set; } public Dice Dice2 { get; private set; }
public int Turn { get; private set; } public int Turn { get; private set; }
@ -176,14 +176,14 @@ namespace Models.Game
BestScores = new ObservableCollection<BestScore>(); BestScores = new ObservableCollection<BestScore>();
GameRules = new Rules.Rules(); GameRules = new Rules.Rules();
UsedMap = new Map("test");
IsRunning = false; IsRunning = false;
} }
/// <summary> /// <summary>
/// Rolls all the dice. /// Rolls all the dice.
/// </summary> /// </summary>
private void RollAllDice() public void RollAllDice()
{ {
Dice1.Roll(); Dice1.Roll();
Dice2.Roll(); Dice2.Roll();
@ -347,7 +347,7 @@ namespace Models.Game
{ {
if (Turn == 20) if (Turn == 20)
{ {
foreach(var cells in UsedMap.Boards) foreach(var cells in UsedMap.Boards.ToList())
{ {
GameRules.IsZoneValidAndAddToZones(cells, UsedMap); GameRules.IsZoneValidAndAddToZones(cells, UsedMap);
AddToRopePath(cells, GameRules.EveryAdjacentCells(cells, UsedMap.Boards.ToList())); AddToRopePath(cells, GameRules.EveryAdjacentCells(cells, UsedMap.Boards.ToList()));

@ -6,20 +6,40 @@
BackgroundColor="Bisque"> BackgroundColor="Bisque">
<Grid RowDefinitions="*,auto" ColumnDefinitions="auto,*,auto"> <Grid RowDefinitions="*,auto" ColumnDefinitions="auto,*,auto">
<Frame BorderColor="DarkGray" <HorizontalStackLayout>
<Frame BorderColor="DarkGray"
HeightRequest="50" HeightRequest="50"
WidthRequest="50" WidthRequest="50"
Grid.Column="0" Grid.Column="0"
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Center" VerticalOptions="Center"
Padding="0"> Padding="0">
<Label Text="{Binding ThePartie.Dice1.Value}" <Label Text="{Binding ThePartie.Dice1.Value}"
FontSize="16" FontSize="16"
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center" HorizontalOptions="Center"
TextColor="Black" TextColor="Black"
/> x:Name="Dice1"/>
</Frame> </Frame>
<Frame BorderColor="DarkGray"
HeightRequest="50"
WidthRequest="50"
Grid.Column="0"
HorizontalOptions="Center"
VerticalOptions="Center"
Padding="0">
<Label Text="{Binding ThePartie.Dice1.Value}"
FontSize="16"
VerticalOptions="Center"
HorizontalOptions="Center"
TextColor="Black"
x:Name="Dice2"/>
</Frame>
<Button Text="Roll"
HeightRequest="200"
WidthRequest="200"
Clicked="Button_Clicked"/>
</HorizontalStackLayout>
<Image Source="maptest.png" Aspect="AspectFit" Grid.ColumnSpan="2" Grid.RowSpan="3"/> <Image Source="maptest.png" Aspect="AspectFit" Grid.ColumnSpan="2" Grid.RowSpan="3"/>
<CollectionView ItemsSource="{Binding ListMap[0].Boards}" <CollectionView ItemsSource="{Binding ListMap[0].Boards}"

@ -12,14 +12,16 @@ public partial class PageBoard : ContentPage
public PageBoard() public PageBoard()
{ {
InitializeComponent(); InitializeComponent();
MyStub.ThePartie.DiceRolled += ThePartie_DiceRolled;
BindingContext = MyStub; BindingContext = MyStub;
MyStub.ThePartie.InitializeGame(MyStub.ThePartie.UsedMap, MyStub.ListPlayer[0]); MyStub.ThePartie.InitializeGame(MyStub.ThePartie.UsedMap, MyStub.ListPlayer[0]);
MyStub.ThePartie.DiceRolled += ThePartie_DiceRolled;
} }
private void ThePartie_DiceRolled(object? sender, Models.Events.DiceRolledEventArgs e) private void ThePartie_DiceRolled(object? sender, Models.Events.DiceRolledEventArgs e)
{ {
MyStub.ThePartie.Dice1.Roll(); Dice1.Text = $"{e.Dice1Value}";
Dice2.Text = $"{e.Dice2Value}";
} }
private void OnOperationCellSelected(object sender, SelectionChangedEventArgs e) private void OnOperationCellSelected(object sender, SelectionChangedEventArgs e)
@ -36,4 +38,9 @@ public partial class PageBoard : ContentPage
((CollectionView)sender).SelectedItem = null; // Déselectionne l'élément pour la CollectionView ((CollectionView)sender).SelectedItem = null; // Déselectionne l'élément pour la CollectionView
} }
} }
private void Button_Clicked(object sender, EventArgs e)
{
MyStub.ThePartie.RollAllDice();
}
} }
Loading…
Cancel
Save