boarddddddddddddd XAMLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

test_old_branch
Jérémy Mouyon 11 months ago
parent aef5efb2ac
commit b5a44ba4a6

@ -26,7 +26,7 @@ namespace QwirkleClassLibrary.Boards
/// </summary> /// </summary>
/// <param name="rows">The numbers of rows in the board.</param> /// <param name="rows">The numbers of rows in the board.</param>
/// <param name="cols">The number of columns in the board.</param> /// <param name="cols">The number of columns in the board.</param>
public Board(int rows, int cols) public Board(int cols, int rows)
{ {
Rows = rows; Rows = rows;
Columns = cols; Columns = cols;

@ -23,7 +23,15 @@ namespace QwirkleClassLibrary.Games
private TileBag? bag = null; private TileBag? bag = null;
public bool GameRunning { get; private set; } public bool GameRunning { get; private set; }
private Board? board = null;
private Board _board = new Board(15, 12);
public Board Board
{
get { return _board; }
private set { _board = value; }
}
public ObservableCollection<Cell> GetCellsInBoard => new ObservableCollection<Cell>(Board!.GetCells());
public ReadOnlyCollection<Player> PlayerList => players.AsReadOnly(); public ReadOnlyCollection<Player> PlayerList => players.AsReadOnly();
private readonly List<Player> players = new(); private readonly List<Player> players = new();
@ -135,10 +143,10 @@ namespace QwirkleClassLibrary.Games
} }
/// <summary> /// <summary>
/// Returns the board of the game /// Returns the Board of the game
/// </summary> /// </summary>
/// <returns>Board</returns> /// <returns>Board</returns>
public Board? GetBoard() { return board; } public Board? GetBoard() { return Board; }
/// <summary> /// <summary>
/// Returns the tile bag of the game /// Returns the tile bag of the game
@ -147,13 +155,13 @@ namespace QwirkleClassLibrary.Games
public TileBag? GetTileBag() { return bag; } public TileBag? GetTileBag() { return bag; }
/// <summary> /// <summary>
/// Creates a board with a number of columns and rows /// Creates a Board with a number of columns and rows
/// </summary> /// </summary>
/// <returns>Board</returns> /// <returns>Board</returns>
public Board CreateBoard() public Board CreateBoard()
{ {
board = new Board(7, 7); Board = new Board(15, 12);
return board; return Board;
} }
/// <summary> /// <summary>
@ -173,7 +181,7 @@ namespace QwirkleClassLibrary.Games
public void StartGame() public void StartGame()
{ {
if (players.Count < 2 || players.Count >= 5) return; if (players.Count < 2 || players.Count >= 5) return;
board = CreateBoard(); Board = CreateBoard();
bag = CreateTileBag(3); bag = CreateTileBag(3);
GameRunning = true; GameRunning = true;
} }
@ -293,7 +301,7 @@ namespace QwirkleClassLibrary.Games
} }
/// <summary> /// <summary>
/// Allows the player to place a tile on the board at a (x, y) position /// Allows the player to place a tile on the Board at a (x, y) position
/// </summary> /// </summary>
/// <param name="player"></param> /// <param name="player"></param>
/// <param name="tile"></param> /// <param name="tile"></param>
@ -302,11 +310,11 @@ namespace QwirkleClassLibrary.Games
/// <returns>bool</returns> /// <returns>bool</returns>
public bool PlaceTile(Player player, Tile tile, int x, int y) public bool PlaceTile(Player player, Tile tile, int x, int y)
{ {
if (!IsMoveCorrect(tile, x, y, board!)) return false; if (!IsMoveCorrect(tile, x, y, Board!)) return false;
if (board!.AddTileInCell(x, y, tile)) if (Board!.AddTileInCell(x, y, tile))
{ {
OnPlaceTile(new PlaceTileNotifiedEventArgs(tile, "was correctly placed !")); OnPlaceTile(new PlaceTileNotifiedEventArgs(tile, "was correctly placed !"));
AddCellUsed(board.GetCell(x, y)); AddCellUsed(Board.GetCell(x, y));
return player.RemoveTileToPlayer(tile); return player.RemoveTileToPlayer(tile);
} }
@ -689,7 +697,7 @@ namespace QwirkleClassLibrary.Games
} }
/// <summary> /// <summary>
/// Returns a boolean to check if the player can play a tile on the board /// Returns a boolean to check if the player can play a tile on the Board
/// </summary> /// </summary>
/// <param name="playerTilesBagPos"></param> /// <param name="playerTilesBagPos"></param>
/// <returns></returns> /// <returns></returns>
@ -699,12 +707,12 @@ namespace QwirkleClassLibrary.Games
{ {
for (int j = 0; j < players[playerTilesBagPos[i]].Tiles.Count; j++) for (int j = 0; j < players[playerTilesBagPos[i]].Tiles.Count; j++)
{ {
for (int b = 0; b < board!.ReadCells.Count; b++) for (int b = 0; b < Board!.ReadCells.Count; b++)
{ {
int x = board.ReadCells[b].GetX; int x = Board.ReadCells[b].GetX;
int y = board.ReadCells[b].GetY; int y = Board.ReadCells[b].GetY;
if (IsMoveCorrect(players[playerTilesBagPos[i]].Tiles[j], x, y, board)) if (IsMoveCorrect(players[playerTilesBagPos[i]].Tiles[j], x, y, Board))
{ {
return true; return true;
} }
@ -742,7 +750,7 @@ namespace QwirkleClassLibrary.Games
scoreBoard.Clear(); scoreBoard.Clear();
cellUsed.Clear(); cellUsed.Clear();
bag = null; bag = null;
board = CreateBoard(); Board = CreateBoard();
GameRunning = false; GameRunning = false;
} }
} }

@ -1,9 +1,21 @@
using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
using System.Collections.ObjectModel;
using WinRT;
namespace Qwirkle.Pages; namespace Qwirkle.Pages;
public partial class Gameboard : ContentPage public partial class Gameboard : ContentPage
{ {
public Gameboard()
private Game game = ((App)App.Current!).Game;
public Gameboard()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = game;
} }
public List<Tile> PlayerCells1 { get; set; } = ((App)App.Current!).Game.PlayerList[0].Tiles.ToList();
} }

