ITS WORK MATE (just problm with see tiles of players fix monday)
continuous-integration/drone/push Build is failing Details

test_old_branch
Jérémy Mouyon 11 months ago
parent 471679c332
commit bc1ad999bf

@ -48,4 +48,94 @@ namespace Qwirkle.Converters
throw new NotSupportedException();
}
}
public class RhombusToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
return sh == "Rhombus";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
public class SquareToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
return sh == "Square";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
public class ClubToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
return sh == "Club";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
public class ShurikenToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
return sh == "Shuriken";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
public class StarToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
return sh == "Star";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using CommunityToolkit.Maui;
using Microsoft.Extensions.Logging;
namespace Qwirkle
{
@ -6,10 +7,10 @@ namespace Qwirkle
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("DiloWorld.ttf", "DiloWorld");

@ -24,19 +24,19 @@ public partial class Gameboard : ContentPage
BindingContext = game;
}
private void OnDragOver(object sender, DragEventArgs e)
private void OnDragStarting(object sender, DragStartingEventArgs e)
{
foreach (var t in game.PlayerList[game.GetPlayingPlayerPosition()].Tiles)
{
if (e.Data.Text == t.ToString())
{
tiledrag = t;
break;
}
}
var tile = (sender as Element).BindingContext as Tile;
e.Data.Text = tile?.ToString();
tiledrag = tile;
}
private void OnDragOver(object sender, DragEventArgs e)
{
e.AcceptedOperation = DataPackageOperation.Copy;
}
private void OnDropTile(Cell cell)
{
game.PlaceTileNotified += Game_PlaceTileNotified;
@ -51,6 +51,11 @@ public partial class Gameboard : ContentPage
private void Game_PlaceTileNotified(object? sender, PlaceTileNotifiedEventArgs args)
{
if(args.Tile != null)
{
DisplayAlert("Tile place notified", args.Tile.ToString() + args.Reason, "<3");
return;
}
DisplayAlert("Tile place notified", args.Tile.ToString() + args.Reason, "<3");
}
}

@ -1,14 +1,63 @@
<?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"
x:Class="Qwirkle.Pages.Gameboard"
xmlns:controls="clr-namespace:Qwirkle.Views"
Title="Gameboard"
x:Name="root">
<ScrollView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackLayout>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CollectionView Grid.Row="0" ItemsSource="{Binding PlayerList[0].Tiles}"
HorizontalOptions="Center"
VerticalOptions="Start" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Horizontal"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke"
Margin="0">
<Border.GestureRecognizers>
<DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/>
</Border.GestureRecognizers>
<controls:TileView Shape="{Binding GetShape}" Color="{Binding GetColor}"></controls:TileView>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView Grid.Row="1" Grid.Column="0" ItemsSource="{Binding PlayerList[1].Tiles}"
HorizontalOptions="Center"
VerticalOptions="Start" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke"
Margin="0">
<Border.GestureRecognizers>
<DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/>
</Border.GestureRecognizers>
<controls:TileView Shape="{Binding GetShape}" Color="{Binding GetColor}"></controls:TileView>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<ScrollView Grid.Row="1">
<CollectionView ItemsSource="{Binding Board.ReadCells}"
HorizontalOptions="Center"
VerticalOptions="Center">
@ -26,60 +75,51 @@
DropCommand="{Binding OnDrop, Source={x:Reference root}}"
DropCommandParameter="{Binding .}" />
</Border.GestureRecognizers>
<controls:TileCircle Shape="{Binding Tile.GetShape}" Color="{Binding Tile.GetColor}"></controls:TileCircle>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView ItemsSource="{Binding PlayerList[0].Tiles}"
HorizontalOptions="Center"
VerticalOptions="Start" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Horizontal"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke"
Margin="0">
<Label Text="{Binding}">
<Label.GestureRecognizers>
<DragGestureRecognizer />
</Label.GestureRecognizers>
</Label>
<controls:TileView Shape="{Binding Tile.GetShape}" Color="{Binding Tile.GetColor}"></controls:TileView>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView>
<CollectionView ItemsSource="{Binding PlayerList[1].Tiles}"
HorizontalOptions="End"
VerticalOptions="End" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke"
Margin="0">
<Label Text="{Binding}">
<Label.GestureRecognizers>
<DragGestureRecognizer />
</Label.GestureRecognizers>
</Label>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
<CollectionView Grid.Row="1" Grid.Column="2" ItemsSource="{Binding PlayerList[2].Tiles}"
HorizontalOptions="Center"
VerticalOptions="Start" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke"
Margin="0">
<Border.GestureRecognizers>
<DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/>
</Border.GestureRecognizers>
<controls:TileView Shape="{Binding GetShape}" Color="{Binding GetColor}"></controls:TileView>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView>
<CollectionView Grid.Row="2" Grid.ColumnSpan="3" ItemsSource="{Binding PlayerList[1].Tiles}"
HorizontalOptions="Center"
VerticalOptions="End" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Horizontal"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke"
Margin="0">
<Border.GestureRecognizers>
<DragGestureRecognizer CanDrag="True" DragStarting="OnDragStarting"/>
</Border.GestureRecognizers>
<controls:TileView Shape="{Binding GetShape}" Color="{Binding GetColor}"></controls:TileView>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</ContentPage>

