Beispiel #1
0
        public void TestProvidingDifferentSeedsGivesDifferentResults()
        {
            // Assign
            const string firstSeed  = "SeedText-First";
            const string secondSeed = "SeedText-Second";

            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            _opts.SeedText = firstSeed;
            Program.RunMain(_opts);
            string firstRunDropMasterString  = File.ReadAllText(FolderPathOutput + "/PB_DT_DropRateMaster.json");
            string firstRunQuestMasterString = File.ReadAllText(FolderPathOutput + "/PB_DT_QuestMaster.json");
            string firstRunCraftMasterString = File.ReadAllText(FolderPathOutput + "/PB_DT_CraftMaster.json");

            _opts.SeedText = secondSeed;
            Program.RunMain(_opts);
            string secondRunDropMasterString  = File.ReadAllText(FolderPathOutput + "/PB_DT_DropRateMaster.json");
            string secondRunQuestMasterString = File.ReadAllText(FolderPathOutput + "/PB_DT_QuestMaster.json");
            string secondRunCraftMasterString = File.ReadAllText(FolderPathOutput + "/PB_DT_CraftMaster.json");

            //Assert
            Assert.AreNotEqual(firstRunDropMasterString, secondRunDropMasterString);
            Assert.AreNotEqual(firstRunQuestMasterString, secondRunQuestMasterString);
            Assert.AreNotEqual(firstRunCraftMasterString, secondRunCraftMasterString);
        }
Beispiel #2
0
        public void TestOnlySecondUpgradeBackerWeaponsAreRandomizedByDefault()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var           gameFileReader            = new GameFileService(_opts, new UassetService());
            GameFiles     inputFiles                = gameFileReader.ReadAllFiles(_opts.InputPath);
            List <string> firstAndLastBackerWeapons = inputFiles.CraftList
                                                      .Where(entry => entry.IsBackerWeapon() && !Constants.ItemName16BitCoin.Equals(entry.Value.Ingredient2Id))
                                                      .Select(entry => entry.GetItemName())
                                                      .ToList();

            // Act
            Program.RunMain(_opts);

            //Assert
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);
            int       numberAssignedFirstAndLastBackerWeapons = outputFiles.DropList
                                                                .FindAll(entry => firstAndLastBackerWeapons.Contains(entry.GetItemName()))
                                                                .Count;

            Assert.AreEqual(0, numberAssignedFirstAndLastBackerWeapons);
            numberAssignedFirstAndLastBackerWeapons = outputFiles.QuestList
                                                      .FindAll(entry => firstAndLastBackerWeapons.Contains(entry.GetItemName()))
                                                      .Count;
            Assert.AreEqual(0, numberAssignedFirstAndLastBackerWeapons);
        }
Beispiel #3
0
        public static void RunMain(Options opts)
        {
            Random random = CreateSeededRandom(opts.SeedText);
            var    itemRandomizerService = new ItemRandomizerService(random);
            var    uassetService         = new UassetService();

            var gameFileService = new GameFileService(opts, uassetService);

            var itemPlacementRandomizerMod = new ItemPlacementRandomizerMod(itemRandomizerService);
            var dropTypeRandomizerMod      = new DropTypeRandomizerMod(itemRandomizerService, opts);
            var modManager = new ModManager(opts, itemPlacementRandomizerMod, dropTypeRandomizerMod);

            CreateTrueRandomizerMod(opts, gameFileService, modManager);
        }
Beispiel #4
0
        public void TestUniqueConsumablesAreNeverPlacedInCraftList()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestConsumablesOnly\";
            _opts.SeedText  = "SeedText-UniqueConsumableNeverInCraftList";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            int countUniqueConsumables = CountAllItemsWithNamesContaining("unique_consumable", outputFiles);

            Assert.AreEqual(0, countUniqueConsumables);
        }
