diff --git a/Qwirkle/QwirkleClassLibrary/Games/Game.cs b/Qwirkle/QwirkleClassLibrary/Games/Game.cs index a7de103..5ba5c3d 100644 --- a/Qwirkle/QwirkleClassLibrary/Games/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Games/Game.cs @@ -21,7 +21,7 @@ namespace QwirkleClassLibrary.Games public class Game : IPlayer, IRules { [DataMember] - private TileBag? bag = null; + public TileBag? bag = null; [DataMember] public bool GameRunning { get; set; } diff --git a/Qwirkle/QwirkleViews/ConverterColor.cs b/Qwirkle/QwirkleViews/ConverterColor.cs index c47f4d1..1887107 100644 --- a/Qwirkle/QwirkleViews/ConverterColor.cs +++ b/Qwirkle/QwirkleViews/ConverterColor.cs @@ -17,12 +17,12 @@ namespace Qwirkle.Converters if (colorstring == "Red") return Colors.Red; if (colorstring == "Blue") return Colors.Blue; 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 == "Transparent") return Colors.Transparent; - return Colors.Plum; + return Colors.Transparent; } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) @@ -133,9 +133,9 @@ namespace Qwirkle.Converters 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(); } } } diff --git a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs index 6a318b5..b92f2ae 100644 --- a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs +++ b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs @@ -7,6 +7,8 @@ using System.Collections.ObjectModel; using System.Windows.Input; using System.ComponentModel; using Cell = QwirkleClassLibrary.Boards.Cell; +using Color = Microsoft.Maui.Graphics.Color; +using System.Drawing; namespace Qwirkle.Pages; @@ -18,6 +20,12 @@ public partial class Gameboard : ContentPage 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() { InitializeComponent(); @@ -53,9 +61,68 @@ public partial class Gameboard : ContentPage { 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; } - 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) + { + } } \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml index c5588da..10670e3 100644 --- a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml +++ b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml @@ -6,19 +6,21 @@ x:Name="root"> - - + + - - + + - - + + + + + BackgroundColor="{Binding ColorBC1, Source={x:Reference root}}" + Margin="0" + > - + @@ -50,7 +53,7 @@ @@ -70,7 +73,7 @@ @@ -90,7 +93,7 @@ @@ -111,15 +114,15 @@ - - + Margin="0" > + + DropCommandParameter="{Binding .}"/> - + diff --git a/Qwirkle/QwirkleViews/Views/TileView.xaml b/Qwirkle/QwirkleViews/Views/TileView.xaml index 5249a91..c91e19c 100644 --- a/Qwirkle/QwirkleViews/Views/TileView.xaml +++ b/Qwirkle/QwirkleViews/Views/TileView.xaml @@ -17,21 +17,24 @@ - - + + + - + + - + + + IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource squareToVisibilityConverter}}" /> - + + IsVisible="{Binding Shape, Source={x:Reference root}, Converter={StaticResource clubToVisibilityConverter}}"> @@ -85,5 +90,6 @@ + \ No newline at end of file diff --git a/Qwirkle/QwirkleViews/Views/TileView.xaml.cs b/Qwirkle/QwirkleViews/Views/TileView.xaml.cs index ffd11cf..742beac 100644 --- a/Qwirkle/QwirkleViews/Views/TileView.xaml.cs +++ b/Qwirkle/QwirkleViews/Views/TileView.xaml.cs @@ -53,4 +53,11 @@ public partial class TileView : ContentView set => SetValue(ShapeProperty, value); } + public event EventHandler InfoClicked; + + void OnInfoClicked(object sender, EventArgs args) + { + InfoClicked?.Invoke(this, args); + } + } \ No newline at end of file