using System.Drawing;
using ImageMagick;

namespace Kynareth.Helpers.AmongUs;

public enum AmogusRole
{
	Imposter,
	Crewmate,
	Unknown
}
	
public enum AmogusColour
{
	Red,
	Blue,
	Green,
	Pink,
	Orange,
	Yellow,
	Black,
	White,
	Purple,
	Brown,
	Cyan,
	Lime,
	Maroon,
	Rose,
	Banana,
	Gray,
	Tan,
	Coral,
}
	
public enum AmogusSkin
{
	Archaeologist,
	Astronaut,
	Captain,
	Hazmat,
	Mechanic,
	Military,
	Miner,
	Police,
	SecurityGuard,
	Scientist,
	BlackSuit,
	WhiteSuit,
	Tarmac,
	Wall,
	Winter,
	None,
}

public readonly struct ColourHelper
{
    private static readonly Dictionary<AmogusColour, MagickColor> RedReplaceColors = new() {
        { AmogusColour.Red, new(215, 30, 34, 255) },
        { AmogusColour.Blue, new(29, 60, 233, 255) },
        { AmogusColour.Green, new(27, 145, 62, 255) },
        { AmogusColour.Pink, new(255, 99, 212, 255) },
        { AmogusColour.Orange, new(255, 141, 28, 255) },
        { AmogusColour.Yellow, new(255, 255, 103, 255) },
        { AmogusColour.Black, new(74, 86, 94, 255) },
        { AmogusColour.White, new(233, 247, 255, 255) },
        { AmogusColour.Purple, new(120, 61, 210, 255) },
        { AmogusColour.Brown, new(128, 88, 45, 255) },
        { AmogusColour.Cyan, new(68, 255, 247, 255) },
        { AmogusColour.Lime, new(91, 255, 75, 255) },
        { AmogusColour.Maroon, new(108, 43, 61, 255) },
        { AmogusColour.Rose, new(255, 214, 236, 255) },
        { AmogusColour.Banana, new(255, 255, 190, 255) },
        { AmogusColour.Gray, new(131, 151, 167, 255) },
        { AmogusColour.Tan, new(159, 153, 137, 255) },
        { AmogusColour.Coral, new(236, 117, 120, 255) },
    };

    private static readonly Dictionary<AmogusColour, MagickColor> BlueReplaceColors = new() {
        { AmogusColour.Red, new(122, 8, 56, 255) },
        { AmogusColour.Blue, new(9, 21, 142, 255) },
        { AmogusColour.Green, new(10, 77, 46, 255) },
        { AmogusColour.Pink, new(172, 43, 174, 255) },
        { AmogusColour.Orange, new(180, 62, 21, 255) },
        { AmogusColour.Yellow, new(195, 136, 34, 255) },
        { AmogusColour.Black, new(30, 31, 38, 255) },
        { AmogusColour.White, new(132, 149, 192, 255) },
        { AmogusColour.Purple, new(59, 23, 124, 255) },
        { AmogusColour.Brown, new(94, 38, 21, 255) },
        { AmogusColour.Cyan, new(36, 169, 191, 255) },
        { AmogusColour.Lime, new(21, 168, 66, 255) },
        { AmogusColour.Maroon, new(65, 15, 26, 255) },
        { AmogusColour.Rose, new(222, 146, 179, 255) },
        { AmogusColour.Banana, new(210, 188, 137, 255) },
        { AmogusColour.Gray, new(70, 86, 100, 255) },
        { AmogusColour.Tan, new(81, 65, 62, 255) },
        { AmogusColour.Coral, new(180, 67, 98, 255) },
    };

    private readonly MagickColor _green = new(149, 202, 220, 255);
    private readonly MagickColor _red;
    private readonly MagickColor _blue;

    public MagickColor Red => _red;
    public MagickColor Green => _green;
    public MagickColor Blue => _blue;

    public ColourHelper(AmogusColour colour = AmogusColour.Blue)
    {
        _red = RedReplaceColors[colour];
        _blue = BlueReplaceColors[colour];
    }
}