Beispiel #5
0
        public void TestResultListsEntryCountIsUnchanged()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles inputFiles  = gameFileReader.ReadAllFiles(_opts.InputPath);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            Assert.AreEqual(inputFiles.QuestList.Count, outputFiles.QuestList.Count);
            Assert.AreEqual(inputFiles.DropList.Count, outputFiles.DropList.Count);
            Assert.AreEqual(inputFiles.CraftList.Count, GetResultingCraftListItemCount(outputFiles.CraftList));
        }
Beispiel #6
0
        public void TestNonValidEntriesAreUnchanged()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles inputFiles  = gameFileReader.ReadAllFiles(_opts.InputPath);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            AssertInvalidEntriesAreEqual(inputFiles.DropList, outputFiles.DropList);
            AssertInvalidEntriesAreEqual(inputFiles.QuestList, outputFiles.QuestList);
            AssertInvalidEntriesAreEqual(inputFiles.CraftList, outputFiles.CraftList);
        }
Beispiel #7
0
        private static void CreateTrueRandomizerMod(Options opts, GameFileService gameFileService, ModManager modManager)
        {
            GameFiles gameFiles = gameFileService.ReadAllFiles();

            modManager.ApplyMods(gameFiles);

            if (opts.IsJsonOutput || opts.IsJsonOnly)
            {
                gameFileService.WriteModifiedJsonFiles(gameFiles, opts.OutputPath);
            }

            if (!opts.IsJsonOnly)
            {
                var packageFilePath = new FilePath(Path.GetFullPath(opts.OutputPath), opts.SeedText, Constants.FileExtensionPak, Constants.DefaultPakFileName);
                gameFileService.WritePackagedModFile(gameFiles, packageFilePath);
            }
        }
Beispiel #8
0
        public void TestAllSingleInstanceUniqueItemsPresentInResultLists()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles inputFiles  = gameFileReader.ReadAllFiles(_opts.InputPath);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            int expectedUniqueItemCount = CountAllItemsWithNamesContaining("unique_", inputFiles);
            int actualUniqueItemCount   = CountAllItemsWithNamesContaining("unique_", outputFiles);

            Assert.AreEqual(expectedUniqueItemCount, actualUniqueItemCount);
        }
Beispiel #9
0
        public void TestThatIfCraftableItemCanBeFoundInMultiplesItCanBeAssignedInMultiples()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestMultipleInstanceUniqueItems\";
            _opts.SeedText  = "SeedText-TwoCraftableInDropAndQuestBothSetAsFindable";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            int actualDropAndQuestCount = CountItemsWithNamesContaining("craftable_weapon_1", outputFiles.DropList);

            actualDropAndQuestCount += CountItemsWithNamesContaining("craftable_weapon_1", outputFiles.QuestList);
            Assert.AreEqual(2, actualDropAndQuestCount);
        }
        public void TestExemptItemTypeEntriesAreUnchanged()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);

            //Assert
            List <DropItemEntry> inputDropList  = gameFileReader.ReadAllFiles(_opts.InputPath).DropList;
            List <DropItemEntry> outputDropList = gameFileReader.ReadAllFiles(FolderPathOutput).DropList;

            AssertEntriesWithTypeAreUnchanged(inputDropList, outputDropList, Constants.ItemTypeConsumable);
            AssertEntriesWithTypeAreUnchanged(inputDropList, outputDropList, Constants.ItemTypeCraftingMaterials);
            AssertEntriesWithTypeAreUnchanged(inputDropList, outputDropList, Constants.ItemTypeNone);
        }
Beispiel #11
0
        public void TestSingleInstanceConsumablesCanBeAssignedMultipleTimes()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestConsumablesOnly\";
            _opts.SeedText  = "SeedText-SingleInstanceConsumableExistsInMultiples";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            const string singleInstanceConsumableName = "onlycraftable_consumable_1";
            int          count = CountItemsWithNamesContaining(singleInstanceConsumableName, outputFiles.QuestList);

            count += CountItemsWithNamesContaining(singleInstanceConsumableName, outputFiles.DropList);
            Assert.IsTrue(count > 1);
        }
