예제 #1
0
    private void InitializeQuirks(RecruitUpgrade expUpgrade = null)
    {
        int positiveQuirkNumber = RandomSolver.Next(HeroClass.Generation.NumberOfPositiveQuirksMin,
                                                    HeroClass.Generation.NumberOfPositiveQuirksMax + 1);

        int negativeQuirkNumber = RandomSolver.Next(HeroClass.Generation.NumberOfNegativeQuirksMin,
                                                    HeroClass.Generation.NumberOfNegativeQuirksMax + 1);

        if (expUpgrade != null)
        {
            positiveQuirkNumber += expUpgrade.ExtraPositiveQuirks;
            negativeQuirkNumber += expUpgrade.ExtraNegativeQuirks;
        }

        for (int i = 0; i < positiveQuirkNumber; i++)
        {
            var availableQuirks = DarkestDungeonManager.Data.Quirks.Values.ToList().FindAll(newQuirk => newQuirk.IsPositive &&
                                                                                            quirkData.TrueForAll(quirkInfo => !quirkInfo.Quirk.IncompatibleQuirks.Contains(newQuirk.Id)) &&
                                                                                            quirkData.Find(quirkInfo => quirkInfo.Quirk == newQuirk) == null);
            var availableQuirk = availableQuirks[RandomSolver.Next(availableQuirks.Count)];
            quirkData.Add(new QuirkInfo(availableQuirk, false, 1, false));
            ApplyQuirk(availableQuirk);
        }

        for (int i = 0; i < negativeQuirkNumber; i++)
        {
            var availableQuirks = DarkestDungeonManager.Data.Quirks.Values.ToList().FindAll(newQuirk => !newQuirk.IsPositive &&
                                                                                            !newQuirk.IsDisease && quirkData.TrueForAll(quirkInfo => !quirkInfo.Quirk.IncompatibleQuirks.Contains(newQuirk.Id)) &&
                                                                                            quirkData.Find(quirkInfo => quirkInfo.Quirk == newQuirk) == null);
            var availableQuirk = availableQuirks[RandomSolver.Next(availableQuirks.Count)];
            quirkData.Add(new QuirkInfo(availableQuirk, false, 1, false));
            ApplyQuirk(availableQuirk);
        }
    }
예제 #2
0
    public void RestockBonus(List <int> rosterIds, Estate estate, string bonusClass, int bonusAmount)
    {
        EventHeroes.Clear();
        GraveIndexes.Clear();

        #region Clear unrecruited heroes
        if (EventHeroes.Count > 0)
        {
            for (int i = 0; i < EventHeroes.Count; i++)
            {
                if (rosterIds.Contains(EventHeroes[i].RosterId))
                {
                    Debug.LogError("Same id returned while restocking heroes.");
                }
                else
                {
                    rosterIds.Add(EventHeroes[i].RosterId);
                }

                estate.HeroPurchases.Remove(EventHeroes[i].RosterId);
            }
        }
        #endregion

        #region Create bonus recruits
        for (int i = 0; i < bonusAmount; i++)
        {
            RecruitUpgrade experienceUpgrade = null;

            if (CurrentRecruitMaxLevel > 0)
            {
                for (int j = 0; j <= RecruitExperienceUpgrades.Count - 1; j++)
                {
                    if (RecruitExperienceUpgrades[j].Level <= CurrentRecruitMaxLevel &&
                        RandomSolver.CheckSuccess(RecruitExperienceUpgrades[j].Chance))
                    {
                        experienceUpgrade = RecruitExperienceUpgrades[j];
                        break;
                    }
                }
            }
            int    id        = rosterIds[Random.Range(0, rosterIds.Count)];
            string heroClass = DarkestDungeonManager.Data.HeroClasses[bonusClass].StringId;
            string heroName  = LocalizationManager.GetString("hero_name_" + Random.Range(0, 556).ToString());
            var    newHero   = experienceUpgrade == null ?
                               new Hero(id, heroClass, heroName) :
                               new Hero(id, heroClass, heroName, experienceUpgrade);
            EventHeroes.Add(newHero);
            rosterIds.Remove(id);
            GeneratePurchaseInfo(newHero, estate);
        }
        #endregion
    }
예제 #3
0
    public Hero(int rosterId, string classId, string generatedName, RecruitUpgrade expUpgrade)
        : base(DarkestDungeonManager.Data.HeroClasses[classId], expUpgrade.Level)
    {
        InitializeHeroInfo(rosterId, generatedName, classId, expUpgrade.Level, 10);

        int equipLevel = DarkestDungeonManager.Data.UpgradeTrees[classId + ".weapon"].Upgrades.FindAll(upgrade =>
                                                                                                       upgrade is HeroUpgrade && ((HeroUpgrade)upgrade).PrerequisiteResolveLevel <= expUpgrade.Level).Count + 1;

        InitializeEquipment(equipLevel, equipLevel);
        InitializeQuirks(expUpgrade);
        InitializeCombatSkills(expUpgrade.ExtraCombatSkills);
        InitializeCampingSkills(expUpgrade.ExtraCampingSkills);
    }
