Exemplo n.º 1
0
        internal static void TestDefaultLevelPlan2()
        {
            var            defaultClass   = ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"); //Alchemist
            var            defaultBuild   = defaultClass.DefaultBuild;
            var            addClassLevels = defaultBuild.GetComponent <AddClassLevels>();
            var            targetPoints   = Main.settings.DefaultPointBuy25 ? 25 : 20;
            var            stats          = defaultBuild.GetComponents <StatsDistributionPreset>().FirstOrDefault(sd => sd.TargetPoints == targetPoints);
            UnitEntityData unitData       = Main.settings.DefaultPointBuy25 ?
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.DefaultPlayerCharacter) :
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.CustomCompanion);
            var unit = unitData.Descriptor;

            LogUnit("BlankUnit.txt", unit);
            var  levelUpController = TestLevelUpController.Start(unit: unit, instantCommit: true, unitJson: null, onSuccess: null, mode: LevelUpState.CharBuildMode.CharGen);
            bool success           = true;

            success = levelUpController.SelectPortrait(ResourcesLibrary.GetBlueprints <BlueprintPortrait>().First());
            if (!success)
            {
                Main.Log("Error selecting portrait");
            }
            success = levelUpController.SelectGender(Gender.Male);
            if (!success)
            {
                Main.Log("Error selecting gender");
            }
            var race = ResourcesLibrary.TryGetBlueprint <BlueprintRace>("0a5d473ead98b0646b94495af250fdc4"); //Human

            race    = ResourcesLibrary.TryGetBlueprint <BlueprintRace>("5c4e42124dc2b4647af6e36cf2590500");  //Tiefling
            success = levelUpController.SelectRace(race);
            if (!success)
            {
                Main.Log("Error selecting race");
            }
            levelUpController.State.SelectedClass = ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721");
            ApplyDefaultBuild(levelUpController);
            //success = levelUpController.SelectClass(ResourcesLibrary.TryGetBlueprint<BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"));
            //if (!success) Main.Log("Error selecting class");
            //levelUpController.ApplyClassMechanics();
            //levelUpController.ApplySpellbook();
            //levelUpController.SelectDefaultClassBuild();

            var levelPlanHolder = new LevelPlanHolder();

            for (int i = 0; i < 20; i++)
            {
                var plan = unit.Progression.GetLevelPlan(i + 1);
                levelPlanHolder.LevelPlanData[i] = plan;
            }
            LevelPlanManager.CurrentLevelPlan = levelPlanHolder;

            var token = UnitSerialization.Serialize(unit);

            File.WriteAllText("TestDefaultAlch.json", token.ToString());
            LogUnit("TestDefaultAlch.txt", unit);
        }
Exemplo n.º 2
0
        static void ApplyDefaultBuild(TestLevelUpController controller)
        {
            var           defaultBuild = controller.State.SelectedClass.DefaultBuild;
            BlueprintRace race         = controller.Preview.Progression.Race;

            controller.Unit.Ensure <LevelUpPlanUnitHolder>();
            controller.Unit.Progression.DropLevelPlans();
            controller.Unit.AddFact(defaultBuild, null, null);
            LevelPlanData levelPlan = controller.Unit.Progression.GetLevelPlan(controller.State.NextLevel);
        }
 public bool SelectDefaultClassBuild()
 {
     if (!this.HasNextLevelPlan)
     {
         return(false);
     }
     if (!this.State.IsFirstLevel)
     {
         this.RemoveAction <SelectClass>(null);
         bool flag = this.ApplyLevelUpPlan(true);
         if (flag)
         {
             this.m_PlanChanged = false;
             this.UpdateDifficulty();
             return(true);
         }
         return(false);
     }
     else
     {
         if (this.State.SelectedClass == null)
         {
             return(false);
         }
         BlueprintUnitFact defaultBuild = this.State.SelectedClass.DefaultBuild;
         if (defaultBuild == null)
         {
             return(false);
         }
         BlueprintRace race = this.Preview.Progression.Race;
         if (race == null || this.State.CanSelectRace)
         {
             return(false);
         }
         bool result;
         try
         {
             using (new DefaultBuildData(race))
             {
                 this.Unit.Ensure <LevelUpPlanUnitHolder>();
                 this.Unit.Progression.DropLevelPlans();
                 this.Unit.AddFact(defaultBuild, null, null);
                 LevelPlanData levelPlan = this.Unit.Progression.GetLevelPlan(this.State.NextLevel);
                 if (levelPlan == null)
                 {
                     result = false;
                 }
                 else
                 {
                     this.m_RecalculatePreview = true;
                     this.LevelUpActions.RemoveAll((ILevelUpAction a) => TestLevelUpController.IsDefaultBuildPriority(a.Priority));
                     this.LevelUpActions.AddRange(from a in levelPlan.Actions
                                                  where TestLevelUpController.IsDefaultBuildPriority(a.Priority)
                                                  select a);
                     this.LevelUpActions = (from a in this.LevelUpActions
                                            orderby a.Priority
                                            select a).ToList <ILevelUpAction>();
                     this.UpdatePreview();
                     this.m_HasPlan     = true;
                     this.m_PlanChanged = false;
                     this.UpdateDifficulty();
                     result = true;
                 }
             }
         }
         finally
         {
             this.Unit.RemoveFact(defaultBuild);
             this.Unit.Remove <LevelUpPlanUnitHolder>();
         }
         return(result);
     }
 }
