コード例 #1
0
ファイル: Generator.cs プロジェクト: iliakonnov/AdventureBot
        private static ResultStats Shuffle(RaceStats stats, Random random)
        {
            string artifact = null;

            if (stats.Artifact)
            {
                var manager = ObjectManager <IItem> .Instance.Get <ItemManager>();

                var items = manager.Items()
                            .Where(i => manager.Get(i.Identificator)?.Effect != null)
                            .ToList();
                artifact = items[random.Next(0, items.Count)].Identificator;
            }

            return(new ResultStats
            {
                Name = $"{string.Join(" ", stats.Modifiers)} {stats.Name}",
                Damage = Shuffle(stats.Damage, random),
                Health = Shuffle(stats.Health, random),
                Defence = Shuffle(LevelToNum(stats.Defence, 10, 25, 40), random),
                DefencedPlaces = stats.DefencedPlaces,
                Gold = Shuffle(LevelToNum(stats.Gold, 30, 150, 300), random),
                ArtifactId = artifact,
                KnowledgeGroup = stats.KnowledgeGroup,
                KnowledgeMinimal = Shuffle(LevelToNum(stats.KnowledgeLevel, 10, 30, 60), random),
                KnowledgeRequired = Shuffle(LevelToNum(stats.KnowledgeLevel, 20, 50, 70), random)
            });
        }
コード例 #2
0
ファイル: Generator.cs プロジェクト: iliakonnov/AdventureBot
        private static void Mutate(RaceStats stats, Random random)
        {
            var mutated = new HashSet <MonsterProperty>();

            for (var i = 0; i < random.Next(1, 4); i++)
            {
                MonsterProperty prop;
                do
                {
                    prop = (MonsterProperty)random.Next(0, 7);
                } while (mutated.Contains(prop));

                mutated.Add(prop);
                Mutate(stats, prop, random);
            }
        }
コード例 #3
0
ファイル: Generator.cs プロジェクト: iliakonnov/AdventureBot
        private static void Mutate(RaceStats stats, MonsterProperty property, Random random)
        {
            switch (property)
            {
            case MonsterProperty.Artifact:
            {
                stats.Mutate(random.NextDouble() < 0.5, property);
                break;
            }

            case MonsterProperty.DefenceLevel:
            case MonsterProperty.KnowledgeLevel:
            case MonsterProperty.Gold:
            {
                stats.Mutate((Level)random.Next(0, 3), property);
                break;
            }

            case MonsterProperty.KnowledgeGroup:
            {
                stats.Mutate((Knowledge)random.Next(0, 2), property);
                break;
            }

            case MonsterProperty.Damage:
            {
                stats.Mutate(stats.Damage * ((decimal)random.NextDouble() - 0.5M + 1), property);
                break;
            }

            case MonsterProperty.Health:
            {
                stats.Mutate(stats.Health * ((decimal)random.NextDouble() - 0.5M + 1), property);
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(property), property, null);
            }
            }
        }