using QwirkleClassLibrary.Games; using QwirkleClassLibrary.Players; using QwirkleClassLibrary.Tiles; using QwirkleClassLibrary.Events; using QwirkleClassLibrary.Boards; using System.Collections.ObjectModel; using System.Windows.Input; using System.ComponentModel; using Cell = QwirkleClassLibrary.Boards.Cell; namespace Qwirkle.Pages; public partial class Gameboard : ContentPage { public ICommand OnDrop => new Command(OnDropTile); private Game game = ((App)Application.Current!).Game; private Tile? tiledrag; public Gameboard() { InitializeComponent(); BindingContext = game; } private void OnDragOver(object sender, DragEventArgs e) { foreach (var t in game.PlayerList[game.GetPlayingPlayerPosition()].Tiles) { if (e.Data.Text == t.ToString()) { tiledrag = t; break; } } } private void OnDropTile(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"); } }