boarddddddddddddd XAMLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

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

@ -26,7 +26,7 @@ namespace QwirkleClassLibrary.Boards
/// </summary>
/// <param name="rows">The numbers of rows 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;
Columns = cols;

@ -23,7 +23,15 @@ namespace QwirkleClassLibrary.Games
private TileBag? bag = null;
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();
private readonly List<Player> players = new();
@ -135,10 +143,10 @@ namespace QwirkleClassLibrary.Games
}
/// <summary>
/// Returns the board of the game
/// Returns the Board of the game
/// </summary>
/// <returns>Board</returns>
public Board? GetBoard() { return board; }
public Board? GetBoard() { return Board; }
/// <summary>
/// Returns the tile bag of the game
@ -147,13 +155,13 @@ namespace QwirkleClassLibrary.Games
public TileBag? GetTileBag() { return bag; }
/// <summary>
/// Creates a board with a number of columns and rows
/// Creates a Board with a number of columns and rows
/// </summary>
/// <returns>Board</returns>
public Board CreateBoard()
{
board = new Board(7, 7);
return board;
Board = new Board(15, 12);
return Board;
}
/// <summary>
@ -173,7 +181,7 @@ namespace QwirkleClassLibrary.Games
public void StartGame()
{
if (players.Count < 2 || players.Count >= 5) return;
board = CreateBoard();
Board = CreateBoard();
bag = CreateTileBag(3);
GameRunning = true;
}
@ -293,7 +301,7 @@ namespace QwirkleClassLibrary.Games
}
/// <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>
/// <param name="player"></param>
/// <param name="tile"></param>
@ -302,11 +310,11 @@ namespace QwirkleClassLibrary.Games
/// <returns>bool</returns>
public bool PlaceTile(Player player, Tile tile, int x, int y)
{
if (!IsMoveCorrect(tile, x, y, board!)) return false;
if (board!.AddTileInCell(x, y, tile))
if (!IsMoveCorrect(tile, x, y, Board!)) return false;
if (Board!.AddTileInCell(x, y, tile))
{
OnPlaceTile(new PlaceTileNotifiedEventArgs(tile, "was correctly placed !"));
AddCellUsed(board.GetCell(x, y));
AddCellUsed(Board.GetCell(x, y));
return player.RemoveTileToPlayer(tile);
}
@ -689,7 +697,7 @@ namespace QwirkleClassLibrary.Games
}
/// <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>
/// <param name="playerTilesBagPos"></param>
/// <returns></returns>
@ -699,12 +707,12 @@ namespace QwirkleClassLibrary.Games
{
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 y = board.ReadCells[b].GetY;
int x = Board.ReadCells[b].GetX;
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;
}
@ -742,7 +750,7 @@ namespace QwirkleClassLibrary.Games
scoreBoard.Clear();
cellUsed.Clear();
bag = null;
board = CreateBoard();
Board = CreateBoard();
GameRunning = false;
}
}

@ -1,9 +1,21 @@
using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
using System.Collections.ObjectModel;
using WinRT;
namespace Qwirkle.Pages;
public partial class Gameboard : ContentPage
{
public Gameboard()
private Game game = ((App)App.Current!).Game;
public Gameboard()
{
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"
x:Class="Qwirkle.Pages.Gameboard"
xmlns:controls="clr-namespace:Qwirkle.Views"
Title="Gameboard">
<VerticalStackLayout MaximumHeightRequest="1080"
MaximumWidthRequest="1920">
Title="Gameboard"
x:Name="root">
<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>
<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>
</ScrollView>
</ContentPage>

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

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

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