pls loard
continuous-integration/drone/push Build is passing Details

test_old_branch
Jérémy Mouyon 11 months ago
parent a6746b66d8
commit 028de27909

@ -37,7 +37,7 @@ namespace QwirkleClassLibrary.Games
public ReadOnlyDictionary<string, int> ScoreBoard => scoreBoard.AsReadOnly();
private ObservableCollection<KeyValuePair<string, int>> observableScoreBoard = new ObservableCollection<KeyValuePair<string, int>>();
private readonly ObservableCollection<KeyValuePair<string, int>> observableScoreBoard = [];
public ReadOnlyObservableCollection<KeyValuePair<string, int>> ObservableScoreBoard =>
new ReadOnlyObservableCollection<KeyValuePair<string, int>>(observableScoreBoard);
@ -347,7 +347,6 @@ namespace QwirkleClassLibrary.Games
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));
return player.RemoveTileToPlayer(tile);
}
@ -812,14 +811,10 @@ namespace QwirkleClassLibrary.Games
public void SetScoreBoard(string name, int score)
{
if (scoreBoard.ContainsKey(name))
if (!scoreBoard.TryAdd(name, score))
{
scoreBoard[name] = score;
}
else
{
scoreBoard.Add(name, score);
}
observableScoreBoard.Clear();
foreach (var item in scoreBoard)

@ -5,11 +5,11 @@ namespace Qwirkle.Converters
{
public class Int2ColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string) return Colors.Transparent;
string colorstring = (string)value;
string? colorstring = (string)value;
if (string.IsNullOrWhiteSpace(colorstring)) return Colors.Transparent;
@ -33,17 +33,17 @@ namespace Qwirkle.Converters
public class RoundToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
string? sh = (string)value;
return sh == "Round";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
@ -51,17 +51,17 @@ namespace Qwirkle.Converters
public class RhombusToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
string? sh = (string)value;
return sh == "Rhombus";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
@ -69,17 +69,17 @@ namespace Qwirkle.Converters
public class SquareToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
string? sh = (string)value;
return sh == "Square";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
@ -87,17 +87,17 @@ namespace Qwirkle.Converters
public class ClubToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
string? sh = (string)value;
return sh == "Club";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
@ -105,17 +105,17 @@ namespace Qwirkle.Converters
public class ShurikenToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
string? sh = (string)value;
return sh == "Shuriken";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
@ -123,12 +123,12 @@ namespace Qwirkle.Converters
public class StarToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string)
return false;
string sh = (string)value;
string? sh = (string)value;
return sh == "Star";
}

@ -37,7 +37,7 @@ public partial class Gameboard : ContentPage
}
private void OnDragStarting(object sender, DragStartingEventArgs e)
{
var tile = (sender as Element).BindingContext as Tile;
var tile = ((Element)sender).BindingContext as Tile;
e.Data.Text = tile?.ToString();
tiledrag = tile;
}
@ -176,7 +176,7 @@ public partial class Gameboard : ContentPage
{
if (game.PlayerSwapping)
{
game.PlayerList[game.GetPlayingPlayerPosition()].RemoveTileToPlayer(tiledrag);
game.PlayerList[game.GetPlayingPlayerPosition()].RemoveTileToPlayer(tiledrag!);
tilesSwap.Add(tiledrag!);
}
}

@ -18,7 +18,7 @@ public partial class ButtonShadow : ContentView
set => SetValue(TextProperty, value);
}
public event EventHandler InfoClicked;
public event EventHandler? InfoClicked;
void OnInfoClicked(object sender, EventArgs args)
{

@ -7,12 +7,12 @@ using System.Linq;
namespace Qwirkle.Views
{
public partial class Scoreboard : ContentView, INotifyPropertyChanged
public partial class Scoreboard : ContentView
{
private Game game = ((App)Application.Current!).Game;
private ObservableCollection<KeyValuePair<string, int>> scoreboardList;
public ObservableCollection<KeyValuePair<string, int>> ScoreboardList
private ObservableCollection<KeyValuePair<string, int>>? scoreboardList;
public ObservableCollection<KeyValuePair<string, int>>? ScoreboardList
{
get => scoreboardList;
set
@ -41,16 +41,9 @@ namespace Qwirkle.Views
ScoreboardList = new ObservableCollection<KeyValuePair<string, int>>(scoreboard);
}
private void OnScoreChanged(object sender, EventArgs e)
private void OnScoreChanged(object? sender, EventArgs e)
{
UpdateScoreboard();
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

@ -6,21 +6,23 @@ namespace TestBase;
public class TestBoard
{
public static TheoryData<bool, int, int, Tile> DataBoard()
public static TheoryData<bool, int, int, Shape, Color> DataBoard()
{
var data = new TheoryData<bool, int, int, Tile>
var data = new TheoryData<bool, int, int, Shape, Color>
{
{
true,
1,
2,
new Tile(Shape.Round, Color.Red)
Shape.Round,
Color.Red
},
{
false,
-5,
9999,
new Tile(Shape.Round, Color.Red)
Shape.Round,
Color.Red
}
};
return data;
@ -28,9 +30,10 @@ public class TestBoard
[Theory]
[MemberData(nameof(DataBoard))]
public void Test_BoardAddSolo(bool except, int x, int y, Tile t)
public void Test_BoardAddSolo(bool except, int x, int y, Shape shape, Color color)
{
Tile t = new Tile(shape, color);
Board b = new Board(12, 12);
if (!except)

Loading…
Cancel
Save