just swap didnt work
continuous-integration/drone/push Build is passing Details

test_old_branch
Jérémy Mouyon 11 months ago
parent 1cb9aa820d
commit d575f0f998

@ -21,7 +21,7 @@ namespace QwirkleClassLibrary.Games
public class Game : IPlayer, IRules public class Game : IPlayer, IRules
{ {
[DataMember] [DataMember]
private TileBag? bag = null; public TileBag? bag = null;
[DataMember] [DataMember]
public bool GameRunning { get; set; } public bool GameRunning { get; set; }

@ -17,12 +17,12 @@ namespace Qwirkle.Converters
if (colorstring == "Red") return Colors.Red; if (colorstring == "Red") return Colors.Red;
if (colorstring == "Blue") return Colors.Blue; if (colorstring == "Blue") return Colors.Blue;
if (colorstring == "Green") return Colors.Green; if (colorstring == "Green") return Colors.Green;
if (colorstring == "Orange") return Colors.Orange; if (colorstring == "Orange") return Colors.OrangeRed;
if (colorstring == "Purple") return Colors.Purple; if (colorstring == "Purple") return Colors.Purple;
if (colorstring == "Transparent") return Colors.Transparent; if (colorstring == "Transparent") return Colors.Transparent;
return Colors.Plum; return Colors.Transparent;
} }
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
@ -133,9 +133,9 @@ namespace Qwirkle.Converters
return sh == "Star"; return sh == "Star";
} }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{ {
throw new NotSupportedException(); throw new NotImplementedException();
} }
} }
} }

@ -7,6 +7,8 @@ using System.Collections.ObjectModel;
using System.Windows.Input; using System.Windows.Input;
using System.ComponentModel; using System.ComponentModel;
using Cell = QwirkleClassLibrary.Boards.Cell; using Cell = QwirkleClassLibrary.Boards.Cell;
using Color = Microsoft.Maui.Graphics.Color;
using System.Drawing;
namespace Qwirkle.Pages; namespace Qwirkle.Pages;
@ -18,6 +20,12 @@ public partial class Gameboard : ContentPage
private Tile? tiledrag; private Tile? tiledrag;
public Color ColorBC1 { get; set; } = Colors.White;
public Color ColorBC2 { get; set; } = Colors.Transparent;
public Color ColorBC3 { get; set; } = Colors.Transparent;
public Color ColorBC4 { get; set; } = Colors.Transparent;
public Gameboard() public Gameboard()
{ {
InitializeComponent(); InitializeComponent();
@ -53,9 +61,68 @@ public partial class Gameboard : ContentPage
{ {
if(args.Tile != null) if(args.Tile != null)
{ {
DisplayAlert("Tile place notified", args.Tile.ToString() + args.Reason, "<3"); DisplayAlert("Tile place notified", args.Tile.ToString() + " : " + args.Reason, "<3");
return; return;
} }
DisplayAlert("Tile place notified", args.Tile.ToString() + args.Reason, "<3"); DisplayAlert("Tile place notified", args.Reason, "<3");
}
private void OnButtonSkipClicked(object sender, EventArgs e)
{
game.NextPlayerNotified += Game_NextPlayerNotified;
game.GetPlayerScore(game.GetPlayingPlayer(), game.CellsUsed, game.GetBoard()!);
game.EmptyCellUsed();
game.DrawTiles(game.GetPlayingPlayer());
game.CheckGameOver(game.GetPlayingPlayer());
game.SetNextPlayer();
game.NextPlayerNotified -= Game_NextPlayerNotified;
ChangeColorBC();
}
private void ChangeColorBC()
{
if (game.GetPlayingPlayerPosition() == 0)
{
ColorBC1 = Colors.White;
ColorBC4 = Colors.Transparent;
OnPropertyChanged(nameof(ColorBC1));
OnPropertyChanged(nameof(ColorBC4));
}
if (game.GetPlayingPlayerPosition() == 1)
{
ColorBC2 = Colors.White;
ColorBC1 = Colors.Transparent;
OnPropertyChanged(nameof(ColorBC1));
OnPropertyChanged(nameof(ColorBC2));
}
if (game.GetPlayingPlayerPosition() == 2)
{
ColorBC3 = Colors.White;
ColorBC2 = Colors.Transparent;
OnPropertyChanged(nameof(ColorBC3));
OnPropertyChanged(nameof(ColorBC2));
}
if (game.GetPlayingPlayerPosition() == 3)
{
ColorBC4 = Colors.White;
ColorBC3 = Colors.Transparent;
OnPropertyChanged(nameof(ColorBC4));
OnPropertyChanged(nameof(ColorBC3));
}
}
private void Game_NextPlayerNotified(object? sender, NextPlayerNotifiedEventArgs args)
{
DisplayAlert("Player switch !", "It's your turn : " + args.Player.NameTag, "<3");
}
private void OnTileClickedP1(object? sender, EventArgs args)
{
} }
} }

