Exemple #1
0
        public static List <string> FindTemplateNames()
        {
            EncounterBuilder.build_template_list("", Difficulty.Random, -1, true);
            List <string> strs = new List <string>();

            foreach (EncounterTemplateGroup fTemplateGroup in EncounterBuilder.fTemplateGroups)
            {
                strs.Add(fTemplateGroup.Name);
            }
            strs.Sort();
            return(strs);
        }
Exemple #2
0
 private static bool match(EncounterCard card, string query)
 {
     string[] strArrays = query.ToLower().Split(new char[0]);
     for (int i = 0; i < (int)strArrays.Length; i++)
     {
         if (!EncounterBuilder.match_token(card, strArrays[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #3
0
 private static void build_creature_list(int min_level, int max_level, List <string> categories, List <string> keywords, bool include_templates)
 {
     EncounterBuilder.fCreatures.Clear();
     foreach (Creature creature in Session.Creatures)
     {
         if (creature == null || min_level != -1 && creature.Level < min_level || max_level != -1 && creature.Level > max_level || categories != null && categories.Count != 0 && !categories.Contains(creature.Category))
         {
             continue;
         }
         if (keywords != null && keywords.Count != 0)
         {
             bool flag = false;
             foreach (string keyword in keywords)
             {
                 if (!creature.Phenotype.ToLower().Contains(keyword.ToLower()))
                 {
                     continue;
                 }
                 flag = true;
                 break;
             }
             if (!flag)
             {
                 continue;
             }
         }
         EncounterCard encounterCard = new EncounterCard()
         {
             CreatureID = creature.ID
         };
         EncounterBuilder.fCreatures.Add(encounterCard);
         if (!include_templates)
         {
             continue;
         }
         EncounterBuilder.add_templates(creature);
     }
     foreach (CustomCreature customCreature in Session.Project.CustomCreatures)
     {
         EncounterCard encounterCard1 = new EncounterCard()
         {
             CreatureID = customCreature.ID
         };
         EncounterBuilder.fCreatures.Add(encounterCard1);
         if (!include_templates)
         {
             continue;
         }
         EncounterBuilder.add_templates(customCreature);
     }
 }
Exemple #4
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);
     }
 }
Exemple #5
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);
        }
        private static Encounter get_encounter(Map map, MapArea ma, AutoBuildData data)
        {
            object[]  objArray;
            Encounter encounter = new Encounter()
            {
                MapID     = map.ID,
                MapAreaID = ma.ID
            };

            EncounterBuilder.Build(data, encounter, false);
            if (encounter.GetDifficulty(Session.Project.Party.Level, Session.Project.Party.Size) != Difficulty.Extreme)
            {
                switch (Session.Random.Next() % 6)
                {
                case 0:
                case 1:
                case 3:
                {
                    Trap trap = DelveBuilder.select_trap(data);
                    if (trap == null)
                    {
                        break;
                    }
                    encounter.Traps.Add(trap);
                    break;
                }

                case 4:
                {
                    SkillChallenge skillChallenge = DelveBuilder.select_challenge(data);
                    if (skillChallenge == null)
                    {
                        break;
                    }
                    encounter.SkillChallenges.Add(skillChallenge);
                    break;
                }
                }
            }
            List <Rectangle> rectangles = new List <Rectangle>();

            foreach (TileData tile in map.Tiles)
            {
                Tile tile1 = Session.FindTile(tile.TileID, SearchType.Global);
                int  num   = (tile.Rotations % 2 == 0 ? tile1.Size.Width : tile1.Size.Height);
                Size size  = new Size(num, (tile.Rotations % 2 == 0 ? tile1.Size.Height : tile1.Size.Width));
                rectangles.Add(new Rectangle(tile.Location, size));
            }
            Dictionary <Point, bool> points = new Dictionary <Point, bool>();

            for (int i = ma.Region.Left; i != ma.Region.Right; i++)
            {
                for (int j = ma.Region.Top; j != ma.Region.Bottom; j++)
                {
                    Point point = new Point(i, j);
                    bool  flag  = false;
                    foreach (Rectangle rectangle in rectangles)
                    {
                        if (!rectangle.Contains(point))
                        {
                            continue;
                        }
                        flag = true;
                        break;
                    }
                    points[point] = flag;
                }
            }
            foreach (EncounterSlot slot in encounter.Slots)
            {
                ICreature creature = Session.FindCreature(slot.Card.CreatureID, SearchType.Global);
                int       size1    = Creature.GetSize(creature.Size);
                foreach (CombatData combatDatum in slot.CombatData)
                {
                    List <Point> points1 = new List <Point>();
                    for (int k = ma.Region.Left; k != ma.Region.Right; k++)
                    {
                        for (int l = ma.Region.Top; l != ma.Region.Bottom; l++)
                        {
                            Point point1 = new Point(k, l);
                            bool  flag1  = true;
                            for (int m = point1.X; m != point1.X + size1; m++)
                            {
                                for (int n = point1.Y; n != point1.Y + size1; n++)
                                {
                                    Point point2 = new Point(m, n);
                                    if (!points.ContainsKey(point2) || !points[point2])
                                    {
                                        flag1 = false;
                                    }
                                }
                            }
                            if (flag1)
                            {
                                points1.Add(point1);
                            }
                        }
                    }
                    if (points1.Count == 0)
                    {
                        continue;
                    }
                    int   num1 = Session.Random.Next() % points1.Count;
                    Point item = points1[num1];
                    combatDatum.Location = item;
                    for (int o = item.X; o != item.X + size1; o++)
                    {
                        for (int p = item.Y; p != item.Y + size1; p++)
                        {
                            points[new Point(o, p)] = false;
                        }
                    }
                }
            }
            encounter.SetStandardEncounterNotes();
            EncounterNote encounterNote = encounter.FindNote("Illumination");

            if (encounterNote != null)
            {
                switch (Session.Random.Next(6))
                {
                case 0:
                case 1:
                case 2:
                {
                    encounterNote.Contents = "The area is in bright light.";
                    break;
                }

                case 3:
                case 4:
                {
                    encounterNote.Contents = "The area is in dim light.";
                    break;
                }

                case 5:
                {
                    encounterNote.Contents = "None.";
                    break;
                }
                }
            }
            EncounterNote item1 = encounter.FindNote("Victory Conditions");

            if (item1 != null)
            {
                List <string> strs  = new List <string>();
                List <string> strs1 = new List <string>();
                bool          flag2 = false;
                int           count = 0;
                foreach (EncounterSlot encounterSlot in encounter.Slots)
                {
                    if (encounterSlot.CombatData.Count == 1 && (encounterSlot.Card.Leader || encounterSlot.Card.Flag == RoleFlag.Elite || encounterSlot.Card.Flag == RoleFlag.Solo))
                    {
                        strs1.Add(encounterSlot.CombatData[0].DisplayName);
                    }
                    ICreature creature1 = Session.FindCreature(encounterSlot.Card.CreatureID, SearchType.Global);
                    if (creature1 == null)
                    {
                        continue;
                    }
                    if (!(creature1.Role is Minion))
                    {
                        count += encounterSlot.CombatData.Count;
                    }
                    else
                    {
                        flag2 = true;
                    }
                }
                if (strs1.Count != 0)
                {
                    int    num2 = Session.Random.Next() % strs1.Count;
                    string str  = strs1[num2];
                    if (Session.Random.Next() % 12 == 0)
                    {
                        strs.Add(string.Concat("Defeat ", str, "."));
                        strs.Add(string.Concat("Capture ", str, "."));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        int num3 = Session.Dice(2, 4);
                        objArray = new object[] { "The party must defeat ", str, " within ", num3, " rounds." };
                        strs.Add(string.Concat(objArray));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        int num4 = Session.Dice(2, 4);
                        objArray = new object[] { "After ", num4, ", ", str, " will flee or surrender." };
                        strs.Add(string.Concat(objArray));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        int num5 = 10 * Session.Dice(1, 4);
                        objArray = new object[] { "At ", num5, "% HP, ", str, " will flee or surrender." };
                        strs.Add(string.Concat(objArray));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        strs.Add(string.Concat("The party must obtain an item from ", str, "."));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        strs.Add(string.Concat("Defeat ", str, " by destroying a guarded object in the area."));
                    }
                    if (flag2)
                    {
                        strs.Add(string.Concat("Minions will flee or surrender when ", str, " is defeated."));
                    }
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    int num6 = 2 + Session.Random.Next() % 4;
                    strs.Add(string.Concat("The party must defeat their opponents within ", num6, " rounds."));
                }
                if (flag2 && Session.Random.Next() % 12 == 0)
                {
                    int num7 = 2 + Session.Random.Next() % 4;
                    strs.Add(string.Concat("The party must defend a certain area from ", num7, " waves of minions."));
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    int num8 = 2 + Session.Random.Next() % 4;
                    strs.Add(string.Concat("At least one character must get to a certain area and stay there for ", num8, " consecutive rounds."));
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    int num9 = 2 + Session.Random.Next() % 4;
                    strs.Add(string.Concat("The party must leave the area within ", num9, " rounds."));
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must keep the enemy away from a certain area for the duration of the encounter.");
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must escort an NPC safely through the encounter area.");
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must rescue an NPC from their opponents.");
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must avoid contact with the enemy in this area.");
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must attack and destroy a feature of the area.");
                }
                if (count > 1 && Session.Random.Next() % 12 == 0)
                {
                    int num10 = 1 + Session.Random.Next(count);
                    strs.Add(string.Concat("The party must defeat ", num10, " non-minion opponents."));
                }
                if (strs.Count != 0)
                {
                    int num11 = Session.Random.Next() % strs.Count;
                    item1.Contents = strs[num11];
                }
            }
            return(encounter);
        }