public static class AmongUsGeneratorHelper
{
    public static readonly Dictionary<AmogusSkin, string> IdleSkins = new()
    {
        { AmogusSkin.Archaeologist, "archae-idle.png" },
        { AmogusSkin.Astronaut, "astro-idle.png" },
        { AmogusSkin.Captain, "captain-idle.png" },
        { AmogusSkin.Hazmat, "hazmat-idle.png" },
        { AmogusSkin.Mechanic, "mech-idle.png" },
        { AmogusSkin.Military, "military-idle.png" },
        { AmogusSkin.Miner, "miner-idle.png" },
        { AmogusSkin.Police, "pol-idle.png" },
        { AmogusSkin.SecurityGuard, "secguard-idle.png" },
        { AmogusSkin.Scientist, "sci-idle.png" },
        { AmogusSkin.BlackSuit, "suitBlack-idle.png" },
        { AmogusSkin.WhiteSuit, "suitWhite-idle.png" },
        { AmogusSkin.Tarmac, "tarmac-idle.png" },
        { AmogusSkin.Wall, "wall-idle.png" },
        { AmogusSkin.Winter, "winter-idle.png" },
    };

    public static readonly Dictionary<AmogusSkin, string> EjectSkins = new()
    {
        { AmogusSkin.Archaeologist, "archae-eject.png" },
        { AmogusSkin.Astronaut, "astro-eject.png" },
        { AmogusSkin.Captain, "captain-eject.png" },
        { AmogusSkin.Hazmat, "hazmat-eject.png" },
        { AmogusSkin.Mechanic, "mech-eject.png" },
        { AmogusSkin.Military, "military-eject.png" },
        { AmogusSkin.Miner, "miner-eject.png" },
        { AmogusSkin.Police, "police-eject.png" },
        { AmogusSkin.SecurityGuard, "secguard-eject.png" },
        { AmogusSkin.Scientist, "sci-eject.png" },
        { AmogusSkin.BlackSuit, "suitBlack-eject.png" },
        { AmogusSkin.WhiteSuit, "suitWhite-eject.png" },
        { AmogusSkin.Tarmac, "tarmac-eject.png" },
        { AmogusSkin.Wall, "wall-eject.png" },
        { AmogusSkin.Winter, "winter-eject.png" },
    };

    public static readonly Dictionary<AmogusSkin, Point> IdleOffset = new()
    {
        { AmogusSkin.Archaeologist, new(13, 41) },
        { AmogusSkin.Astronaut, new(13, 46) },
        { AmogusSkin.Captain, new(14, 45) },
        { AmogusSkin.Hazmat, new(12, 34) },
        { AmogusSkin.Mechanic, new(13, 46) },
        { AmogusSkin.Military, new(11, 45) },
        { AmogusSkin.Miner, new(13, 40) },
        { AmogusSkin.Police, new(10, 45) },
        { AmogusSkin.SecurityGuard, new(13, 42) },
        { AmogusSkin.Scientist, new(14, 43) },
        { AmogusSkin.BlackSuit, new(14, 44) },
        { AmogusSkin.WhiteSuit, new(14, 44) },
        { AmogusSkin.Tarmac, new(14, 40) },
        { AmogusSkin.Wall, new(10, 44) },
        { AmogusSkin.Winter, new(9, 35) },
    };

    public static readonly Dictionary<AmogusSkin, Point> EjectOffset = new()
    {
        { AmogusSkin.Archaeologist, new(12, 35) },
        { AmogusSkin.Astronaut, new(12, 35) },
        { AmogusSkin.Captain, new(12, 35) },
        { AmogusSkin.Hazmat, new(13, 37) },
        { AmogusSkin.Mechanic, new(13, 35) },
        { AmogusSkin.Military, new(12, 35) },
        { AmogusSkin.Miner, new(12, 36) },
        { AmogusSkin.Police, new(12, 35) },
        { AmogusSkin.SecurityGuard, new(13, 35) },
        { AmogusSkin.Scientist, new(-10, 35) },
        { AmogusSkin.BlackSuit, new(12, 35) },
        { AmogusSkin.WhiteSuit, new(11, 35) },
        { AmogusSkin.Tarmac, new(14, 37) },
        { AmogusSkin.Wall, new(12, 35) },
        { AmogusSkin.Winter, new(5, 30) },
    };
}