on the good road
continuous-integration/drone/push Build is passing Details

test_old_branch
Jérémy Mouyon 11 months ago
parent bc35df6566
commit 93c9593e2e

@ -160,7 +160,7 @@ namespace QwirkleClassLibrary.Games
/// <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;
} }

@ -1,27 +1,62 @@
using QwirkleClassLibrary.Games; using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Players; using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles; using QwirkleClassLibrary.Tiles;
using QwirkleClassLibrary.Events;
using QwirkleClassLibrary.Boards;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Windows.Input;
using System.ComponentModel;
using Cell = QwirkleClassLibrary.Boards.Cell;
namespace Qwirkle.Pages; namespace Qwirkle.Pages;
public partial class Gameboard : ContentPage public partial class Gameboard : ContentPage
{ {
public ICommand OnDrop => new Command<Cell>(onDrop);
private Game game = ((App)App.Current!).Game; private Game game = ((App)App.Current!).Game;
private Tile? tiledrag;
public Gameboard() public Gameboard()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = game; BindingContext = game;
DisplayAlert("List", ((App)App.Current!).Game.PlayerList[0].Tiles[0].ToString(), "chut");
}
DisplayAlert("List", ((App)App.Current!).Game.PlayerList[0].Tiles[0].ToString(), "chut"); public List<Tile> PlayerCells1 { get; set; } = ((App)App.Current!).Game.PlayerList[0].Tiles.ToList();
}
public List<Tile> PlayerCells1 { get; set; } = ((App)App.Current!).Game.PlayerList[0].Tiles.ToList();
void OnDragOver(object sender, DragEventArgs e) void OnDragOver(object sender, DragEventArgs e)
{ {
foreach (var t in PlayerCells1)
{
if (e.Data.Text == t.ToString())
{
tiledrag = t;
break;
}
}
}
private void onDrop(Cell cell)
{
game.PlaceTileNotified += Game_PlaceTileNotified;
int x = cell.GetX;
int y = cell.GetY;
game.PlaceTile(game.GetPlayingPlayer(), tiledrag, x, y);
game.PlaceTileNotified -= Game_PlaceTileNotified;
} }
private void Game_PlaceTileNotified(object? sender, PlaceTileNotifiedEventArgs args)
{
DisplayAlert("Tile place notified", args.Reason, "<3");
}
} }

@ -19,13 +19,17 @@
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Border WidthRequest="70" HeightRequest="70" <Border WidthRequest="70" HeightRequest="70"
BackgroundColor="WhiteSmoke" BackgroundColor="WhiteSmoke"
Margin="0"> Margin="0">
<Label Text="{Binding Tile}"></Label>
<Border.GestureRecognizers> <Border.GestureRecognizers>
<DropGestureRecognizer /> <DropGestureRecognizer DragOver="OnDragOver"
DropCommand="{Binding OnDrop, Source={x:Reference root}}"
DropCommandParameter="{Binding .}" />
</Border.GestureRecognizers> </Border.GestureRecognizers>
<Label Text="{Binding GetTile}"></Label>
</Border> </Border>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
@ -56,7 +60,5 @@
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>
</ContentPage> </ContentPage>
Loading…
Cancel
Save