Beispiel #12
0
        public void TestCraftListContainsNoDuplicates()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);

            //Assert
            List <CraftItemEntry> resultCraftList = gameFileReader.ReadAllFiles(FolderPathOutput).CraftList;
            List <string>         craftItemNames  = resultCraftList.Where(entry => entry.IsEntryValid() && !Constants.ItemNameNone.Equals(entry.GetItemName()))
                                                    .Select(entry => entry.GetItemName())
                                                    .ToList();
            HashSet <string> craftItemNameSet = craftItemNames.ToHashSet();

            Assert.AreEqual(craftItemNames.Count, craftItemNameSet.Count);
        }
Beispiel #13
0
        public void TestAllFoodItemsAreReplacedWithFoodNeededForQuests()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            int assignedQuestFoodCount = CountItemsWithNamesContaining("quest_food", outputFiles.DropList);

            assignedQuestFoodCount += CountItemsWithNamesContaining("quest_food", outputFiles.QuestList);
            Assert.AreEqual(2, assignedQuestFoodCount);
            int questFoodAssignedToCraftList = CountItemsWithNamesContaining("quest_food", outputFiles.CraftList);

            Assert.AreEqual(0, questFoodAssignedToCraftList);
        }
        public void TestFixedKeyLocationsHaveTypeKey()
        {
            // Assign
            const int expectedRandomKeyLocations = 0;

            _opts.NumberOfKeyLocations = expectedRandomKeyLocations;
            _opts.InputPath            = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);

            //Assert
            List <DropItemEntry> outputDropList = gameFileReader.ReadAllFiles(FolderPathOutput).DropList;

            AssertKeyTypeForNamedEntry(outputDropList, "Swordsman");
            AssertKeyTypeForNamedEntry(outputDropList, "CertificationboardEvent");
            AssertKeyTypeForNamedEntry(outputDropList, "Treasurebox_SAN024");
        }
Beispiel #15
0
        public void TestThatIfUniqueItemHasSeveralInstancesItCanBeBothDropAndCraftable()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestMultipleInstanceUniqueItems\";
            _opts.SeedText  = "SeedText-1UniqueItemInDropOrQuest1InCraft";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            int actualDropAndQuestCount = CountItemsWithNamesContaining("unique_weapon_1", outputFiles.DropList);

            actualDropAndQuestCount += CountItemsWithNamesContaining("unique_weapon_1", outputFiles.QuestList);
            int actualCraftCount = CountItemsWithNamesContaining("unique_weapon_1", outputFiles.CraftList);

            Assert.AreEqual(1, actualDropAndQuestCount);
            Assert.AreEqual(1, actualCraftCount);
        }
        public void TestUserDefinedNumberOfEntriesAreSetAsKeyLocation()
        {
            // Assign
            const int expectedRandomKeyLocations = 5;
            const int expectedFixedKeyLocations  = 3;

            _opts.NumberOfKeyLocations = expectedRandomKeyLocations;
            _opts.InputPath            = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);

            //Assert
            List <DropItemEntry> outputDropList = gameFileReader.ReadAllFiles(FolderPathOutput).DropList;

            int actualNumberOfKeyLocations = GetNumberOfEntriesWithType(outputDropList, Constants.ItemTypeKey);
            int expectedTotalKeyLocations  = expectedFixedKeyLocations + expectedRandomKeyLocations;

            Assert.AreEqual(expectedTotalKeyLocations, actualNumberOfKeyLocations);
        }