Exemplo n.º 4
0
        internal static void TestLevelUp()
        {
            var            defaultClass   = ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"); //Alchemist
            var            defaultBuild   = defaultClass.DefaultBuild;
            var            addClassLevels = defaultBuild.GetComponent <AddClassLevels>();
            var            targetPoints   = Main.settings.DefaultPointBuy25 ? 25 : 20;
            var            stats          = defaultBuild.GetComponents <StatsDistributionPreset>().FirstOrDefault(sd => sd.TargetPoints == targetPoints);
            UnitEntityData unitData       = Main.settings.DefaultPointBuy25 ?
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.DefaultPlayerCharacter) :
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.CustomCompanion);
            var  unit              = unitData.Descriptor;
            bool success           = false;
            var  levelUpController = TestLevelUpController.Start(unit: unit, instantCommit: true, unitJson: null, onSuccess: null, mode: LevelUpState.CharBuildMode.CharGen);

            success = levelUpController.SelectPortrait(ResourcesLibrary.GetBlueprints <BlueprintPortrait>().First());
            if (!success)
            {
                Main.Log("Error selecting portrait");
            }
            success = levelUpController.SelectGender(Gender.Male);
            if (!success)
            {
                Main.Log("Error selecting gender");
            }
            success = levelUpController.SelectRace(ResourcesLibrary.TryGetBlueprint <BlueprintRace>("0a5d473ead98b0646b94495af250fdc4"));
            if (!success)
            {
                Main.Log("Error selecting race");
            }
            success = levelUpController.SelectRaceStat(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            if (!success)
            {
                Main.Log("Error selecting race stat");
            }
            success = levelUpController.SelectClass(ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"));
            if (!success)
            {
                Main.Log("Error selecting class");
            }
            levelUpController.ApplyClassMechanics();
            levelUpController.ApplySpellbook();
            success  = levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Constitution);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Constitution);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            if (!success)
            {
                Main.Log("Error selecting stats");
            }
            success  = levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillUseMagicDevice);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillKnowledgeWorld);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillPerception);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillThievery);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillStealth);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillLoreNature);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillKnowledgeArcana);
            if (!success)
            {
                Main.Log("Error selecting skills");
            }
            var selection         = ResourcesLibrary.TryGetBlueprint <BlueprintFeatureSelection>("247a4068296e8be42890143f451b4b45"); //BasicFeatSelection
            var featurePointBlack = ResourcesLibrary.TryGetBlueprint <BlueprintFeature>("0da0c194d6e1d43419eb8d990b28e0ab");          //PointBlankFeature

            success = levelUpController.SelectFeature(new FeatureSelectionState(null, null, selection, 0, 0), featurePointBlack);
            if (!success)
            {
                Main.Log("Error selecting point blank");
            }
            var featurePreciseShot = ResourcesLibrary.TryGetBlueprint <BlueprintFeature>("8f3d1e6b4be006f4d896081f2f889665"); //PreciseShotFeature

            success = levelUpController.SelectFeature(new FeatureSelectionState(null, null, selection, 1, 0), featurePreciseShot);
            if (!success)
            {
                Main.Log("Error selecting precise shot");
            }
            var spells = new List <string>()
            {
                "4f8181e7a7f1d904fbaea64220e83379",
                "5590652e1c2225c4ca30c4a699ab3649",
                "4e0e9aba6447d514f88eff1464cc4763",
                "ef768022b0785eb43a18969903c537c4",
                "2c38da66e5a599347ac95b3294acbe00",
                "9d504f8dff6e93b4ab6afc938ed6a23d",
                "24afb2c948c731440a3aaf5411904c89",
                "c60969e7f264e6d4b84a1499fdcf9039",
            };
            var alchemistSpellBook = ResourcesLibrary.TryGetBlueprint <BlueprintSpellbook>("fcbf2a5447624528a3f333bced844d06");
            var alchemistSpellList = ResourcesLibrary.TryGetBlueprint <BlueprintSpellList>("f60d0cd93edc65c42ad31e34a905fb2f");

            success = true;
            for (var i = 0; i < spells.Count; i++)
            {
                var spell = ResourcesLibrary.TryGetBlueprint <BlueprintAbility>(spells[i]);
                success &= levelUpController.SelectSpell(alchemistSpellBook, alchemistSpellList, 1, spell, i);
            }
            if (!success)
            {
                Main.Log("Error selecting spells");
            }
            success = levelUpController.SelectVoice(ResourcesLibrary.TryGetBlueprint <BlueprintUnitAsksList>("e7b22776ba8e2b84eaaff98e439639a7"));
            if (!success)
            {
                Main.Log("Error selecting voice");
            }
            success = levelUpController.SelectName("ABC");
            if (!success)
            {
                Main.Log("Error selecting name");
            }
            var token = UnitSerialization.Serialize(unit);

            File.WriteAllText("TestUnit.json", token.ToString());
            LogUnit("TestUnit.txt", unit);
        }