|
|
@ -1,4 +1,6 @@
|
|
|
|
using QwirkleClassLibrary.Players;
|
|
|
|
using QwirkleClassLibrary.Players;
|
|
|
|
|
|
|
|
using QwirkleClassLibrary.Games;
|
|
|
|
|
|
|
|
using QwirkleClassLibrary.Boards;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
|
|
|
@ -6,43 +8,39 @@ namespace Qwirkle.Views;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class Scoreboard : ContentView, INotifyPropertyChanged
|
|
|
|
public partial class Scoreboard : ContentView, INotifyPropertyChanged
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private IOrderedEnumerable<KeyValuePair<Player, int>> scoreboard;
|
|
|
|
private Game game = ((App)Application.Current!).Game;
|
|
|
|
private Dictionary<Player, int> currentScoreBoard;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Player> namesPlayers;
|
|
|
|
private IOrderedEnumerable<KeyValuePair<string, int>> scoreboard;
|
|
|
|
public List<Player> NamesPlayers
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<KeyValuePair<string, int>> scoreboardList;
|
|
|
|
|
|
|
|
public ObservableCollection<KeyValuePair<string, int>> ScoreboardList
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get => namesPlayers;
|
|
|
|
get => scoreboardList;
|
|
|
|
set
|
|
|
|
set
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (namesPlayers != value)
|
|
|
|
if (scoreboardList != value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
namesPlayers = value;
|
|
|
|
scoreboardList = value;
|
|
|
|
OnPropertyChanged(nameof(NamesPlayers));
|
|
|
|
OnPropertyChanged(nameof(ScoreboardList));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Scoreboard()
|
|
|
|
public Scoreboard()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
InitializeComponent();
|
|
|
|
BindingContext = this;
|
|
|
|
BindingContext = this;
|
|
|
|
|
|
|
|
|
|
|
|
scoreboard = ((App)Application.Current!).Game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
|
|
|
|
scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key);
|
|
|
|
currentScoreBoard = scoreboard.ToDictionary<Player, int>();
|
|
|
|
ScoreboardList = new ObservableCollection<KeyValuePair<string, int>>(scoreboard);
|
|
|
|
|
|
|
|
|
|
|
|
NamesPlayers = currentScoreBoard.Keys.ToList();
|
|
|
|
game.Board.PropertyChanged += Board_PropertyChanged;
|
|
|
|
|
|
|
|
|
|
|
|
((App)Application.Current!).Game.Board.PropertyChanged += Board_PropertyChanged;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Board_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
|
|
private void Board_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
|
|
|
|
scoreboard = ((App)Application.Current!).Game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
|
|
|
|
ScoreboardList = new ObservableCollection<KeyValuePair<string, int>>(scoreboard);
|
|
|
|
currentScoreBoard = scoreboard.ToDictionary<Player, int>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NamesPlayers = currentScoreBoard.Keys.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
@ -51,7 +49,4 @@ public partial class Scoreboard : ContentView, INotifyPropertyChanged
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|