Ejemplo n.º 1
0
 public static void FillDeck(EncounterDeck deck)
 {
     EncounterBuilder.build_creature_list(deck.Level - 2, deck.Level + 5, null, null, false);
     if (EncounterBuilder.fCreatures.Count == 0)
     {
         return;
     }
     while (deck.Cards.Count < 50)
     {
         int           num  = Session.Random.Next() % EncounterBuilder.fCreatures.Count;
         EncounterCard item = EncounterBuilder.fCreatures[num];
         deck.Cards.Add(item);
     }
 }
Ejemplo n.º 2
0
        public static List <EncounterCard> FindCreatures(EncounterTemplateSlot slot, int party_level, string query)
        {
            int partyLevel = party_level + slot.LevelAdjustment;

            EncounterBuilder.build_creature_list(partyLevel, partyLevel, null, null, true);
            List <EncounterCard> encounterCards = new List <EncounterCard>();

            foreach (EncounterCard fCreature in EncounterBuilder.fCreatures)
            {
                if (!slot.Match(fCreature, party_level) || !EncounterBuilder.match(fCreature, query))
                {
                    continue;
                }
                encounterCards.Add(fCreature);
            }
            return(encounterCards);
        }
Ejemplo n.º 3
0
        public static List <Pair <EncounterTemplateGroup, EncounterTemplate> > FindTemplates(Encounter enc, int level, bool include_individual)
        {
            EncounterBuilder.build_template_list("", Difficulty.Random, level, include_individual);
            List <Pair <EncounterTemplateGroup, EncounterTemplate> > pairs = new List <Pair <EncounterTemplateGroup, EncounterTemplate> >();

            foreach (EncounterTemplateGroup fTemplateGroup in EncounterBuilder.fTemplateGroups)
            {
                foreach (EncounterTemplate template in fTemplateGroup.Templates)
                {
                    EncounterTemplate encounterTemplate = template.Copy();
                    bool flag = true;
                    foreach (EncounterSlot slot in enc.Slots)
                    {
                        EncounterTemplateSlot encounterTemplateSlot = encounterTemplate.FindSlot(slot, level);
                        if (encounterTemplateSlot == null)
                        {
                            flag = false;
                            break;
                        }
                        else
                        {
                            EncounterTemplateSlot count = encounterTemplateSlot;
                            count.Count = count.Count - slot.CombatData.Count;
                            if (encounterTemplateSlot.Count > 0)
                            {
                                continue;
                            }
                            encounterTemplate.Slots.Remove(encounterTemplateSlot);
                        }
                    }
                    if (!flag)
                    {
                        continue;
                    }
                    bool flag1 = true;
                    foreach (EncounterTemplateSlot slot1 in encounterTemplate.Slots)
                    {
                        bool flag2 = false;
                        int  num   = level + slot1.LevelAdjustment;
                        EncounterBuilder.build_creature_list(num, num, null, null, true);
                        foreach (EncounterCard fCreature in EncounterBuilder.fCreatures)
                        {
                            if (!slot1.Match(fCreature, level))
                            {
                                continue;
                            }
                            flag2 = true;
                            break;
                        }
                        if (flag2)
                        {
                            continue;
                        }
                        flag1 = false;
                        break;
                    }
                    if (!flag1)
                    {
                        continue;
                    }
                    pairs.Add(new Pair <EncounterTemplateGroup, EncounterTemplate>(fTemplateGroup, encounterTemplate));
                }
            }
            return(pairs);
        }
Ejemplo n.º 4
0
        public static EncounterDeck BuildDeck(int level, List <string> categories, List <string> keywords)
        {
            EncounterBuilder.build_creature_list(level - 2, level + 5, categories, keywords, false);
            if (EncounterBuilder.fCreatures.Count == 0)
            {
                return(null);
            }
            Dictionary <CardCategory, Pair <int, int> > cardCategories = new Dictionary <CardCategory, Pair <int, int> >();

            cardCategories[CardCategory.SoldierBrute] = new Pair <int, int>(0, 18);
            cardCategories[CardCategory.Skirmisher]   = new Pair <int, int>(0, 14);
            cardCategories[CardCategory.Minion]       = new Pair <int, int>(0, 5);
            cardCategories[CardCategory.Artillery]    = new Pair <int, int>(0, 5);
            cardCategories[CardCategory.Controller]   = new Pair <int, int>(0, 5);
            cardCategories[CardCategory.Lurker]       = new Pair <int, int>(0, 2);
            cardCategories[CardCategory.Solo]         = new Pair <int, int>(0, 1);
            Dictionary <Difficulty, Pair <int, int> > difficulties = new Dictionary <Difficulty, Pair <int, int> >();

            if (level < 3)
            {
                difficulties[Difficulty.Easy] = new Pair <int, int>(0, 37);
            }
            else
            {
                difficulties[Difficulty.Trivial] = new Pair <int, int>(0, 7);
                difficulties[Difficulty.Easy]    = new Pair <int, int>(0, 30);
            }
            difficulties[Difficulty.Moderate] = new Pair <int, int>(0, 8);
            difficulties[Difficulty.Hard]     = new Pair <int, int>(0, 5);
            difficulties[Difficulty.Extreme]  = new Pair <int, int>(0, 0);
            EncounterDeck encounterDeck = new EncounterDeck()
            {
                Level = level
            };
            int num = 0;

            do
            {
Label0:
                if (num >= 100)
                {
                    break;
                }
                num++;
                int             num1     = Session.Random.Next() % EncounterBuilder.fCreatures.Count;
                EncounterCard   item     = EncounterBuilder.fCreatures[num1];
                CardCategory    category = item.Category;
                Pair <int, int> pair     = cardCategories[category];
                if (pair.First < pair.Second)
                {
                    Difficulty      difficulty = item.GetDifficulty(level);
                    Pair <int, int> item1      = difficulties[difficulty];
                    if (item1.First < item1.Second)
                    {
                        encounterDeck.Cards.Add(item);
                        Pair <int, int> first = cardCategories[category];
                        first.First = first.First + 1;
                        Pair <int, int> first1 = difficulties[difficulty];
                        first1.First = first1.First + 1;
                    }
                    else
                    {
                        goto Label0;
                    }
                }
                else
                {
                    goto Label0;
                }
            }while (encounterDeck.Cards.Count != 50);
            EncounterBuilder.FillDeck(encounterDeck);
            return(encounterDeck);
        }