@ -6,19 +6,21 @@
x:Name="root"> x:Name="root">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="150" /> <RowDefinition Height="4*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="10*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button HorizontalOptions="End" Grid.Row="0" Grid.Column="1" Text="Settings" WidthRequest="200" HeightRequest="10" FontSize="20" Margin="20"></Button> <Label Text="{Binding bag.TilesBag.Count}"></Label>
<Button HorizontalOptions="Start" Grid.Row="0" Grid.Column="1" Text="Skip turn" WidthRequest="200" HeightRequest="10" FontSize="20" Margin="20"></Button>
<Button HorizontalOptions="End" Grid.Row="2" Grid.Column="1" Text="Skip / End Turn" WidthRequest="200" HeightRequest="10" FontSize="20" Margin="20" Clicked="OnButtonSkipClicked"></Button>
<Button HorizontalOptions="Start" Grid.Row="2" Grid.Column="1" Text="Settings" WidthRequest="200" HeightRequest="10" FontSize="20" Margin="20" ></Button>
<CollectionView Grid.Row="0" Grid.Column="1" ItemsSource="{Binding PlayerList[0].Tiles}" <CollectionView Grid.Row="0" Grid.Column="1" ItemsSource="{Binding PlayerList[0].Tiles}"
HorizontalOptions="Center" HorizontalOptions="Center"
@ -30,12 +32,13 @@
<DataTemplate> <DataTemplate>
<Border WidthRequest="70" HeightRequest="70" <Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke" BackgroundColor="{Binding ColorBC1, Source={x:Reference root}}"
Margin="0"> Margin="0"
>
<Border.GestureRecognizers> <Border.GestureRecognizers>
<DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/> <DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/>
</Border.GestureRecognizers> </Border.GestureRecognizers>
<controls:TileView Shape="{Binding GetShape}" Color="{Binding GetColor}"></controls:TileView> <controls:TileView Shape="{Binding GetShape}" Color="{Binding GetColor}" InfoClicked="OnTileClickedP1"></controls:TileView>
</Border> </Border>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
@ -50,7 +53,7 @@
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Border WidthRequest="70" HeightRequest="70" <Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke" BackgroundColor="{Binding ColorBC3, Source={x:Reference root}}"
Margin="0"> Margin="0">
<Border.GestureRecognizers> <Border.GestureRecognizers>
<DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/> <DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/>
@ -70,7 +73,7 @@
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Border WidthRequest="70" HeightRequest="70" <Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke" BackgroundColor="{Binding ColorBC4, Source={x:Reference root}}"
Margin="0"> Margin="0">
<Border.GestureRecognizers> <Border.GestureRecognizers>
<DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/> <DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/>
@ -90,7 +93,7 @@
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Border WidthRequest="70" HeightRequest="70" <Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke" BackgroundColor="{Binding ColorBC2, Source={x:Reference root}}"
Margin="0"> Margin="0">
<Border.GestureRecognizers> <Border.GestureRecognizers>
<DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/> <DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/>
@ -111,15 +114,15 @@
</CollectionView.ItemsLayout> </CollectionView.ItemsLayout>
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Border WidthRequest="70" HeightRequest="70" <Border WidthRequest="80" HeightRequest="80"
BackgroundColor="WhiteSmoke" BackgroundColor="WhiteSmoke"
Margin="0"> Margin="0" >
<Border.GestureRecognizers> <Border.GestureRecognizers >
<DropGestureRecognizer DragOver="OnDragOver" <DropGestureRecognizer DragOver="OnDragOver"
DropCommand="{Binding OnDrop, Source={x:Reference root}}" DropCommand="{Binding OnDrop, Source={x:Reference root}}"
DropCommandParameter="{Binding .}" /> DropCommandParameter="{Binding .}"/>
</Border.GestureRecognizers> </Border.GestureRecognizers>
<controls:TileView Shape="{Binding Tile.GetShape}" Color="{Binding Tile.GetColor}"></controls:TileView> <controls:TileView HorizontalOptions="Start" Shape="{Binding Tile.GetShape}" Color="{Binding Tile.GetColor}"></controls:TileView>
</Border> </Border>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>

@ -17,21 +17,24 @@
</ContentView.Resources> </ContentView.Resources>
<Grid> <Grid>
<Rectangle HeightRequest="70" <Rectangle HeightRequest="70"
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
WidthRequest="70" WidthRequest="70"
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center" HorizontalOptions="Center"
BackgroundColor="Transparent"/> BackgroundColor="Transparent"/>
<!--Rond / round-->
<Ellipse HeightRequest="50" <Ellipse HeightRequest="50"
WidthRequest="50" WidthRequest="50"
Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}" Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center" HorizontalOptions="Center"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource roundToVisibilityConverter}}" /> IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource roundToVisibilityConverter}}" />
<!--Losange / Rhombus-->
<Rectangle HeightRequest="35" <Rectangle HeightRequest="35"
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
@ -41,7 +44,8 @@
HorizontalOptions="Center" HorizontalOptions="Center"
Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}" Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource rhombusToVisibilityConverter}}" /> IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource rhombusToVisibilityConverter}}" />
<!--Carre / Square-->
<Rectangle HeightRequest="40" <Rectangle HeightRequest="40"
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
@ -49,14 +53,15 @@
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center" HorizontalOptions="Center"
Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}" Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource clubToVisibilityConverter}}" /> IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource squareToVisibilityConverter}}" />
<Image Source="club.png" <!--Trefle / Club-->
<Image Source="club.png"
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
WidthRequest="100" WidthRequest="100"
HeightRequest="100" HeightRequest="100"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource squareToVisibilityConverter}}"> IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource clubToVisibilityConverter}}">
<Image.Behaviors> <Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"/> <toolkit:IconTintColorBehavior TintColor="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"/>
</Image.Behaviors> </Image.Behaviors>
@ -85,5 +90,6 @@
</Image> </Image>
</Grid> </Grid>
</ContentView> </ContentView>

@ -53,4 +53,11 @@ public partial class TileView : ContentView
set => SetValue(ShapeProperty, value); set => SetValue(ShapeProperty, value);
} }
public event EventHandler InfoClicked;
void OnInfoClicked(object sender, EventArgs args)
{
InfoClicked?.Invoke(this, args);
}
} }
Loading…
Cancel
Save