@ -15,7 +15,7 @@
<Border Style="{StaticResource TabBorder}">
<Border.Shadow>
<Border.Shadow>
<Shadow/>
</Border.Shadow>
<Border.StrokeShape>
@ -69,9 +69,6 @@
</VerticalStackLayout>
</Border>
<controls:TileShuriken></controls:TileShuriken>
</VerticalStackLayout>

@ -64,9 +64,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0-preview.4.24266.19" />
</ItemGroup>
<ItemGroup>
@ -98,6 +99,9 @@
<Compile Update="Views\ScoreboardLine.xaml.cs">
<DependentUpon>ScoreboardLine.xaml</DependentUpon>
</Compile>
<Compile Update="Views\TileView.xaml.cs">
<DependentUpon>TileView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>

@ -1,31 +0,0 @@
<?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="Qwirkle.Views.TileCircle"
xmlns:conv="clr-namespace:Qwirkle.Converters"
x:Name="root">
<ContentView.Resources>
<conv:Int2ColorConverter x:Key="int2ColorConverter"/>
<conv:RoundToVisibilityConverter x:Key="roundToVisibilityConverter"/>
</ContentView.Resources>
<Grid>
<Label Text="{Binding Shape, Source={x:Reference root}}"></Label>
<Rectangle HeightRequest="70"
Grid.Row="0"
Grid.Column="0"
WidthRequest="70"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="Transparent"/>
<Ellipse HeightRequest="50"
WidthRequest="50"
Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"
VerticalOptions="Center"
HorizontalOptions="Center"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource roundToVisibilityConverter}}" />
</Grid>
</ContentView>

@ -1,20 +0,0 @@
<?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="Qwirkle.Views.TileClub">
<Grid>
<Rectangle HeightRequest="600"
Grid.Row="0"
Grid.Column="0"
WidthRequest="600"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="{StaticResource Gray800}" />
<Image Source="club.png"
Grid.Row="0"
Grid.Column="0"
WidthRequest="600"
HeightRequest="600" />
</Grid>
</ContentView>

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Qwirkle.Views;
public partial class TileClub : ContentView
{
public TileClub()
{
InitializeComponent();
}
}

@ -1,23 +0,0 @@
<?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="Qwirkle.Views.TileRhombus">
<Grid>
<Rectangle HeightRequest="600"
Grid.Row="0"
Grid.Column="0"
WidthRequest="600"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="{StaticResource Gray800}"/>
<Rectangle HeightRequest="400"
Grid.Row="0"
Grid.Column="0"
Rotation="45"
WidthRequest="400"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="Red"/>
</Grid>
</ContentView>

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Qwirkle.Views;
public partial class TileRhombus : ContentView
{
public TileRhombus()
{
InitializeComponent();
}
}

@ -1,21 +0,0 @@
<?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="Qwirkle.Views.TileShuriken">
<Grid>
<Rectangle HeightRequest="600"
Grid.Row="0"
Grid.Column="0"
WidthRequest="600"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="{StaticResource Gray800}" />
<Image Source="shuriken.png"
Grid.Row="0"
Grid.Column="0"
WidthRequest="600"
HeightRequest="600"
BackgroundColor="AntiqueWhite"/>
</Grid>
</ContentView>

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Qwirkle.Views;
public partial class TileShuriken : ContentView
{
public TileShuriken()
{
InitializeComponent();
}
}

@ -1,22 +0,0 @@
<?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="Qwirkle.Views.TileSquare">
<Grid>
<Rectangle HeightRequest="600"
Grid.Row="0"
Grid.Column="0"
WidthRequest="600"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="{StaticResource Gray800}"/>
<Rectangle HeightRequest="400"
Grid.Row="0"
Grid.Column="0"
WidthRequest="400"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="Red"/>
</Grid>
</ContentView>

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Qwirkle.Views;
public partial class TileSquare : ContentView
{
public TileSquare()
{
InitializeComponent();
}
}