예제 #4
0
    public void RestockHeroes(List <int> rosterIds, Estate estate)
    {
        var heroClasses = DarkestDungeonManager.Data.HeroClasses.Keys.ToList();

        Heroes.AddRange(EventHeroes);
        EventHeroes.Clear();
        GraveIndexes.Clear();
        #region Clear unrecruited heroes
        if (Heroes != null && Heroes.Count > 0)
        {
            for (int i = 0; i < Heroes.Count; i++)
            {
                if (rosterIds.Contains(Heroes[i].RosterId))
                {
                    Debug.LogError("Same id returned while restocking heroes.");
                }
                else
                {
                    rosterIds.Add(Heroes[i].RosterId);
                }

                estate.HeroPurchases.Remove(Heroes[i].RosterId);
            }
        }
        #endregion
        #region Create new recruits
        Heroes = new List <Hero>();
        if (DarkestDungeonManager.RaidManager.Quest != null && DarkestDungeonManager.RaidManager.Quest.Goal.Id == "tutorial_final_room")
        {
            for (int i = 0; i < firstHeroClasses.Length; i++)
            {
                int id      = rosterIds[Random.Range(0, rosterIds.Count)];
                var newHero = new Hero(id, firstHeroClasses[i],
                                       LocalizationManager.GetString("hero_name_" + Random.Range(0, 556).ToString()));
                Heroes.Add(newHero);
                rosterIds.Remove(id);
                GeneratePurchaseInfo(newHero, estate);
            }
        }
        else
        {
            for (int i = 0; i < RecruitSlots; i++)
            {
                RecruitUpgrade experienceUpgrade = null;

                if (CurrentRecruitMaxLevel > 0)
                {
                    for (int j = 0; j <= RecruitExperienceUpgrades.Count - 1; j++)
                    {
                        if (RecruitExperienceUpgrades[j].Level <= CurrentRecruitMaxLevel &&
                            RandomSolver.CheckSuccess(RecruitExperienceUpgrades[j].Chance))
                        {
                            experienceUpgrade = RecruitExperienceUpgrades[j];
                            break;
                        }
                    }
                }
                int    id        = rosterIds[Random.Range(0, rosterIds.Count)];
                string heroClass = heroClasses[Random.Range(0, DarkestDungeonManager.Data.HeroClasses.Count)];
                string heroName  = LocalizationManager.GetString("hero_name_" + Random.Range(0, 556).ToString());
                var    newHero   = experienceUpgrade == null ?
                                   new Hero(id, heroClass, heroName) :
                                   new Hero(id, heroClass, heroName, experienceUpgrade);
                Heroes.Add(newHero);
                rosterIds.Remove(id);
                GeneratePurchaseInfo(newHero, estate);
            }
        }
        #endregion
        #region Add recruits for minimum of one party
        int abominations = DarkestDungeonManager.Campaign.Heroes.FindAll(hero =>
                                                                         hero.Class == "abomination").Count + Heroes.FindAll(hero => hero.Class == "abomination").Count;
        int additionalHeroes = 4 - DarkestDungeonManager.Campaign.Heroes.Count - Heroes.Count + abominations;
        if (abominations > 3)
        {
            return;
        }
        for (int i = 0; i < additionalHeroes; i++)
        {
            RecruitUpgrade experienceUpgrade = null;

            if (CurrentRecruitMaxLevel > 0)
            {
                for (int j = 0; j <= RecruitExperienceUpgrades.Count - 1; j++)
                {
                    if (RecruitExperienceUpgrades[j].Level <= CurrentRecruitMaxLevel &&
                        RandomSolver.CheckSuccess(RecruitExperienceUpgrades[j].Chance))
                    {
                        experienceUpgrade = RecruitExperienceUpgrades[j];
                        break;
                    }
                }
            }
            int    id        = rosterIds[Random.Range(0, rosterIds.Count)];
            string heroClass = "abomination";
            while (heroClass == "abomination")
            {
                heroClass = heroClasses[Random.Range(0, DarkestDungeonManager.Data.HeroClasses.Count)];
            }

            string heroName = LocalizationManager.GetString("hero_name_" + Random.Range(0, 556).ToString());
            var    newHero  = experienceUpgrade == null ?
                              new Hero(id, heroClass, heroName) :
                              new Hero(id, heroClass, heroName, experienceUpgrade);
            Heroes.Add(newHero);
            rosterIds.Remove(id);
            GeneratePurchaseInfo(newHero, estate);
        }
        #endregion
    }