@ -3,37 +3,31 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Qwirkle.Pages.Gameboard" x:Class="Qwirkle.Pages.Gameboard"
xmlns:controls="clr-namespace:Qwirkle.Views" xmlns:controls="clr-namespace:Qwirkle.Views"
Title="Gameboard"> Title="Gameboard"
<VerticalStackLayout MaximumHeightRequest="1080" x:Name="root">
MaximumWidthRequest="1920"> <ScrollView>
<Label
Text="Test"/>
<CollectionView ItemsSource="{Binding GetCellsInBoard}"
HorizontalOptions="Center"
VerticalOptions="Center">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"
Span="{Binding Board.Columns}"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke"
Margin="0">
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Rectangle Fill="White" Stroke="CornflowerBlue" StrokeThickness="10" RadiusX="20"
HeightRequest="500"
WidthRequest="700" />
<!-- Test grille dans la grille -->
<Grid> </ScrollView>
<Grid.ColumnDefinitions>
<ColumnDefinition Width= "1000" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="3*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
</Grid>
<Grid ColumnDefinitions="1000" RowDefinitions="*, 3, *">
</Grid>
</VerticalStackLayout>
</ContentPage> </ContentPage>

@ -69,9 +69,12 @@
</VerticalStackLayout> </VerticalStackLayout>
</Border> </Border>
<controls:TileShuriken></controls:TileShuriken>
</VerticalStackLayout> </VerticalStackLayout>
</ScrollView> </ScrollView>
</ContentPage> </ContentPage>

@ -8,7 +8,7 @@
<Label <Label
Grid.Column="0" Grid.Column="0"
Text="Player Tag" Text="Player"
Style="{StaticResource ContentTab}"/> Style="{StaticResource ContentTab}"/>
<Rectangle <Rectangle

@ -15,6 +15,7 @@
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
WidthRequest="600" WidthRequest="600"
HeightRequest="600" /> HeightRequest="600"
BackgroundColor="AntiqueWhite"/>
</Grid> </Grid>
</ContentView> </ContentView>
Loading…
Cancel
Save