using System;
using System.Globalization;

namespace Qwirkle.Converters
{
    public class Int2ColorConverter : IValueConverter
    {
        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is not string) return Colors.Transparent;

            string? colorstring = (string)value;

            if (string.IsNullOrWhiteSpace(colorstring)) return Colors.Transparent;

            if (colorstring == "Yellow") return Colors.Yellow;
            if (colorstring == "Red") return Colors.Red;
            if (colorstring == "Blue") return Colors.Blue;
            if (colorstring == "Green") return Colors.Green;
            if (colorstring == "Orange") return Colors.Orange;
            if (colorstring == "Purple") return Colors.Purple;
            if (colorstring == "Transparent") return Colors.Transparent;


            return Colors.Transparent;
        }

        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class RoundToVisibilityConverter : IValueConverter
    {
        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is not string)
                return false;

            string? sh = (string)value;

            return sh == "Round";
        }

        public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }

    public class RhombusToVisibilityConverter : IValueConverter
    {
        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is not string)
                return false;

            string? sh = (string)value;

            return sh == "Rhombus";
        }

        public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }

    public class SquareToVisibilityConverter : IValueConverter
    {
        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is not string)
                return false;

            string? sh = (string)value;

            return sh == "Square";
        }

        public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }

    public class ClubToVisibilityConverter : IValueConverter
    {
        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is not string)
                return false;

            string? sh = (string)value;

            return sh == "Club";
        }

        public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }

    public class ShurikenToVisibilityConverter : IValueConverter
    {
        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is not string)
                return false;

            string? sh = (string)value;

            return sh == "Shuriken";
        }

        public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }

    public class StarToVisibilityConverter : IValueConverter
    {
        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is not string)
                return false;

            string? sh = (string)value;

            return sh == "Star";
        }

        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
