From bc1ad999bf0185b2f8a6ef0e883f7e4e5fdb2606 Mon Sep 17 00:00:00 2001 From: "jeremy.mouyon" Date: Sat, 1 Jun 2024 23:50:44 +0200 Subject: [PATCH] ITS WORK MATE (just problm with see tiles of players fix monday) --- Qwirkle/QwirkleViews/ConverterColor.cs | 90 +++++++++++ Qwirkle/QwirkleViews/MauiProgram.cs | 5 +- Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs | 23 +-- Qwirkle/QwirkleViews/Pages/Gameboard.xaml | 146 +++++++++++------- Qwirkle/QwirkleViews/Pages/Leaderboard.xaml | 35 ++--- Qwirkle/QwirkleViews/QwirkleViews.csproj | 10 +- Qwirkle/QwirkleViews/Views/TileCircle.xaml | 31 ---- Qwirkle/QwirkleViews/Views/TileClub.xaml | 20 --- Qwirkle/QwirkleViews/Views/TileClub.xaml.cs | 15 -- Qwirkle/QwirkleViews/Views/TileRhombus.xaml | 23 --- .../QwirkleViews/Views/TileRhombus.xaml.cs | 15 -- Qwirkle/QwirkleViews/Views/TileShuriken.xaml | 21 --- .../QwirkleViews/Views/TileShuriken.xaml.cs | 15 -- Qwirkle/QwirkleViews/Views/TileSquare.xaml | 22 --- Qwirkle/QwirkleViews/Views/TileSquare.xaml.cs | 15 -- Qwirkle/QwirkleViews/Views/TileStar.xaml | 20 --- Qwirkle/QwirkleViews/Views/TileStar.xaml.cs | 15 -- Qwirkle/QwirkleViews/Views/TileView.xaml | 89 +++++++++++ .../{TileCircle.xaml.cs => TileView.xaml.cs} | 20 +-- Qwirkle/TestBase/TestBase.csproj | 14 +- 20 files changed, 327 insertions(+), 317 deletions(-) delete mode 100644 Qwirkle/QwirkleViews/Views/TileCircle.xaml delete mode 100644 Qwirkle/QwirkleViews/Views/TileClub.xaml delete mode 100644 Qwirkle/QwirkleViews/Views/TileClub.xaml.cs delete mode 100644 Qwirkle/QwirkleViews/Views/TileRhombus.xaml delete mode 100644 Qwirkle/QwirkleViews/Views/TileRhombus.xaml.cs delete mode 100644 Qwirkle/QwirkleViews/Views/TileShuriken.xaml delete mode 100644 Qwirkle/QwirkleViews/Views/TileShuriken.xaml.cs delete mode 100644 Qwirkle/QwirkleViews/Views/TileSquare.xaml delete mode 100644 Qwirkle/QwirkleViews/Views/TileSquare.xaml.cs delete mode 100644 Qwirkle/QwirkleViews/Views/TileStar.xaml delete mode 100644 Qwirkle/QwirkleViews/Views/TileStar.xaml.cs create mode 100644 Qwirkle/QwirkleViews/Views/TileView.xaml rename Qwirkle/QwirkleViews/Views/{TileCircle.xaml.cs => TileView.xaml.cs} (72%) diff --git a/Qwirkle/QwirkleViews/ConverterColor.cs b/Qwirkle/QwirkleViews/ConverterColor.cs index a48ac66..c47f4d1 100644 --- a/Qwirkle/QwirkleViews/ConverterColor.cs +++ b/Qwirkle/QwirkleViews/ConverterColor.cs @@ -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(); + } + } } diff --git a/Qwirkle/QwirkleViews/MauiProgram.cs b/Qwirkle/QwirkleViews/MauiProgram.cs index 36d59df..54cd7fe 100644 --- a/Qwirkle/QwirkleViews/MauiProgram.cs +++ b/Qwirkle/QwirkleViews/MauiProgram.cs @@ -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() + .UseMauiCommunityToolkit() .ConfigureFonts(fonts => { fonts.AddFont("DiloWorld.ttf", "DiloWorld"); diff --git a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs index 894b907..6a318b5 100644 --- a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs +++ b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs @@ -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"); } } \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml index 8db9c10..8558ee1 100644 --- a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml +++ b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml @@ -1,14 +1,63 @@ - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -26,60 +75,51 @@ DropCommand="{Binding OnDrop, Source={x:Reference root}}" DropCommandParameter="{Binding .}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + diff --git a/Qwirkle/QwirkleViews/Pages/Leaderboard.xaml b/Qwirkle/QwirkleViews/Pages/Leaderboard.xaml index ec7623a..575db19 100644 --- a/Qwirkle/QwirkleViews/Pages/Leaderboard.xaml +++ b/Qwirkle/QwirkleViews/Pages/Leaderboard.xaml @@ -15,63 +15,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - diff --git a/Qwirkle/QwirkleViews/QwirkleViews.csproj b/Qwirkle/QwirkleViews/QwirkleViews.csproj index d77e2e5..54ad304 100644 --- a/Qwirkle/QwirkleViews/QwirkleViews.csproj +++ b/Qwirkle/QwirkleViews/QwirkleViews.csproj @@ -64,9 +64,10 @@ - - - + + + + @@ -98,6 +99,9 @@ ScoreboardLine.xaml + + TileView.xaml + diff --git a/Qwirkle/QwirkleViews/Views/TileCircle.xaml b/Qwirkle/QwirkleViews/Views/TileCircle.xaml deleted file mode 100644 index f90838c..0000000 --- a/Qwirkle/QwirkleViews/Views/TileCircle.xaml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileClub.xaml b/Qwirkle/QwirkleViews/Views/TileClub.xaml deleted file mode 100644 index 19813d5..0000000 --- a/Qwirkle/QwirkleViews/Views/TileClub.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileClub.xaml.cs b/Qwirkle/QwirkleViews/Views/TileClub.xaml.cs deleted file mode 100644 index ca42a77..0000000 --- a/Qwirkle/QwirkleViews/Views/TileClub.xaml.cs +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileRhombus.xaml b/Qwirkle/QwirkleViews/Views/TileRhombus.xaml deleted file mode 100644 index b0f9fd4..0000000 --- a/Qwirkle/QwirkleViews/Views/TileRhombus.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileRhombus.xaml.cs b/Qwirkle/QwirkleViews/Views/TileRhombus.xaml.cs deleted file mode 100644 index c17abac..0000000 --- a/Qwirkle/QwirkleViews/Views/TileRhombus.xaml.cs +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileShuriken.xaml b/Qwirkle/QwirkleViews/Views/TileShuriken.xaml deleted file mode 100644 index 8748cc5..0000000 --- a/Qwirkle/QwirkleViews/Views/TileShuriken.xaml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileShuriken.xaml.cs b/Qwirkle/QwirkleViews/Views/TileShuriken.xaml.cs deleted file mode 100644 index bab5b98..0000000 --- a/Qwirkle/QwirkleViews/Views/TileShuriken.xaml.cs +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileSquare.xaml b/Qwirkle/QwirkleViews/Views/TileSquare.xaml deleted file mode 100644 index f051735..0000000 --- a/Qwirkle/QwirkleViews/Views/TileSquare.xaml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileSquare.xaml.cs b/Qwirkle/QwirkleViews/Views/TileSquare.xaml.cs deleted file mode 100644 index 95e5a00..0000000 --- a/Qwirkle/QwirkleViews/Views/TileSquare.xaml.cs +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileStar.xaml b/Qwirkle/QwirkleViews/Views/TileStar.xaml deleted file mode 100644 index b53d6dc..0000000 --- a/Qwirkle/QwirkleViews/Views/TileStar.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileStar.xaml.cs b/Qwirkle/QwirkleViews/Views/TileStar.xaml.cs deleted file mode 100644 index e23cd05..0000000 --- a/Qwirkle/QwirkleViews/Views/TileStar.xaml.cs +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileView.xaml b/Qwirkle/QwirkleViews/Views/TileView.xaml new file mode 100644 index 0000000..5249a91 --- /dev/null +++ b/Qwirkle/QwirkleViews/Views/TileView.xaml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileCircle.xaml.cs b/Qwirkle/QwirkleViews/Views/TileView.xaml.cs similarity index 72% rename from Qwirkle/QwirkleViews/Views/TileCircle.xaml.cs rename to Qwirkle/QwirkleViews/Views/TileView.xaml.cs index 0d32df2..ffd11cf 100644 --- a/Qwirkle/QwirkleViews/Views/TileCircle.xaml.cs +++ b/Qwirkle/QwirkleViews/Views/TileView.xaml.cs @@ -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; } } \ No newline at end of file diff --git a/Qwirkle/TestBase/TestBase.csproj b/Qwirkle/TestBase/TestBase.csproj index 6443260..3e7e645 100644 --- a/Qwirkle/TestBase/TestBase.csproj +++ b/Qwirkle/TestBase/TestBase.csproj @@ -10,10 +10,16 @@ - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +