work.
continuous-integration/drone/push Build is passing Details

test_old_branch
Jérémy Mouyon 11 months ago
parent 0787add85f
commit ed05061476

@ -30,6 +30,7 @@ namespace QwirkleClassLibrary.Games
[DataMember]
private Board board = new Board(15, 12);
public Board Board => board;
public ObservableCollection<Cell> GetCellsInBoard => new ObservableCollection<Cell>(board!.GetCells());

@ -1,18 +1,24 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary.Players
{
public class Player
public class Player : INotifyPropertyChanged
{
public ReadOnlyCollection<Tile> Tiles => playerTiles.AsReadOnly();
private readonly List<Tile> playerTiles = new();
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged([CallerMemberName] string? propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/// <summary>
/// Creates a player with a name
/// </summary>
@ -39,6 +45,7 @@ namespace QwirkleClassLibrary.Players
public void AddTileToPlayer(Tile tile)
{
playerTiles.Add(tile);
OnPropertyChanged();
}
/// <summary>
@ -48,7 +55,12 @@ namespace QwirkleClassLibrary.Players
/// <returns>bool</returns>
public bool RemoveTileToPlayer(Tile tile)
{
return playerTiles.Remove(tile);
if (playerTiles.Remove(tile))
{
OnPropertyChanged();
return true;
}
return false;
}
}
}

@ -9,24 +9,34 @@ using System.ComponentModel;
using Cell = QwirkleClassLibrary.Boards.Cell;
namespace Qwirkle.Pages;
public partial class Gameboard : ContentPage
public partial class Gameboard : ContentPage, INotifyPropertyChanged
{
public ICommand OnDrop => new Command<Cell>(OnDropTile);
private Game game = ((App)Application.Current!).Game;
private Tile? tiledrag;
private ObservableCollection<Tile> playerCells1;
public ObservableCollection<Tile> PlayerCells1
{
get => playerCells1;
set
{
playerCells1 = value;
OnPropertyChanged(nameof(PlayerCells1));
}
}
public Gameboard()
{
InitializeComponent();
BindingContext = game;
DisplayAlert("List", ((App)Application.Current!).Game.PlayerList[0].Tiles[0].ToString(), "chut");
PlayerCells1 = new ObservableCollection<Tile>(game.PlayerList[0].Tiles.ToList());
DisplayAlert("List", playerCells1[0].ToString(), "chut");
}
public List<Tile> PlayerCells1 { get; set; } = ((App)Application.Current!).Game.PlayerList[0].Tiles.ToList();
private void OnDragOver(object sender, DragEventArgs e)
@ -59,4 +69,11 @@ public partial class Gameboard : ContentPage
{
DisplayAlert("Tile place notified", args.Reason, "<3");
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

@ -10,43 +10,39 @@
<StackLayout>
<CollectionView ItemsSource="{Binding GetCellsInBoard}"
HorizontalOptions="Center"
VerticalOptions="Center">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"
Span="{Binding Board.Columns}"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
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">
BackgroundColor="WhiteSmoke"
Margin="0">
<Border.GestureRecognizers>
<DropGestureRecognizer DragOver="OnDragOver"
DropCommand="{Binding OnDrop, Source={x:Reference root}}"
DropCommandParameter="{Binding .}" />
</Border.GestureRecognizers>
<Label Text="{Binding GetTile}"></Label>
<Label Text="{Binding GetTile}" />
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView ItemsSource="{Binding PlayerCells1, Source={x:Reference root}}"
HorizontalOptions="Center"
VerticalOptions="Start" >
<CollectionView ItemsSource="{Binding PlayerCells1, Source={x:Reference root}}"
HorizontalOptions="Center"
VerticalOptions="Start" >
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Horizontal"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke"
Margin="0">
BackgroundColor="WhiteSmoke"
Margin="0">
<Label Text="{Binding}">
<Label.GestureRecognizers>
<DragGestureRecognizer />
@ -54,11 +50,10 @@
</Label>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</ScrollView>
</ContentPage>
</ContentPage>

Loading…
Cancel
Save