Exemple #7
0
        static Encounter get_encounter(Map map, MapArea ma, AutoBuildData data)
        {
            // Set up the encounter
            Encounter enc = new Encounter();

            enc.MapID     = map.ID;
            enc.MapAreaID = ma.ID;
            EncounterBuilder.Build(data, enc, false);

            Difficulty diff = enc.GetDifficulty(Session.Project.Party.Level, Session.Project.Party.Size);

            if (diff != Difficulty.Extreme)
            {
                // Add a trap or skill challenge
                switch (Session.Random.Next() % 6)
                {
                case 0:
                case 1:
                case 3:
                    // Add a trap
                    Trap t = select_trap(data);
                    if (t != null)
                    {
                        enc.Traps.Add(t);
                    }
                    break;

                case 4:
                    // Add a skill challenge
                    SkillChallenge sc = select_challenge(data);
                    if (sc != null)
                    {
                        enc.SkillChallenges.Add(sc);
                    }
                    break;

                default:
                    // Don't add anything else
                    break;
                }
            }

            // Make matrix of tile squares
            List <Rectangle> tiles = new List <Rectangle>();

            foreach (TileData td in map.Tiles)
            {
                Tile t      = Session.FindTile(td.TileID, SearchType.Global);
                int  width  = (td.Rotations % 2 == 0) ? t.Size.Width : t.Size.Height;
                int  height = (td.Rotations % 2 == 0) ? t.Size.Height : t.Size.Width;
                Size sz     = new Size(width, height);

                Rectangle rect = new Rectangle(td.Location, sz);
                tiles.Add(rect);
            }
            Dictionary <Point, bool> matrix = new Dictionary <Point, bool>();

            for (int x = ma.Region.Left; x != ma.Region.Right; ++x)
            {
                for (int y = ma.Region.Top; y != ma.Region.Bottom; ++y)
                {
                    Point pt = new Point(x, y);

                    // Is there a tile at this location?
                    bool open = false;
                    foreach (Rectangle rect in tiles)
                    {
                        if (rect.Contains(pt))
                        {
                            open = true;
                            break;
                        }
                    }
                    matrix[pt] = open;
                }
            }

            // Place creatures on the map
            foreach (EncounterSlot slot in enc.Slots)
            {
                ICreature creature = Session.FindCreature(slot.Card.CreatureID, SearchType.Global);
                int       size     = Creature.GetSize(creature.Size);

                foreach (CombatData cd in slot.CombatData)
                {
                    // Find candidate points
                    List <Point> candidates = new List <Point>();
                    for (int x = ma.Region.Left; x != ma.Region.Right; ++x)
                    {
                        for (int y = ma.Region.Top; y != ma.Region.Bottom; ++y)
                        {
                            Point pt = new Point(x, y);

                            // Is this location free?
                            bool all_open = true;
                            for (int dx = pt.X; dx != pt.X + size; ++dx)
                            {
                                for (int dy = pt.Y; dy != pt.Y + size; ++dy)
                                {
                                    Point loc = new Point(dx, dy);
                                    if ((!matrix.ContainsKey(loc)) || (!matrix[loc]))
                                    {
                                        all_open = false;
                                    }
                                }
                            }

                            if (all_open)
                            {
                                candidates.Add(pt);
                            }
                        }
                    }

                    if (candidates.Count != 0)
                    {
                        int   index = Session.Random.Next() % candidates.Count;
                        Point loc   = candidates[index];

                        // Place creature
                        cd.Location = loc;

                        // This space is now occupied
                        for (int x = loc.X; x != loc.X + size; ++x)
                        {
                            for (int y = loc.Y; y != loc.Y + size; ++y)
                            {
                                Point pt = new Point(x, y);
                                matrix[pt] = false;
                            }
                        }
                    }
                }
            }

            // Set up notes

            enc.SetStandardEncounterNotes();
            EncounterNote light_note = enc.FindNote("Illumination");

            if (light_note != null)
            {
                int n = Session.Random.Next(6);
                switch (n)
                {
                case 0:
                case 1:
                case 2:
                    light_note.Contents = "The area is in bright light.";
                    break;

                case 3:
                case 4:
                    light_note.Contents = "The area is in dim light.";
                    break;

                case 5:
                    light_note.Contents = "None.";
                    break;
                }
            }

            EncounterNote victory_note = enc.FindNote("Victory Conditions");

            if (victory_note != null)
            {
                List <string> candidates = new List <string>();

                List <string> leaders     = new List <string>();
                bool          has_minions = false;
                int           non_minions = 0;
                foreach (EncounterSlot slot in enc.Slots)
                {
                    if (slot.CombatData.Count == 1)
                    {
                        if ((slot.Card.Leader) || (slot.Card.Flag == RoleFlag.Elite) || (slot.Card.Flag == RoleFlag.Solo))
                        {
                            leaders.Add(slot.CombatData[0].DisplayName);
                        }
                    }

                    ICreature c = Session.FindCreature(slot.Card.CreatureID, SearchType.Global);
                    if (c != null)
                    {
                        if (c.Role is Minion)
                        {
                            has_minions = true;
                        }
                        else
                        {
                            non_minions += slot.CombatData.Count;
                        }
                    }
                }

                if (leaders.Count != 0)
                {
                    int    index  = Session.Random.Next() % leaders.Count;
                    string leader = leaders[index];

                    if (Session.Random.Next() % 12 == 0)
                    {
                        candidates.Add("Defeat " + leader + ".");
                        candidates.Add("Capture " + leader + ".");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        int rounds = Session.Dice(2, 4);
                        candidates.Add("The party must defeat " + leader + " within " + rounds + " rounds.");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        int rounds = Session.Dice(2, 4);
                        candidates.Add("After " + rounds + ", " + leader + " will flee or surrender.");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        int hp = 10 * Session.Dice(1, 4);
                        candidates.Add("At " + hp + "% HP, " + leader + " will flee or surrender.");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        candidates.Add("The party must obtain an item from " + leader + ".");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        candidates.Add("Defeat " + leader + " by destroying a guarded object in the area.");
                    }

                    if (has_minions)
                    {
                        candidates.Add("Minions will flee or surrender when " + leader + " is defeated.");
                    }
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    int rounds = 2 + Session.Random.Next() % 4;
                    candidates.Add("The party must defeat their opponents within " + rounds + " rounds.");
                }

                if ((has_minions) && (Session.Random.Next() % 12 == 0))
                {
                    int waves = 2 + Session.Random.Next() % 4;
                    candidates.Add("The party must defend a certain area from " + waves + " waves of minions.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    int rounds = 2 + Session.Random.Next() % 4;
                    candidates.Add("At least one character must get to a certain area and stay there for " + rounds + " consecutive rounds.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    int rounds = 2 + Session.Random.Next() % 4;
                    candidates.Add("The party must leave the area within " + rounds + " rounds.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must keep the enemy away from a certain area for the duration of the encounter.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must escort an NPC safely through the encounter area.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must rescue an NPC from their opponents.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must avoid contact with the enemy in this area.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must attack and destroy a feature of the area.");
                }

                if (non_minions > 1)
                {
                    if (Session.Random.Next() % 12 == 0)
                    {
                        int n = 1 + Session.Random.Next(non_minions);
                        candidates.Add("The party must defeat " + n + " non-minion opponents.");
                    }
                }

                if (candidates.Count != 0)
                {
                    // Select an option
                    int index = Session.Random.Next() % candidates.Count;
                    victory_note.Contents = candidates[index];
                }
            }

            return(enc);
        }
Exemple #8
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);
        }
