Exemple #1
0
        internal static void LoadCards(int type, ref int indexCounter)
        {
            var cardIndex = 0;
            var csv       = CSV.Tables.Get(type);

            foreach (var data in csv.Datas)
            {
                var card = new Card
                {
                    Type  = type,
                    Index = indexCounter,
                    Scid  = new SCID(type, cardIndex++)
                };

                if (type == TYPE_BUILDING)
                {
                    var info = (Spells_Buildings)csv.GetData(data.Row.Name);
                    card.Name        = info.Name;
                    card.Rarity      = Rarities.Get(info.Rarity);
                    card.ElixirCost  = info.ManaCost;
                    card.UnlockArena = Arenas.Get(info.UnlockArena);
                    card.NotInUse    = info.NotInUse;
                }
                else if (type == TYPE_CHARACTER)
                {
                    var info = (Spells_Characters)csv.GetData(data.Row.Name);
                    card.Name        = info.Name;
                    card.Rarity      = Rarities.Get(info.Rarity);
                    card.ElixirCost  = info.ManaCost;
                    card.UnlockArena = Arenas.Get(info.UnlockArena);
                    card.NotInUse    = info.NotInUse;
                }
                else if (type == TYPE_SPELL)
                {
                    var info = (Spells_Other)csv.GetData(data.Row.Name);
                    card.Name        = info.Name;
                    card.Rarity      = Rarities.Get(info.Rarity);
                    card.ElixirCost  = info.ManaCost;
                    card.UnlockArena = Arenas.Get(info.UnlockArena);
                    card.NotInUse    = info.NotInUse;
                }


                Card_List.Add(card);
                ++indexCounter;
            }
        }
Exemple #2
0
        //Not working yet
        public OpeningChest GenerateChest(Avatar player, Chest chest, Random random)
        {
            var isDraft = chest.DraftChest;
            var builder = OpeningChest.Builder(isDraft);

            var common    = Rarities.Get("Common");
            var rare      = Rarities.Get("Rare");
            var epic      = Rarities.Get("Epic");
            var legendary = Rarities.Get("Legendary");

            float rewardMultiplier       = chest.Arena.ChestRewardMultiplier / 100f;
            int   minimumSpellsCount     = (int)(chest.RandomSpells * rewardMultiplier);
            int   minimumDifferentSpells = (int)(chest.DifferentSpells * rewardMultiplier);

            Console.WriteLine($"minimumSpellsCount {minimumSpellsCount}");
            Console.WriteLine($"minimumDifferentSpells {minimumDifferentSpells}");

            Console.WriteLine($"chest.RareChance {chest.RareChance}");
            Console.WriteLine($"chest.EpicChance {chest.EpicChance}");

            Console.WriteLine($"chest.LegendaryChance {chest.LegendaryChance}");

            float minimumRare      = (float)minimumSpellsCount / (float)chest.RareChance;
            float minimumEpic      = (float)minimumSpellsCount / (float)chest.EpicChance;
            float minimumLegendary = (float)minimumSpellsCount / (float)chest.LegendaryChance;

            Console.WriteLine($"minimumRare {minimumRare}");
            Console.WriteLine($"minimumEpic {minimumEpic}");
            Console.WriteLine($"minimumLegendary {minimumLegendary}");

            float rareCount      = minimumRare + player.RareChance;
            float epicCount      = minimumEpic + player.EpicChance;
            float legendaryCount = minimumLegendary + player.LegendaryChance;
            float commonCount    = minimumSpellsCount - rareCount - epicCount - legendaryCount;

            Console.WriteLine($"rareCount {rareCount}");
            Console.WriteLine($"epicCount {epicCount}");
            Console.WriteLine($"legendaryCount {legendaryCount}");
            Console.WriteLine($"commonCount {commonCount}");

            int differentRare      = CountDifferent(rareCount, minimumSpellsCount, minimumDifferentSpells);
            int differentEpic      = CountDifferent(epicCount, minimumSpellsCount, minimumDifferentSpells);
            int differentLegendary = CountDifferent(legendaryCount, minimumSpellsCount, minimumDifferentSpells);
            int differentCommon    = minimumDifferentSpells - differentRare - differentEpic - differentLegendary;

            Console.WriteLine($"differentRare {differentRare}");
            Console.WriteLine($"differentEpic {differentEpic}");
            Console.WriteLine($"differentLegendary {differentLegendary}");
            Console.WriteLine($"differentCommon {differentCommon}");

            int realSpellsCount = (int)(commonCount + rareCount + epicCount + legendaryCount);

            Dictionary <Rarity, List <Card> > candidates = Cards.Select(Arenas.Get("Arena9"));

            commonCount    -= GenerateCards(builder, candidates[common], differentCommon, (int)commonCount, random);
            rareCount      -= GenerateCards(builder, candidates[rare], differentRare, (int)rareCount, random);
            epicCount      -= GenerateCards(builder, candidates[epic], differentEpic, (int)epicCount, random);
            legendaryCount -= GenerateCards(builder, candidates[legendary], differentLegendary, (int)legendaryCount, random);

            player.RareChance      = rareCount;
            player.EpicChance      = epicCount;
            player.LegendaryChance = legendaryCount;

            int minGold = chest.MinGoldPerCard * realSpellsCount;
            int maxGold = chest.MaxGoldPerCard * realSpellsCount;

            builder.Gold = minGold + random.Next(maxGold - minGold);
            builder.Gems = 0; // TODO:

            return(builder.Build());
        }