@ -1,20 +0,0 @@
<?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="Qwirkle.Views.TileStar">
<Grid>
<Rectangle HeightRequest="600"
Grid.Row="0"
Grid.Column="0"
WidthRequest="600"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="{StaticResource Gray800}" />
<Image Source="star.png"
Grid.Row="0"
Grid.Column="0"
WidthRequest="600"
HeightRequest="600"/>
</Grid>
</ContentView>

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Qwirkle.Views;
public partial class TileStar : ContentView
{
public TileStar()
{
InitializeComponent();
}
}

@ -0,0 +1,89 @@
<?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="Qwirkle.Views.TileView"
xmlns:conv="clr-namespace:Qwirkle.Converters"
x:Name="root"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
<ContentView.Resources>
<conv:Int2ColorConverter x:Key="int2ColorConverter"/>
<conv:RhombusToVisibilityConverter x:Key="rhombusToVisibilityConverter"/>
<conv:RoundToVisibilityConverter x:Key="roundToVisibilityConverter"/>
<conv:SquareToVisibilityConverter x:Key="squareToVisibilityConverter"/>
<conv:ClubToVisibilityConverter x:Key="clubToVisibilityConverter"/>
<conv:ShurikenToVisibilityConverter x:Key="shurikenToVisibilityConverter"/>
<conv:StarToVisibilityConverter x:Key="starToVisibilityConverter"/>
</ContentView.Resources>
<Grid>
<Rectangle HeightRequest="70"
Grid.Row="0"
Grid.Column="0"
WidthRequest="70"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="Transparent"/>
<Ellipse HeightRequest="50"
WidthRequest="50"
Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"
VerticalOptions="Center"
HorizontalOptions="Center"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource roundToVisibilityConverter}}" />
<Rectangle HeightRequest="35"
Grid.Row="0"
Grid.Column="0"
Rotation="45"
WidthRequest="35"
VerticalOptions="Center"
HorizontalOptions="Center"
Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource rhombusToVisibilityConverter}}" />
<Rectangle HeightRequest="40"
Grid.Row="0"
Grid.Column="0"
WidthRequest="40"
VerticalOptions="Center"
HorizontalOptions="Center"
Fill="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource clubToVisibilityConverter}}" />
<Image Source="club.png"
Grid.Row="0"
Grid.Column="0"
WidthRequest="100"
HeightRequest="100"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource squareToVisibilityConverter}}">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"/>
</Image.Behaviors>
</Image>
<Image Source="shuriken.png"
Grid.Row="0"
Grid.Column="0"
WidthRequest="60"
HeightRequest="60"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource shurikenToVisibilityConverter}}">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"/>
</Image.Behaviors>
</Image>
<Image Source="star.png"
Grid.Row="0"
Grid.Column="0"
WidthRequest="60"
HeightRequest="60"
IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource starToVisibilityConverter}}">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{Binding Color, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"/>
</Image.Behaviors>
</Image>
</Grid>
</ContentView>

@ -13,32 +13,23 @@ using System.Globalization;
namespace Qwirkle.Views;
public partial class TileCircle : ContentView
public partial class TileView : ContentView
{
public TileCircle()
public TileView()
{
InitializeComponent();
((App)Application.Current!).Game.Board.PropertyChanged += Board_PropertyChanged;
ColorPush = "Transparent";
}
private void Board_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Console.WriteLine(Shape);
if (Shape == "Round")
{
ColorPush = Color;
}
else
{
ColorPush = "Transparent";
}
}
public static readonly BindableProperty ColorProperty =
BindableProperty.Create(nameof(Color), typeof(string), typeof(TileCircle), "", propertyChanged: OnColorChanged);
BindableProperty.Create(nameof(Color), typeof(string), typeof(TileView), "", propertyChanged: OnColorChanged);
public string Color
{
@ -48,13 +39,13 @@ public partial class TileCircle : ContentView
private static void OnColorChanged(BindableObject bindable, object oldValue, object newValue)
{
var bin = (TileCircle)bindable;
var bin = (TileView)bindable;
bin.OnPropertyChanged(nameof(Color));
}
public static readonly BindableProperty ShapeProperty =
BindableProperty.Create("Shape", typeof(string), typeof(TileCircle), "");
BindableProperty.Create("Shape", typeof(string), typeof(TileView), "");
public string Shape
{
@ -62,5 +53,4 @@ public partial class TileCircle : ContentView
set => SetValue(ShapeProperty, value);
}
public string? ColorPush { get; set; }
}

@ -10,10 +10,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save