using System;
using Model;

namespace StubLib
{
    public partial class StubData
    {
        private readonly List<Skin> skins = new();

        private void InitSkins()
        {
            //Renekton
            skins.Add(new Skin("Project", champions[0], 1820, "[encoded data, 8640 characters]",
                    "[encoded data, 134644 characters]",
                    "A hybridized warrior taking inspiration from extinct fauna, Renekton is the perfected version of PROJECT's crossbreed superweapon project. Released to aid the City in its fight against the Program virus, Renekton's seemingly endless rage is useful for now... though his belief that he can \"see beyond the soul\" is increasingly disconcerting."));

            skins.Add(new Skin("Maître Nageur", champions[0], 975, "[encoded data, 11776 characters]",
                "[encoded data, 270500 characters]",
                "Lifeguard on duty! Seriously though, be careful-you don't want CPR from a nine foot tall crocodile man."));

            skins.Add(new Skin("Jouet", champions[0], 750, "[encoded data, 11748 characters]",
                "[encoded data, 277004 characters]",
                "First produced in 1996, Renektoy quickly and unexpectedly became the must-have gift of the season. Shortages and heightened demand led to online scalping, parents fist fighting in store aisles, and a small number of what police later described as \"mall stampedes\"."));

            //Aphelios
            skins.Add(new Skin("Fleur spirituelle", champions[1], 1350, "[encoded data, 11584 characters]",
                "[encoded data, 260392 characters]",
                "Ionians share whispered stories of the twin spirits of the night, Aphelio and Alune. It is said the darkening of the sky, comes from the brother's armaments, tearing the fabric of blues and whites apart to create an obsidian canvas painted with stars. The sister's motives are more... mysterious."));

            //Volibear
            skins.Add(new Skin("Volibear Runique", champions[2], 975.0f, "[encoded data, 11984 characters]",
                "[encoded data, 137332 characters]"
                ));
            skins.Add(new Skin("Volibear aux Mille Piques", champions[2], 975.0f, "[encoded data, 11108 characters]",
                "[encoded data, 67380 characters]",
                "Ancient Freljordian legends speak of spirit walkers consumed by the true spirit of the unrelenting bear-a force older than the Freljord itself. Those who dare to invoke its name cannot fathom the terrible, primal power they call down upon themselves."));
            skins.Add(new Skin("Dragon de la Dualité", champions[2], 1350.0f, "[encoded data, 12240 characters]",
                "[encoded data, 132404 characters]",
                "Volibear was the greatest terror in the forest, until the nearby volcano erupted. In the frenzy of escape, Volibear came across a child who was similarly trapped, and heeded a strange instinct-he saved the child. The Duality Dragon saw and made the mighty predator an offer: the power to hone the duality of his nature, both fury and compassion."));

            //Annie
            skins.Add(new Skin("Annie Nounours", champions[3], 975.0f, "[encoded data, 12524 characters]",
                "[encoded data, 97212 characters]"));
            skins.Add(new Skin("Super Annie Intergalactique", champions[3], 1350.0f, "[encoded data, 12632 characters]",
                "[encoded data, 145428 characters]",
                "The youngest human ever to be named a Super Galaxy cadet, Annie proved her mettle the day she turned her teddy bear into a self-piloting mech. Despite serious concerns over her highly combustible designs and volatile programming, Annie's Mecha-Tibbers went into full production. Desperate times call for destructive measures."));
            skins.Add(new Skin("Annie Café Chouchous", champions[3], 1350.0f, "[encoded data, 12428 characters]",
                "[encoded data, 133648 characters]",
                "Daughter of the cafe's owner and an accomplished pastry mage wunderkind, Annie has a sweet tooth to be reckoned with. Though her occasional hangry tantrums send her enchanted gummy bear scouring the cafe for any morsel of food fit for her master, with a full belly Annie is as sweet as sugar!"));

            //Aurelion Sol
            skins.Add(new Skin("Seigneur Volcanique", champions[4], 1350.0f, "[encoded data, 11892 characters]",
                "[encoded data, 71292 characters]",
                "Pyromancer cultists unwisely summoned the god of fire and ruin—the Ashen Lord—into the world hoping to control his power. Instead, he unleashed his infernal legions to remake all things in his image: cinder, ash, and death."));
            skins.Add(new Skin("Mecha", champions[4], 1350.0f, "[encoded data, 12188 characters]",
                "[encoded data, 116540 characters]",
                "Designated ASOL-13, the “Mecha Aurelion Sol” is a gigantic, mobile mothership carrying tens of thousands of personnel, attack fighters, and ground-based anti-kaiju vehicles. Buried within its hull are a vast array of weapons, making ASOL-13 more than a match for even the most gargantuan kaiju."));
            skins.Add(new Skin("Dragon des Tempêtes", champions[4], 1350.0f, "[encoded data, 12296 characters]",
                "[encoded data, 102164 characters]",
                "The dragon Aurelion Sol, known to seven generations of worshippers as Ao Shin, has long awaited the ascent of a warrior worthy of receiving the power of the storm. Now, with Lee Sin's transformation into the Dragonmancer, Ao Shin has directed his impossible power towards purging the world of evil."));

            //Yone
            skins.Add(new Skin("Fleur Spirituelle", champions[5], 1350.0f, "[encoded data, 12148 characters]",
                "[encoded data, 107120 characters]",
                "Long ago, two brothers fought a bitter war across Ionia. Yone, the older brother, was a warlord renowned for his adherence to honor and duty. He fought to defend the country against those who would break its rites and rituals - until he was forced to confront his own brother for his crimes. Both were fated to fall in their final duel… a lesson, perhaps, in pride and hubris."));
            skins.Add(new Skin("Héraut de l'Aube", champions[5], 1350.0f, "[encoded data, 12188 characters]",
                "[encoded data, 131656 characters]",
                "Prophecy dictates that the gods will destroy each other, ushering in the end of creation itself— but Yone is determined to defy fate. A half-mortal, half-god born of the clash between chaos and order, Yone wields the power of both night and dawn. He must rally his brethren, bring peace to the gods… or they will all perish. "));

            //Thresh
            skins.Add(new Skin("Lune de Sang", champions[6], 975.0f, "[encoded data, 12288 characters]",
                "[encoded data, 103664 characters]",
                "A demon summoned on the night of the Blood Moon, Thresh's insatiable urge to torture and kill is fueled by thousands of vengeful spirits drawn to his lantern. Entire villages are left slaughtered in his wake, their blood staining the land for decades."));
            skins.Add(new Skin("Pulsar Sombre", champions[6], 1820.0f, "[encoded data, 12052 characters]",
                "[encoded data, 93120 characters]",
                "A cosmic nightmare who worships the all-consuming Dark Star, Thresh vows to feed the whole of existence to his “god” until all matter, time, and thought are erased. His work will be complete when nothing remains, freeing him to finally leap into the singularity and become one with the end of the universe."));
        }

