/// <summary> /// Event voor de play button wanneer je hier op klikt. /// </summary> private void hmBtnPlay_Click(object sender, EventArgs e) { //Controleer of het spel kan beginnen. if (hoofdmenuPage.CanBegin()) { //Verkrijg een array met alle speler namen. string[] players = hoofdmenuPage.GetPlayerNames(); //Start het spel. gamePage.BeginGame(players); //Controleer of we al een save game hebben.. if (GameFiles.HasSaveGame()) { //Vraag om gebruikers input DialogResult result = MessageBox.Show( "Er is al een bestaande game opgeslagen, wil je deze laden?", "Game Laden", MessageBoxButtons.YesNo ); if (result == DialogResult.Yes) { //Laad het spel van schijf. gamePage.LoadGame(); } } //Laat het spel pagina zien. pageController.ShowPage(PageController.PAGE_SPEL); } else { MessageBox.Show("Er zijn te weinig spelers om het spel te starten!", "Woops", MessageBoxButtons.OK); } }
public ConcurrentQueue <Message> gameQueue; // Used so the gui thread can talk to the game thread. public MainWindow() { // Setup multi-threaded stuff. InitializeComponent(); this.gameQueue = new ConcurrentQueue <Message>(); this._gameThread = new Thread(gameThreadMain); this._gameThread.Start(); // Setup events base.Closed += MainWindow_Closed; // Setup the slots. this._slots = new Label[] { slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8 }; foreach (var slot in this._slots) { slot.MouseLeftButtonUp += onSlotPress; } // Misc. this.Title += $" {Config.versionString}"; if (GameFiles.shouldShowHelpMessage()) { this.showHelpBox(); } }
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); }
/// <summary> /// Update de highscore lijst door middel van het highscore bestand /// </summary> public void Show() { //Verkrijg de highscore data. HighscoreContext highscoreContext = GameFiles.LoadHighscore(); if (highscoreContext != null) { //Sorteer met wins List <HighscoreListItem> sortedList = highscoreContext.HighscoreItems.OrderByDescending(x => x.wins).ToList(); for (int i = 0; i < sortedList.Count; i++) { HighscoreListItem item = sortedList[i]; //Maak een nieuwe list view item. ListViewItem lvItem = new ListViewItem(new[] { item.name, item.wins.ToString(), item.score.ToString() }); //En voeg de listview item toe aan de highscore listview. highscoreList.Items.Add(lvItem); } } }
/// <summary> /// Instala/Actualiza la traducción, es importante cambiarlo ya que es único por juego. /// </summary> public void InstallTranslation(bool updating) { //Se abre el changelog OpenUrl.Open(Temp + "/DDLC_ESP-master/Changelog.txt"); try { //Aquí copias los archivos originales para las futuras actualizaciones if (!Directory.Exists("Original")) { Directory.CreateDirectory("Original"); File.Copy(GameDir + "scripts.rpa", "Original/scripts.rpa"); } //Este método es cuando vas a actualizar la tradu, en el caso del doki no hace mucha falta pero lo dejo como ejemplo if (updating) { File.Copy("../" + GameDir + "/Original/scripts.rpa", GameDir + "scripts.rpa"); } //Copy git files FixGame(); File.Copy(Temp + "/DDLC_ESP-master/files/README.html", GameDir + "../README.html", true); File.Copy(Temp + "/DDLC_ESP-master/Version", GameDir + "Version", true); GameFiles.DirectoryCopy(Temp + "/DDLC_ESP-master/files/game", GameDir, true); } catch (Exception e) { MessageBox.Show("Se ha producido un error en la instalación de la traducción (SO: " + System + ")\n" + e, "Error en la instalación", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Constructs a new version of the AI. /// /// The AI will attempt to load its global tree when constructed. /// </summary> /// /// <param name="window">A debug window for the local tree.</param> /// <param name="globalWindow">A debug window for the global tree.</param> public AI(NodeDebugWindow window = null, NodeDebugWindow globalWindow = null) { // Show the debug windows. if (window != null) { this._debug = window; window.Show(); } if (globalWindow != null) { this._globalDebug = globalWindow; globalWindow.Show(); } // Setup variables. this._useRandom = false; this._rng = new Random(); // Load the move tree this._globalTree = GameFiles.loadTree(AI._globalName, false); if (this._globalTree == null) { this._globalTree = Node.root; } }
private int CountAllItemsWithNamesContaining(string itemNamePart, GameFiles outputFiles) { int uniqueItemCount = CountItemsWithNamesContaining(itemNamePart, outputFiles.DropList); uniqueItemCount += CountItemsWithNamesContaining(itemNamePart, outputFiles.CraftList); uniqueItemCount += CountItemsWithNamesContaining(itemNamePart, outputFiles.QuestList); return(uniqueItemCount); }
// implement Controller.onMatchEnd public override void onMatchEnd(Board.Hash state, int index, MatchResult result) { // The windows won't be closed, as I may still need them. // I can just close them manually afterwards. base.onMatchEnd(state, index, result); // If the last piece placed was by the other controller, then it won't have a node in the local tree. // So we quickly add it. if (!state.isMyPiece(index)) { this.addToLocal(state, index); } // Now, the amount of nodes in the local tree should be the same as: Board.pieceCount - amountOfEmptySlots // If not, then we've not created a node somewhere. // (This test was created to prevent this bug from happening again. Praise be for the debug windows.) var emptyCount = 0; // How many spaces are empty for (int i = 0; i < Board.pieceCount; i++) // Count the empty spaces. { emptyCount += (state.isEmpty(i)) ? 1 : 0; } this._localTree.walkEveryPath(path => { // Then make sure the tree's length is the same var amountOfMoves = Board.pieceCount - emptyCount; Debug.Assert(path.Count == amountOfMoves, $"We've haven't added enough nodes to the local tree!\n" + $"empty = {emptyCount} | amountOfMoves = {amountOfMoves} | treeLength = {path.Count}"); // Finally, bump the won/lost counters in the local tree foreach (var node in path) { if (result == MatchResult.Won) { node.won += 1; } else if (result == MatchResult.Lost) { node.lost += 1; } else { // If we tie, don't bump anything up. } } }); // Then merge the local tree into the global one. Node.merge(this._globalTree, this._localTree); // Save the global tree, and update the debug window. GameFiles.saveTree(AI._globalName, this._globalTree); this.doDebugAction(() => this._globalDebug.updateNodeData(this._globalTree)); }
public void treeExistsTest() { const string name = "Test_dummy"; Assert.IsFalse(GameFiles.treeExists(name)); GameFiles.saveTree(name, Node.root); Assert.IsTrue(GameFiles.treeExists(name)); GameFiles.removeTree(name); }
public void ApplyMods(GameFiles gameFiles) { _itemPlacementRandomizerMod.RandomizeItems(gameFiles); if (_opts.IsRandomizeType) { _dropTypeRandomizerMod.SetAllItemLocationsToSameType(gameFiles.DropList); _dropTypeRandomizerMod.SetRandomKeyItemLocations(gameFiles.DropList); } }
public static void loadJsonToBean() { if (PlayerPrefs.GetString("gameFile") != null && (!PlayerPrefs.GetString("gameFile").Equals("")))//有存過檔 { gameFiles = JsonUtility.FromJson <GameFiles>(PlayerPrefs.GetString("gameFile")); } else//沒存過檔 { gameFiles = new GameFiles(); string saveString = JsonUtility.ToJson(gameFiles);//將gameFiles轉換成json格式的字串 PlayerPrefs.SetString("gameFile", saveString); } }
/// <summary> /// Maak een complete kopie van de data van de game en slaat het op op de schijf. /// </summary> public bool SaveGame() { //Maak nieuwe context GameContext ctx = new GameContext(playerList, turnController, cardController, playingField); //Roep functie aan die het naar de schijf schrijft. if (!GameFiles.CreateSaveGame(ctx)) { return(false); } return(true); }
public void RandomizeItems(GameFiles gameFilesToModify) { var randomizableItemStore = new RandomizableStore(); AddAllRandomizableItems(gameFilesToModify.DropList, randomizableItemStore); AddAllRandomizableItems(gameFilesToModify.QuestList, randomizableItemStore); AddAllGourmandQuestFoods(gameFilesToModify.QuestList, randomizableItemStore); AddAllCraftableItemsToRandomize(gameFilesToModify.CraftList, randomizableItemStore); RandomizeDropItems(gameFilesToModify.DropList, randomizableItemStore); RandomizeQuestItems(gameFilesToModify.QuestList, randomizableItemStore); RandomizeCraftItems(gameFilesToModify.CraftList, randomizableItemStore); }
/// <summary> /// Update de highscore lijst /// </summary> /// <param name="playerList"> De spelerslijst object </param> /// <param name="winners"> Array met de winnaars </param> public void UpdateHighscoreList(PlayerList playerList, Player[] winners) { //Vraag de highscore lijst op van de schijf. HighscoreContext highscoreList = GameFiles.LoadHighscore(); // Als er abosluut niks in de highscore lijst staat, maak nieuwe aan. if (highscoreList == null) { highscoreList = new HighscoreContext(); } //Ga over alle spelers heen in de speler lijst. for (int i = 0; i < playerList.GetPlayerCount(); i++) { //Verkrijg speler object. Player player = playerList.GetPlayerById(i); //Kijk of die gene een winaar is. bool isWinner = false; for (int w = 0; w < winners.Length; w++) { if (winners[w].id == player.id) { isWinner = true; break; } } //Voeg HighScoreListItem toe als die niet bestaat: if (!highscoreList.ContainsPlayer(player)) { highscoreList.HighscoreItems.Add(new HighscoreListItem(player.name, 0, 0)); } //Update alle waarden in de highscore lijst. for (int n = 0; n < highscoreList.HighscoreItems.Count; n++) { HighscoreListItem item = highscoreList.HighscoreItems[n]; item.Update(player, isWinner); highscoreList.HighscoreItems[n] = item; } } //Schrijf opnieuw naar schijf. GameFiles.CreateHighScoreList(highscoreList); }
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); }
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)); }
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); }
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); } }
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); }
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 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); }
/// <summary> /// Laad een game van schijf. /// </summary> /// <returns></returns> public bool LoadGame() { //Laad de context van schijf. GameContext context = GameFiles.LoadSaveGame(); //Als er niks in staat, ga terug. if (context == null) { return(false); } //Pas de context toe. playerList.SetContext(context); turnController.SetContext(context); playingField.SetContext(context); cardController.SetContext(context); return(true); }
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 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 removeTreeTest() { const string name = "Test_remove"; Assert.IsFalse(GameFiles.treeExists(name)); GameFiles.saveTree(name, Node.root); Assert.IsTrue(GameFiles.treeExists(name)); GameFiles.removeTree(name); Assert.IsFalse(GameFiles.treeExists(name)); // Check for exception try { GameFiles.removeTree(name, true); Assert.Fail("No exception was thrown."); } catch (Exception ex) { } }
/// <summary> /// Fills out the <see cref="Installation.GameFiles"/> list by parsing Morrowind.ini. The list /// is sorted such that esm files appear before esp files, with ordering by last modification. /// </summary> private void BuildGameFilesList() { ArgumentNullException.ThrowIfNull(Configuration); // Get the raw list. List <string> definedFiles = new(); var configGameFiles = Configuration["Game Files"]; for (var i = 0; true; ++i) { var gameFile = configGameFiles["GameFile" + i]; if (string.IsNullOrEmpty(gameFile)) { break; } definedFiles.Add(gameFile); } // Add ESM files first. var dataFiles = Path.Combine(RootDirectory, "Data Files"); foreach (var path in Directory.GetFiles(dataFiles, "*.esm", SearchOption.TopDirectoryOnly).OrderBy(p => File.GetLastWriteTime(p).Ticks)) { var fileName = Path.GetFileName(path); if (definedFiles.Contains(fileName)) { GameFiles.Add(fileName); } } // Then add other content files. foreach (var path in Directory.GetFiles(dataFiles, "*.esp", SearchOption.TopDirectoryOnly).OrderBy(p => File.GetLastWriteTime(p).Ticks)) { var fileName = Path.GetFileName(path); if (definedFiles.Contains(fileName)) { GameFiles.Add(fileName); } } }
public void WritePackagedModFile(GameFiles gameFiles, FilePath packageOutputFilePath) { string tempFolder = Path.Combine(packageOutputFilePath.DirectoryPath, Constants.TempFolderName); string tempAssetsFullPath = Path.Combine(tempFolder, Constants.UassetBaseFolderName, Constants.UassetSubPath); bool isTmpDirAlreadyExists = Directory.Exists(tempFolder); Directory.CreateDirectory(tempAssetsFullPath); try { WriteModifiedUassetFile(gameFiles.DropList, new FilePath(tempAssetsFullPath, Constants.FileNameDropRateMaster)); WriteModifiedUassetFile(gameFiles.QuestList, new FilePath(tempAssetsFullPath, Constants.FileNameQuestMaster)); WriteModifiedUassetFile(gameFiles.CraftList, new FilePath(tempAssetsFullPath, Constants.FileNameCraftMaster)); CreatePakFile(packageOutputFilePath, tempFolder); } finally { if (!isTmpDirAlreadyExists) { Directory.Delete(tempFolder, true); } } }
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); }
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)); }
private void Alex_Load(object sender, System.EventArgs e) { gameFiles = new GameFiles(); }