コード例 #1
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));
        }
コード例 #2
0
        public bool Contains(RaceData rd)
        {
            foreach (HeroData hero in Heroes)
            {
                if (hero.Race == rd)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
ファイル: HeroGroup.cs プロジェクト: cmdrmander/Manderplan
        public bool Contains(RaceData rd)
        {
            bool flag;

            List <HeroData> .Enumerator enumerator = this.Heroes.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.Race != rd)
                    {
                        continue;
                    }
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
        }
コード例 #4
0
        public static RaceData GetRace(string name)
        {
            RaceData raceDatum;

            List <RaceData> .Enumerator enumerator = Sourcebook.Races.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    RaceData current = enumerator.Current;
                    if (current.Name != name)
                    {
                        continue;
                    }
                    raceDatum = current;
                    return(raceDatum);
                }
                return(null);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
        }
コード例 #5
0
 public HeroData(RaceData rd, ClassData cd)
 {
     Race  = rd;
     Class = cd;
 }
コード例 #6
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));
        }
コード例 #7
0
 public HeroData(RaceData rd, ClassData cd)
 {
     this.Race  = rd;
     this.Class = cd;
 }