        public class SkinsManager : ISkinsManager
        {
            private readonly StubData parent;

            public SkinsManager(StubData parent)
                => this.parent = parent;

            public Task<Skin?> AddItem(Skin? item)
                => parent.skins.AddItem(item);

            public Task<bool> DeleteItem(Skin? item)
                => parent.skins.DeleteItem(item);

            public Task<IEnumerable<Skin?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
                => parent.skins.GetItemsWithFilterAndOrdering(
                    skin => true,
                    index, count, orderingPropertyName, descending);

            private static Func<Skin, Champion?, bool> filterByChampion = (skin, champion) => champion != null && skin.Champion.Equals(champion!);

            private static Func<Skin, string, bool> filterByName = (skin, substring) => skin.Name.Equals(substring, StringComparison.InvariantCultureIgnoreCase);

            private static Func<Skin, string, bool> filterByNameContains = (skin, substring) => skin.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase);

            public Task<IEnumerable<Skin?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
                => parent.skins.GetItemsWithFilterAndOrdering(
                    skin => filterByChampion(skin, champion),
                    index, count, orderingPropertyName, descending);

            public Task<IEnumerable<Skin?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
                => parent.skins.GetItemsWithFilterAndOrdering(
                    skin => filterByNameContains(skin, substring),
                    index, count, orderingPropertyName, descending);

            public Task<IEnumerable<Skin?>> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
                => parent.skins.GetItemsWithFilterAndOrdering(
                    skin => filterByName(skin, substring),
                    index, count, orderingPropertyName, descending);

            public Task<int> GetNbItems()
                => parent.skins.GetNbItemsWithFilter(
                    c => true);

            public Task<int> GetNbItemsByChampion(Champion? champion)
                => parent.skins.GetNbItemsWithFilter(
                    skin => filterByChampion(skin, champion));

            public Task<int> GetNbItemsByName(string substring)
                => parent.skins.GetNbItemsWithFilter(
                    skin => filterByName(skin, substring));

            public Task<Skin?> UpdateItem(Skin? oldItem, Skin? newItem)
                => parent.skins.UpdateItem(oldItem, newItem);
        }
    }
}

