Exemple #1
0
        public static List <Pair <EncounterTemplateGroup, EncounterTemplate> > FindTemplates(Encounter enc, int level, bool include_individual)
        {
            build_template_list("", Difficulty.Random, level, include_individual);

            List <Pair <EncounterTemplateGroup, EncounterTemplate> > templates = new List <Pair <EncounterTemplateGroup, EncounterTemplate> >();

            foreach (EncounterTemplateGroup group in fTemplateGroups)
            {
                foreach (EncounterTemplate template in group.Templates)
                {
                    EncounterTemplate tmpl = template.Copy();

                    // Does this template fit what we've already got?
                    bool match = true;
                    foreach (EncounterSlot enc_slot in enc.Slots)
                    {
                        EncounterTemplateSlot template_slot = tmpl.FindSlot(enc_slot, level);

                        if (template_slot != null)
                        {
                            template_slot.Count -= enc_slot.CombatData.Count;
                            if (template_slot.Count <= 0)
                            {
                                tmpl.Slots.Remove(template_slot);
                            }
                        }
                        else
                        {
                            match = false;
                            break;
                        }
                    }
                    if (!match)
                    {
                        continue;
                    }

                    // Make sure there's at least one possible creature for each remaining slot
                    bool has_creatures = true;
                    foreach (EncounterTemplateSlot ets in tmpl.Slots)
                    {
                        bool found_creature = false;

                        int creature_level = level + ets.LevelAdjustment;
                        build_creature_list(creature_level, creature_level, null, null, true);
                        foreach (EncounterCard card in fCreatures)
                        {
                            if (ets.Match(card, level))
                            {
                                found_creature = true;
                                break;
                            }
                        }

                        if (!found_creature)
                        {
                            has_creatures = false;
                            break;
                        }
                    }
                    if (!has_creatures)
                    {
                        continue;
                    }

                    templates.Add(new Pair <EncounterTemplateGroup, EncounterTemplate>(group, tmpl));
                }
            }

            return(templates);
        }
Exemple #2
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);
        }