Exemple #9
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);
        }
Exemple #10
0
 private static void build_template_list(string group_name, Difficulty diff, int level, bool include_individual)
 {
     EncounterBuilder.fTemplateGroups.Clear();
     EncounterBuilder.build_template_battlefield_control();
     EncounterBuilder.build_template_commander_and_troops();
     EncounterBuilder.build_template_double_line();
     EncounterBuilder.build_template_dragons_den();
     EncounterBuilder.build_template_grand_melee();
     EncounterBuilder.build_template_wolf_pack();
     if (include_individual)
     {
         EncounterBuilder.build_template_duel();
     }
     if (group_name != "")
     {
         List <EncounterTemplateGroup> encounterTemplateGroups = new List <EncounterTemplateGroup>();
         foreach (EncounterTemplateGroup fTemplateGroup in EncounterBuilder.fTemplateGroups)
         {
             if (fTemplateGroup.Name == group_name)
             {
                 continue;
             }
             encounterTemplateGroups.Add(fTemplateGroup);
         }
         foreach (EncounterTemplateGroup encounterTemplateGroup in encounterTemplateGroups)
         {
             EncounterBuilder.fTemplateGroups.Remove(encounterTemplateGroup);
         }
     }
     if (diff != Difficulty.Random)
     {
         List <EncounterTemplateGroup> encounterTemplateGroups1 = new List <EncounterTemplateGroup>();
         foreach (EncounterTemplateGroup fTemplateGroup1 in EncounterBuilder.fTemplateGroups)
         {
             List <EncounterTemplate> encounterTemplates = new List <EncounterTemplate>();
             foreach (EncounterTemplate template in fTemplateGroup1.Templates)
             {
                 if (template.Difficulty == diff)
                 {
                     continue;
                 }
                 encounterTemplates.Add(template);
             }
             foreach (EncounterTemplate encounterTemplate in encounterTemplates)
             {
                 fTemplateGroup1.Templates.Remove(encounterTemplate);
             }
             if (fTemplateGroup1.Templates.Count != 0)
             {
                 continue;
             }
             encounterTemplateGroups1.Add(fTemplateGroup1);
         }
         foreach (EncounterTemplateGroup encounterTemplateGroup1 in encounterTemplateGroups1)
         {
             EncounterBuilder.fTemplateGroups.Remove(encounterTemplateGroup1);
         }
     }
     if (level != -1)
     {
         List <EncounterTemplateGroup> encounterTemplateGroups2 = new List <EncounterTemplateGroup>();
         foreach (EncounterTemplateGroup fTemplateGroup2 in EncounterBuilder.fTemplateGroups)
         {
             List <EncounterTemplate> encounterTemplates1 = new List <EncounterTemplate>();
             foreach (EncounterTemplate template1 in fTemplateGroup2.Templates)
             {
                 bool flag = true;
                 foreach (EncounterTemplateSlot slot in template1.Slots)
                 {
                     if (level + slot.LevelAdjustment >= 1)
                     {
                         continue;
                     }
                     flag = false;
                     break;
                 }
                 if (flag)
                 {
                     continue;
                 }
                 encounterTemplates1.Add(template1);
             }
             foreach (EncounterTemplate encounterTemplate1 in encounterTemplates1)
             {
                 fTemplateGroup2.Templates.Remove(encounterTemplate1);
             }
             if (fTemplateGroup2.Templates.Count != 0)
             {
                 continue;
             }
             encounterTemplateGroups2.Add(fTemplateGroup2);
         }
         foreach (EncounterTemplateGroup encounterTemplateGroup2 in encounterTemplateGroups2)
         {
             EncounterBuilder.fTemplateGroups.Remove(encounterTemplateGroup2);
         }
     }
 }
Exemple #11
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);
        }