diff --git a/Qwirkle/QwirkleClassLibrary/Games/Game.cs b/Qwirkle/QwirkleClassLibrary/Games/Game.cs
index b3f9751..194c1bb 100644
--- a/Qwirkle/QwirkleClassLibrary/Games/Game.cs
+++ b/Qwirkle/QwirkleClassLibrary/Games/Game.cs
@@ -22,7 +22,7 @@ namespace QwirkleClassLibrary.Games
public bool GameRunning { get; set; }
[DataMember]
- private Board board = new(15, 12);
+ private Board board = new(17, 14);
public bool PlayerSwapping { get; set; }
public Board Board => board;
@@ -184,7 +184,7 @@ namespace QwirkleClassLibrary.Games
/// Board
public Board CreateBoard()
{
- board = new Board(15, 12);
+ board = new Board(17, 14);
return board;
}
@@ -292,16 +292,31 @@ namespace QwirkleClassLibrary.Games
///
/// string
///
- public string SetFirstPlayer()
+ public string SetFirstPlayer(ReadOnlyCollection playingPlayers)
{
- if (GameRunning)
+ if (!GameRunning) throw new ArgumentException("Game is not running");
+
+ Player? startingPlayer = null;
+ int maxGroupSize = 0;
+
+ foreach (var player in players)
{
- players[0].IsPlaying = true;
- OnNextPlayer(new NextPlayerNotifiedEventArgs(players[0]));
- return players[0].NameTag;
+ var colorGroups = player.Tiles.GroupBy(t => t.GetColor).Select(g => g.Count());
+ var shapeGroups = player.Tiles.GroupBy(t => t.GetShape).Select(g => g.Count());
+
+ int playerMaxGroupSize = Math.Max(colorGroups.Max(), shapeGroups.Max());
+
+ if (playerMaxGroupSize > maxGroupSize)
+ {
+ maxGroupSize = playerMaxGroupSize;
+ startingPlayer = player;
+ }
}
+
+ startingPlayer!.IsPlaying = true;
+ OnNextPlayer(new NextPlayerNotifiedEventArgs(players[0]));
+ return startingPlayer.NameTag;
- throw new ArgumentException("Game is not running");
}
///
@@ -314,7 +329,7 @@ namespace QwirkleClassLibrary.Games
if (i == -1)
{
- return SetFirstPlayer();
+ return SetFirstPlayer(PlayerList);
}
players[i].IsPlaying = false;
diff --git a/Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs b/Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs
index f534458..c6642b3 100644
--- a/Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs
+++ b/Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs
@@ -11,7 +11,7 @@ public interface IPlayer
public string SetNextPlayer();
- public string SetFirstPlayer();
+ public string SetFirstPlayer(ReadOnlyCollection playingPlayers);
public bool PlaceTile(Player player, Tile tile, int x, int y);
diff --git a/Qwirkle/QwirkleViews/App.xaml.cs b/Qwirkle/QwirkleViews/App.xaml.cs
index f5ce5e1..97133c1 100644
--- a/Qwirkle/QwirkleViews/App.xaml.cs
+++ b/Qwirkle/QwirkleViews/App.xaml.cs
@@ -15,6 +15,8 @@ namespace Qwirkle
Routing.RegisterRoute(nameof(SetPlayers), typeof(SetPlayers));
Routing.RegisterRoute(nameof(Gameboard), typeof(Gameboard));
+ Routing.RegisterRoute(nameof(Rules), typeof(Rules));
+ Routing.RegisterRoute(nameof(MainPage), typeof(MainPage));
}
diff --git a/Qwirkle/QwirkleViews/MainPage.xaml b/Qwirkle/QwirkleViews/MainPage.xaml
index 413e741..29516a9 100644
--- a/Qwirkle/QwirkleViews/MainPage.xaml
+++ b/Qwirkle/QwirkleViews/MainPage.xaml
@@ -28,7 +28,8 @@
-
+
diff --git a/Qwirkle/QwirkleViews/MainPage.xaml.cs b/Qwirkle/QwirkleViews/MainPage.xaml.cs
index ddbaa35..d37ff57 100644
--- a/Qwirkle/QwirkleViews/MainPage.xaml.cs
+++ b/Qwirkle/QwirkleViews/MainPage.xaml.cs
@@ -23,7 +23,10 @@ namespace Qwirkle
}
-
+ public void OnRulesClicked(object sender, EventArgs e)
+ {
+ Navigation.PushAsync(new Rules());
+ }
}
diff --git a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs
index 3df7d1e..63c0983 100644
--- a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs
+++ b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs
@@ -23,7 +23,7 @@ public partial class Gameboard : ContentPage
private List tilesSwap = [];
- public Color ColorBC1 { get; set; } = Colors.White;
+ public Color ColorBC1 { get; set; } = Colors.Transparent;
public Color ColorBC2 { get; set; } = Colors.Transparent;
public Color ColorBC3 { get; set; } = Colors.Transparent;
public Color ColorBC4 { get; set; } = Colors.Transparent;
@@ -31,10 +31,22 @@ public partial class Gameboard : ContentPage
public Gameboard()
{
+
InitializeComponent();
BindingContext = game;
+ ChangeColorBC();
+
+
}
+
+ private void Game_EndOfGameNotified(object? sender, EndOfGameNotifiedEventArgs e)
+ {
+ DisplayAlert("THE END.", "FAUT QU'ON PARLE DE CE QUE QU'ON VEUT FAIRE ICI !!!" ,"<3");
+ Navigation.PushAsync(new MainPage());
+ game.ClearGame();
+ }
+
private void OnDragStarting(object sender, DragStartingEventArgs e)
{
var tile = ((Element)sender).BindingContext as Tile;
@@ -78,6 +90,7 @@ public partial class Gameboard : ContentPage
private void OnButtonSkipClicked(object sender, EventArgs e)
{
game.NextPlayerNotified += Game_NextPlayerNotified;
+ game.EndOfGameNotified += Game_EndOfGameNotified;
if (game.PlayerSwapping)
{
@@ -95,6 +108,7 @@ public partial class Gameboard : ContentPage
game.CheckGameOver(game.GetPlayingPlayer());
game.SetNextPlayer();
game.NextPlayerNotified -= Game_NextPlayerNotified;
+ game.EndOfGameNotified -= Game_EndOfGameNotified;
ChangeColorBC();
}
@@ -159,14 +173,27 @@ public partial class Gameboard : ContentPage
if (game.CellsUsed.Count == 0 && !game.PlayerSwapping)
{
- DisplayAlert("Swap system", "\r\nWelcome to the swap system! To use the system, take the tiles you wish to swap and place them in the bag (you will not see the tiles disappear). Then, click on the skip button. /!\\ Attention, during the swap phase, you cannot play /!\\", "Copy !");
- game.PlayerSwapping = true;
+ //DisplayAlert("Swap system", "\r\nWelcome to the swap system! To use the system, take the tiles you wish to swap and place them in the bag (you will not see the tiles disappear). Then, click on the skip button. /!\\ Attention, during the swap phase, you cannot play /!\\", "Copy !");
+ AnswerSwap();
+
+
+
}
game.SwapTilesNotified -= Game_SwapTilesNotified;
game.PlaceTileNotified -= Game_PlaceTileNotified;
}
+ private async void AnswerSwap()
+ {
+ bool answer = await DisplayAlert("Swap System", "Etes vous sur de vouloir swap vos tuiles ? Attention, si vous swapez vous ne pouvez pu jouer", "Yes", "No");
+
+ if (answer)
+ {
+ game.PlayerSwapping = true;
+ }
+ }
+
private void Game_SwapTilesNotified(object? sender, SwapTilesNotifiedEventArgs args)
{
DisplayAlert("Swap system", args.Reason, "<3");
diff --git a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml
index 3095be4..2eaf015 100644
--- a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml
+++ b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml
@@ -35,7 +35,7 @@
DropCommand="{Binding OnDropB, Source={x:Reference root}}"
/>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Qwirkle/QwirkleViews/Pages/Rules.xaml.cs b/Qwirkle/QwirkleViews/Pages/Rules.xaml.cs
new file mode 100644
index 0000000..4e557f5
--- /dev/null
+++ b/Qwirkle/QwirkleViews/Pages/Rules.xaml.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Qwirkle.Pages;
+
+public partial class Rules : ContentPage
+{
+ public Rules()
+ {
+ InitializeComponent();
+ }
+}
\ No newline at end of file
diff --git a/Qwirkle/QwirkleViews/Resources/Styles/Styles.xaml b/Qwirkle/QwirkleViews/Resources/Styles/Styles.xaml
index d2f2823..e605fb2 100644
--- a/Qwirkle/QwirkleViews/Resources/Styles/Styles.xaml
+++ b/Qwirkle/QwirkleViews/Resources/Styles/Styles.xaml
@@ -254,6 +254,13 @@
+
+
+