예제 #1
0
        public static HeroData Create()
        {
            int       num  = Session.Random.Next() % Sourcebook.Classes.Count;
            ClassData item = Sourcebook.Classes[num];
            int       num1 = Session.Random.Next() % Sourcebook.Races.Count;

            return(new HeroData(Sourcebook.Races[num1], item));
        }
예제 #2
0
        public static HeroData Create()
        {
            // Select a class candidate
            int       class_index    = Session.Random.Next() % Sourcebook.Classes.Count;
            ClassData selected_class = Sourcebook.Classes[class_index];

            // Select a race candidate
            int      race_index    = Session.Random.Next() % Sourcebook.Races.Count;
            RaceData selected_race = Sourcebook.Races[race_index];

            return(new HeroData(selected_race, selected_class));
        }
예제 #3
0
        public bool Contains(ClassData cd)
        {
            foreach (HeroData hero in Heroes)
            {
                if (hero.Class == cd)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
        public bool Contains(ClassData cd)
        {
            bool flag;

            List <HeroData> .Enumerator enumerator = this.Heroes.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.Class != cd)
                    {
                        continue;
                    }
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
        }
예제 #5
0
        public static ClassData GetClass(string name)
        {
            ClassData classDatum;

            List <ClassData> .Enumerator enumerator = Sourcebook.Classes.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    ClassData current = enumerator.Current;
                    if (current.Name != name)
                    {
                        continue;
                    }
                    classDatum = current;
                    return(classDatum);
                }
                return(null);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
        }
예제 #6
0
 public HeroData(RaceData rd, ClassData cd)
 {
     Race  = rd;
     Class = cd;
 }
예제 #7
0
        public HeroData Suggest()
        {
            // What type of class do we need?
            List <PowerSource>    power_sources = RequiredPowerSources;
            List <PrimaryAbility> abilities     = RequiredAbilities;
            List <HeroRoleType>   roles         = RequiredRoles;

            // Make up a class candidate list
            List <ClassData> class_candidates = Sourcebook.Filter(power_sources, abilities, roles);

            if (class_candidates.Count == 0)
            {
                // Try without the ability score restriction
                class_candidates = Sourcebook.Filter(power_sources, new List <PrimaryAbility>(), roles);

                if (class_candidates.Count == 0)
                {
                    return(null);
                }
            }

            // Remove classes we already have
            List <ClassData> obsolete_classes = new List <ClassData>();

            foreach (ClassData cd in class_candidates)
            {
                if (Contains(cd))
                {
                    obsolete_classes.Add(cd);
                }
            }
            if (obsolete_classes.Count != class_candidates.Count)
            {
                foreach (ClassData cd in obsolete_classes)
                {
                    class_candidates.Remove(cd);
                }
            }

            // Select a class candidate
            int       class_index    = Session.Random.Next() % class_candidates.Count;
            ClassData selected_class = class_candidates[class_index];

            // Make up a race candidate list
            List <RaceData> race_candidates = Sourcebook.Filter(selected_class.KeyAbility);

            if (race_candidates.Count == 0)
            {
                return(null);
            }

            // Remove races we already have
            List <RaceData> obsolete_races = new List <RaceData>();

            foreach (RaceData rd in race_candidates)
            {
                if (Contains(rd))
                {
                    obsolete_races.Add(rd);
                }
            }
            if (obsolete_races.Count != race_candidates.Count)
            {
                foreach (RaceData rd in obsolete_races)
                {
                    race_candidates.Remove(rd);
                }
            }

            // Select a race candidate
            int      race_index    = Session.Random.Next() % race_candidates.Count;
            RaceData selected_race = race_candidates[race_index];

            return(new HeroData(selected_race, selected_class));
        }
예제 #8
0
 public HeroData(RaceData rd, ClassData cd)
 {
     this.Race  = rd;
     this.Class = cd;
 }
예제 #9
0
        public HeroData Suggest()
        {
            List <PowerSource>    requiredPowerSources = this.RequiredPowerSources;
            List <PrimaryAbility> requiredAbilities    = this.RequiredAbilities;
            List <HeroRoleType>   requiredRoles        = this.RequiredRoles;
            List <ClassData>      classDatas           = Sourcebook.Filter(requiredPowerSources, requiredAbilities, requiredRoles);

            if (classDatas.Count == 0)
            {
                classDatas = Sourcebook.Filter(requiredPowerSources, new List <PrimaryAbility>(), requiredRoles);
                if (classDatas.Count == 0)
                {
                    return(null);
                }
            }
            List <ClassData> classDatas1 = new List <ClassData>();

            foreach (ClassData classDatum in classDatas)
            {
                if (!this.Contains(classDatum))
                {
                    continue;
                }
                classDatas1.Add(classDatum);
            }
            if (classDatas1.Count != classDatas.Count)
            {
                foreach (ClassData classData in classDatas1)
                {
                    classDatas.Remove(classData);
                }
            }
            int             num       = Session.Random.Next() % classDatas.Count;
            ClassData       item      = classDatas[num];
            List <RaceData> raceDatas = Sourcebook.Filter(item.KeyAbility);

            if (raceDatas.Count == 0)
            {
                return(null);
            }
            List <RaceData> raceDatas1 = new List <RaceData>();

            foreach (RaceData raceDatum in raceDatas)
            {
                if (!this.Contains(raceDatum))
                {
                    continue;
                }
                raceDatas1.Add(raceDatum);
            }
            if (raceDatas1.Count != raceDatas.Count)
            {
                foreach (RaceData raceData in raceDatas1)
                {
                    raceDatas.Remove(raceData);
                }
            }
            int num1 = Session.Random.Next() % raceDatas.Count;

            return(new HeroData(raceDatas[num1], item));
        }