Ejemplo n.º 5
0
        public static bool Build(AutoBuildData data, Encounter enc, bool include_individual)
        {
            int num   = Math.Max(data.Level - 4, 1);
            int level = data.Level + 5;

            EncounterBuilder.build_creature_list(num, level, data.Categories, data.Keywords, true);
            if (EncounterBuilder.fCreatures.Count == 0)
            {
                return(false);
            }
            EncounterBuilder.build_template_list(data.Type, data.Difficulty, data.Level, include_individual);
            if (EncounterBuilder.fTemplateGroups.Count == 0)
            {
                return(false);
            }
            EncounterBuilder.build_trap_list(data.Level);
            EncounterBuilder.build_challenge_list(data.Level);
            int num1 = 0;

            while (num1 < 100)
            {
                num1++;
                int num2 = Session.Random.Next() % EncounterBuilder.fTemplateGroups.Count;
                EncounterTemplateGroup item = EncounterBuilder.fTemplateGroups[num2];
                int num3 = Session.Random.Next() % item.Templates.Count;
                EncounterTemplate encounterTemplate = item.Templates[num3];
                bool flag = true;
                List <EncounterSlot> encounterSlots = new List <EncounterSlot>();
                foreach (EncounterTemplateSlot slot in encounterTemplate.Slots)
                {
                    List <EncounterCard> encounterCards = new List <EncounterCard>();
                    foreach (EncounterCard fCreature in EncounterBuilder.fCreatures)
                    {
                        if (!slot.Match(fCreature, data.Level))
                        {
                            continue;
                        }
                        encounterCards.Add(fCreature);
                    }
                    if (encounterCards.Count != 0)
                    {
                        int           num4          = Session.Random.Next() % encounterCards.Count;
                        EncounterSlot encounterSlot = new EncounterSlot()
                        {
                            Card = encounterCards[num4]
                        };
                        for (int i = 0; i != slot.Count; i++)
                        {
                            CombatData combatDatum = new CombatData();
                            encounterSlot.CombatData.Add(combatDatum);
                        }
                        encounterSlots.Add(encounterSlot);
                    }
                    else
                    {
                        flag = false;
                        break;
                    }
                }
                if (!flag)
                {
                    continue;
                }
                enc.Slots = encounterSlots;
                enc.Traps.Clear();
                enc.SkillChallenges.Clear();
                switch (Session.Random.Next(12))
                {
                case 4:
                case 5:
                {
                    if (!EncounterBuilder.add_trap(enc))
                    {
                        break;
                    }
                    EncounterBuilder.remove_creature(enc);
                    break;
                }

                case 6:
                {
                    if (!EncounterBuilder.add_challenge(enc))
                    {
                        break;
                    }
                    EncounterBuilder.remove_creature(enc);
                    break;
                }

                case 7:
                {
                    if (!EncounterBuilder.add_lurker(enc))
                    {
                        break;
                    }
                    EncounterBuilder.remove_creature(enc);
                    break;
                }

                case 8:
                case 9:
                {
                    EncounterBuilder.add_trap(enc);
                    Difficulty difficulty = enc.GetDifficulty(data.Level, data.Size);
                    if (difficulty != Difficulty.Hard && difficulty != Difficulty.Extreme)
                    {
                        break;
                    }
                    EncounterBuilder.remove_creature(enc);
                    break;
                }

                case 10:
                {
                    Difficulty difficulty1 = enc.GetDifficulty(data.Level, data.Size);
                    if (difficulty1 == Difficulty.Hard || difficulty1 == Difficulty.Extreme)
                    {
                        EncounterBuilder.remove_creature(enc);
                    }
                    EncounterBuilder.add_challenge(enc);
                    break;
                }

                case 11:
                {
                    EncounterBuilder.add_lurker(enc);
                    Difficulty difficulty2 = enc.GetDifficulty(data.Level, data.Size);
                    if (difficulty2 != Difficulty.Hard && difficulty2 != Difficulty.Extreme)
                    {
                        break;
                    }
                    EncounterBuilder.remove_creature(enc);
                    break;
                }
                }
                while (enc.GetDifficulty(data.Level, data.Size) == Difficulty.Extreme && enc.Count > 1)
                {
                    EncounterBuilder.remove_creature(enc);
                }
                foreach (EncounterSlot slot1 in enc.Slots)
                {
                    slot1.SetDefaultDisplayNames();
                }
                return(true);
            }
            return(false);
        }