Beispiel #17
0
        public MainController(AppData appData, GameFileService gameFileService, IControllerFactory controllerFactory, ArkhamDbService arkhamDbService, LoadingStatusService loadingStatusService, LoggingService loggingService)
        {
            ViewModel.AppData = appData;

            _gameFileService      = gameFileService;
            _controllerFactory    = controllerFactory;
            _arkhamDbService      = arkhamDbService;
            _loadingStatusService = loadingStatusService;
            _logger = loggingService;

            LoadEncounterSets();

            View.Closed += (s, e) => {
                _logger.LogMessage("Closing main window.");
                ClearPlayerCardsWindows();

                if (_overlayController != null)
                {
                    _overlayController.Close();
                }
            };
        }
        public void TestNonExemptNonKeyEntriesAllHaveSameType()
        {
            // Assign
            const int expectedRandomKeyLocations        = 5;
            const int numberOfTypesThatAreNotChangeable = 3;

            _opts.NumberOfKeyLocations = expectedRandomKeyLocations;
            _opts.InputPath            = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);

            //Assert
            List <DropItemEntry> outputDropList = gameFileReader.ReadAllFiles(FolderPathOutput).DropList;

            int numberOfValidTypesNames = outputDropList.Where(entry => entry.IsEntryValid())
                                          .Select(entry => entry.GetItemType())
                                          .Distinct()
                                          .Count();

            Assert.AreEqual(numberOfTypesThatAreNotChangeable + 1, numberOfValidTypesNames);
        }
Beispiel #19
0
        public void TestWeaponInKeyTypeChestIsNotMoved()
        {
            // Assign
            const string keyWeaponId = "keyitem_weapon_1";

            _opts.InputPath = @"file-resources\ComponentTest\TestRandomizeDropQuestCraft\";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles inputFiles  = gameFileReader.ReadAllFiles(_opts.InputPath);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            List <DropItemEntry> inputDroplist          = inputFiles.DropList;
            List <DropItemEntry> outputDroplist         = outputFiles.DropList;
            DropItemEntry        originalKeyWeaponEntry = inputDroplist.Find(entry => keyWeaponId.Equals(entry.GetItemName()));
            DropItemEntry        newKeyWeaponEntry      = outputDroplist.Find(entry => keyWeaponId.Equals(entry.GetItemName()));

            Assert.AreEqual(originalKeyWeaponEntry, newKeyWeaponEntry);
            Assert.AreEqual(inputDroplist.IndexOf(originalKeyWeaponEntry), outputDroplist.IndexOf(newKeyWeaponEntry));
            Assert.AreEqual(0, CountItemsWithNamesContaining(keyWeaponId, outputFiles.QuestList));
            Assert.AreEqual(0, CountItemsWithNamesContaining(keyWeaponId, outputFiles.CraftList));
        }
Beispiel #20
0
        public void TestThatIfUniqueItemHasSeveralInstancesItWillTakeUpOnlyOneEntryIfAllAreAssignedToCraft()
        {
            // Assign
            _opts.InputPath = @"file-resources\ComponentTest\TestMultipleInstanceUniqueItems\";
            _opts.SeedText  = "SeedText-MultipleUniquesAreAllAssignedToCrafting";
            var gameFileReader = new GameFileService(_opts, new UassetService());

            // Act
            Program.RunMain(_opts);
            GameFiles inputFiles  = gameFileReader.ReadAllFiles(_opts.InputPath);
            GameFiles outputFiles = gameFileReader.ReadAllFiles(FolderPathOutput);

            //Assert
            int actualDropAndQuestCount = CountItemsWithNamesContaining("unique_weapon_1", outputFiles.DropList);

            actualDropAndQuestCount += CountItemsWithNamesContaining("unique_weapon_1", outputFiles.QuestList);
            int actualCraftCount = CountItemsWithNamesContaining("unique_weapon_1", outputFiles.CraftList);

            Assert.AreEqual(0, actualDropAndQuestCount);
            Assert.AreEqual(1, actualCraftCount);
            int expectedNumberOfEntriesInCraft = inputFiles.CraftList.Count + 1;

            Assert.AreEqual(expectedNumberOfEntriesInCraft, outputFiles.CraftList.Count);
        }
Beispiel #21
0
 public GameController(ILogger <GameController> logger)
 {
     _logger     = logger;
     fileService = new GameFileService();
     infoService = new GameInfoService();
 }