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..89fe1be 100644
--- a/Qwirkle/QwirkleViews/App.xaml.cs
+++ b/Qwirkle/QwirkleViews/App.xaml.cs
@@ -15,6 +15,7 @@ namespace Qwirkle
Routing.RegisterRoute(nameof(SetPlayers), typeof(SetPlayers));
Routing.RegisterRoute(nameof(Gameboard), typeof(Gameboard));
+ Routing.RegisterRoute(nameof(Rules), typeof(Rules));
}
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/Rules.xaml b/Qwirkle/QwirkleViews/Pages/Rules.xaml
new file mode 100644
index 0000000..1bc40b8
--- /dev/null
+++ b/Qwirkle/QwirkleViews/Pages/Rules.xaml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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 @@
+
+
+