Example #1
0
            //AskToWrite is called when we want to write our SAVEFile classes's variables to file0. It checks if the directory to write to
            //already exists and asks the user if they wish to overwrite. It then calls WriteSaveFile and WriteINI with the relevant arguments passed
            public static bool AskToWrite(SAVEFile thisSave, INI.INIFile thisINI)
            {
                if (!Directory.Exists(Constants.SavesPath + thisSave.SaveName))
                {
                    Directory.CreateDirectory(Constants.SavesPath + thisSave.SaveName);

                    if (!WriteSaveFile(thisSave, thisINI) || !INI.WriteINI(thisINI, thisSave))
                    {
                        return(false);
                    }

                    return(true);
                }

                else
                {
                    Dictionary <Characters, string> messageDict = new Dictionary <Characters, string>()
                    {
                        { Characters.Alphys, "Hey! So, the save \"" + thisSave.SaveName + "\" already exists. Would you like me to overwrite it?" },
                        { Characters.Asgore, "Well human, the save \"" + thisSave.SaveName + "\" already exists. Shall I overwrite it?" },
                        { Characters.Asriel, "Sorry, but the save \"" + thisSave.SaveName + "\" already exists. Do you want me to overwrite it? It's no trouble, really!" },
                        { Characters.Flowey, "YOU. IDIOT! The save \"" + thisSave.SaveName + "\" already exists. Of course, I've got to do all the work - do you want me to overwrite it?" },
                        { Characters.Papyrus, "NYEH, SORRY HUMAN. THE SAVE \"" + thisSave.SaveName + "\" ALREADY EXISTS. WOULD YOU LIKE ME TO ASSIST YOU AND OVERWRITE IT?" },
                        { Characters.Sans, "yo, buddy. the save \"" + thisSave.SaveName + "\" already exists. i'm normally quite lazy, but i'll make an exception for ya. want me to overwrite it?" },
                        { Characters.Toriel, "My child, I apologize, but the save \"" + thisSave.SaveName + "\" already exists. Would you like me to overwrite it for you?" },
                        { Characters.Undyne, "OH COME ON.  The save \"" + thisSave.SaveName + "\" already exists. Want me to overwrite it?" },
                        { Characters.None, "Save \"" + thisSave.SaveName + "\" already exists! Do you want to overwrite?" }
                    };

                    MessageBoxResult res = UTMessageBox.Show(messageDict, Constants.CharacterReactions.Normal, MessageBoxButton.YesNo);
                    if (res == MessageBoxResult.Yes)
                    {
                        if (!WriteSaveFile(thisSave, thisINI) || !INI.WriteINI(thisINI, thisSave))
                        {
                            return(false);
                        }

                        return(true);
                    }

                    return(false);
                }
            }
Example #2
0
            //readSaveFile is responsible for reading file0 and converting or casting its string values to our variable data types
            //We can then use this to setup the editor UI as well as edit data for this specific save
            private static SAVEFile readSaveFile(string saveFileDirectory)
            {
                string ReadLine(int lineNumber)
                {
                    return(File.ReadLines(saveFileDirectory + "//file0").Skip(lineNumber - 1).Take(1).First().Replace(" ", String.Empty));
                }

                SAVEFile currentSave = new SAVEFile();

                //We read the line passed into ReadLine as a parameter and set the variable to the value read, as well as casting/converting as needed
                currentSave.PlayerName             = ReadLine(1);
                currentSave.LOVE                   = Convert.ToInt16(ReadLine(2));
                currentSave.HP                     = Convert.ToInt16(ReadLine(3));
                currentSave.friskAT                = Convert.ToInt16(ReadLine(5));
                currentSave.weaponAT               = Convert.ToInt16(ReadLine(6));
                currentSave.friskDF                = Convert.ToInt16(ReadLine(7));
                currentSave.armorDF                = Convert.ToInt16(ReadLine(8));
                currentSave.EXP                    = Convert.ToInt32(ReadLine(10));
                currentSave.GOLD                   = Convert.ToInt16(ReadLine(11));
                currentSave.KillCount              = Convert.ToInt16(ReadLine(12));
                currentSave.inventoryItems[0]      = Convert.ToInt16(ReadLine(13));
                currentSave.phoneItems[0]          = Convert.ToInt16(ReadLine(14));
                currentSave.inventoryItems[1]      = Convert.ToInt16(ReadLine(15));
                currentSave.phoneItems[1]          = Convert.ToInt16(ReadLine(16));
                currentSave.inventoryItems[2]      = Convert.ToInt16(ReadLine(17));
                currentSave.phoneItems[2]          = Convert.ToInt16(ReadLine(18));
                currentSave.inventoryItems[3]      = Convert.ToInt16(ReadLine(19));
                currentSave.phoneItems[3]          = Convert.ToInt16(ReadLine(20));
                currentSave.inventoryItems[4]      = Convert.ToInt16(ReadLine(21));
                currentSave.inventoryItems[5]      = Convert.ToInt16(ReadLine(23));
                currentSave.inventoryItems[6]      = Convert.ToInt16(ReadLine(25));
                currentSave.inventoryItems[7]      = Convert.ToInt16(ReadLine(27));
                currentSave.Weapon                 = IDs.GetID(ReadLine(29));
                currentSave.Armor                  = IDs.GetID(ReadLine(30));
                currentSave.asrielDefeated         = Convert.ToBoolean(Convert.ToInt16(ReadLine(38)));
                currentSave.randomCountersDisabled = Convert.ToBoolean(Convert.ToInt16(ReadLine(39)));
                currentSave.ruinsDummyState        = (CharacterStates)(Convert.ToInt16(ReadLine(45)));
                currentSave.torielState            = (CharacterStates)(Convert.ToInt16(ReadLine(76)));
                currentSave.doggoState             = (CharacterStates)(Convert.ToInt16(ReadLine(83)));
                currentSave.dogamyState            = (CharacterStates)(Convert.ToInt16(ReadLine(84)));
                currentSave.greaterDogState        = (CharacterStates)(Convert.ToInt16(ReadLine(85)));
                currentSave.comedianState          = (CharacterStates)(Convert.ToInt16(ReadLine(88)));
                currentSave.papyrusState           = (CharacterStates)(Convert.ToInt16(ReadLine(98)));
                currentSave.shyrenState            = (CharacterStates)(Convert.ToInt16(ReadLine(112)));
                currentSave.papyrusDated           = (DateStates)(Convert.ToInt16(ReadLine(119)));
                currentSave.KillCount              = Convert.ToInt16(ReadLine(232));
                currentSave.ruinsKills             = Convert.ToInt16(ReadLine(233));
                currentSave.snowdinKills           = Convert.ToInt16(ReadLine(234));
                currentSave.waterfallKills         = Convert.ToInt16(ReadLine(235));
                currentSave.hotlandKills           = Convert.ToInt16(ReadLine(236));
                currentSave.undyneState            = (CharacterStates)(Convert.ToInt16(ReadLine(282)));
                currentSave.madDummyState          = (CharacterStates)(Convert.ToInt16(ReadLine(283)));
                currentSave.undyneState            = (CharacterStates)(Convert.ToInt16(ReadLine(381)));
                currentSave.undyneDated            = (DateStates)(Convert.ToInt16(ReadLine(420)));
                currentSave.disableAlphysCalls     = Convert.ToBoolean(Convert.ToInt16(ReadLine(399)));
                currentSave.muffetState            = (CharacterStates)(Convert.ToInt16(ReadLine(428)));
                currentSave.disableHotlandPuzzles  = Convert.ToBoolean(Convert.ToInt16(ReadLine(431)));
                currentSave.broGuardsState         = (CharacterStates)(Convert.ToInt16(ReadLine(433)));
                currentSave.coreElevatorUnlocked   = Convert.ToBoolean(Convert.ToInt16(449));
                currentSave.mettatonState          = (CharacterStates)(Convert.ToInt16(ReadLine(456)));
                currentSave.insideCastle           = Convert.ToBoolean(Convert.ToInt16(ReadLine(462)));
                currentSave.rodeCastleLift         = Convert.ToBoolean(Convert.ToInt16(ReadLine(463)));
                currentSave.unlockedCastleChain    = Convert.ToBoolean(Convert.ToInt16(ReadLine(485)));
                currentSave.undyneOnPhone          = Convert.ToBoolean(Convert.ToInt16(ReadLine(496)));
                currentSave.beatTrueLab            = Convert.ToBoolean(Convert.ToInt16(ReadLine(522)));
                currentSave.dateAlphysFlag         = Convert.ToBoolean(Convert.ToInt16(ReadLine(523)));
                currentSave.pacifistStage          = Convert.ToInt16(ReadLine(524));
                currentSave.Plot                   = Convert.ToInt16(ReadLine(543));
                currentSave.Location               = Convert.ToInt16(ReadLine(548));
                currentSave.SaveName               = new DirectoryInfo(saveFileDirectory).Name;

                return(currentSave);
            }
Example #3
0
            //SetSaveForRoute sets the variable values needed for each route's requirements to be met up to the player's currentLocation
            public static SAVEFile SetSaveForRoute(SAVEFile save, int locationID, Routes.GameRoutes routeToSet)
            {
                //It is key to note we assume the maximum kill count allowed for each route, regardless of location
                //This shouldn't be too big of an issue as the user can manually change their kills via the Editor UI
                SAVEInstance = save;
                clearStates(locationID);

                SAVEInstance.rodeCastleLift       = MiscFunctions.SetBooleanValueFromLocation(locationID, 216);
                SAVEInstance.unlockedCastleChain  = MiscFunctions.SetBooleanValueFromLocation(locationID, 226);
                SAVEInstance.insideCastle         = MiscFunctions.SetBooleanValueFromLocation(locationID, 216);
                SAVEInstance.coreElevatorUnlocked = MiscFunctions.SetBooleanValueFromLocation(locationID, 210);

                switch (routeToSet)
                {
                case Routes.GameRoutes.Family:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Toriel, Characters.Papyrus);
                    SetDateValue(locationID, Characters.Papyrus, DateStates.PapyrusComplete);
                    SetDateValue(locationID, Characters.Undyne, DateStates.UndyneComplete);
                    SAVEInstance.undyneOnPhone = MiscFunctions.SetBooleanValueFromLocation(locationID, 139);
                    SAVEInstance.KillCount     = 0;
                    break;

                case Routes.GameRoutes.BetrayedUndyneDated:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Toriel, Characters.Papyrus);
                    SetDateValue(locationID, Characters.Undyne, DateStates.UndyneComplete);
                    SetDateValue(locationID, Characters.Papyrus, DateStates.PapyrusComplete);
                    SAVEInstance.undyneOnPhone = MiscFunctions.SetBooleanValueFromLocation(locationID, 139);
                    SAVEInstance.KillCount     = 9;
                    break;

                case Routes.GameRoutes.BetrayedUndyneNoDate:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Toriel, Characters.Papyrus);
                    SetDateValue(locationID, Characters.Undyne, DateStates.DateNotStarted);
                    SetDateValue(locationID, Characters.Papyrus, DateStates.PapyrusComplete);
                    SAVEInstance.KillCount = 9;
                    break;

                case Routes.GameRoutes.BetrayedUndyneMettaton:
                    SetDateValue(locationID, Characters.Undyne, DateStates.DateNotStarted);
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Toriel, Characters.Papyrus);
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Mettaton);
                    SAVEInstance.KillCount = 1;
                    break;

                case Routes.GameRoutes.ExiledNoUndyneNoPapyrus:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Toriel);
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Papyrus, Characters.Undyne);
                    SAVEInstance.KillCount = 2;
                    break;

                case Routes.GameRoutes.ExiledNoUndynePapyrus:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Toriel, Characters.Papyrus);
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Undyne);
                    SAVEInstance.KillCount = 1;
                    break;

                case Routes.GameRoutes.ExiledUndyneNoPapyrus:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Toriel);
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Papyrus);
                    SAVEInstance.KillCount = 1;
                    break;

                case Routes.GameRoutes.ExiledMonsters:
                    SAVEInstance.KillCount = 10;
                    break;

                case Routes.GameRoutes.QueenUndyne:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Papyrus);
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Toriel);
                    SAVEInstance.KillCount = 1;
                    break;

                case Routes.GameRoutes.QueenUndyneNoPapyrus:
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Toriel, Characters.Papyrus);
                    SAVEInstance.KillCount = 2;
                    break;

                case Routes.GameRoutes.KingMettaton:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Papyrus);
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Toriel, Characters.Undyne);
                    SAVEInstance.KillCount = 2;
                    break;

                case Routes.GameRoutes.KingMettatonNoPapyrus:
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Toriel, Characters.Undyne, Characters.Papyrus);
                    SAVEInstance.KillCount = 3;
                    break;

                case Routes.GameRoutes.KingPapyrus:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.Papyrus);
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Toriel, Characters.Undyne, Characters.Mettaton);
                    SAVEInstance.KillCount = 3;
                    break;

                case Routes.GameRoutes.KingDog:
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Toriel, Characters.Undyne, Characters.Mettaton, Characters.Papyrus);
                    SAVEInstance.KillCount = 4;
                    break;

                case Routes.GameRoutes.Leaderless:
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Toriel, Characters.Undyne, Characters.Mettaton, Characters.Papyrus, Characters.RuinsDummy, Characters.Doggo, Characters.Shyren, Characters.BroGuards);
                    SAVEInstance.KillCount = 8;
                    break;

                case Routes.GameRoutes.QueenAlphys:
                    SetMurderLevel(locationID, 12);
                    SetCharacterStates(locationID, CharacterStates.Killed, Characters.Mettaton);
                    SAVEInstance.KillCount = SAVEInstance.KillCount + 1;     //We add one to account for Mettaton being killed
                    break;

                case Routes.GameRoutes.Genocide:
                    SetMurderLevel(locationID, 16);
                    SAVEInstance.disableAlphysCalls     = MiscFunctions.SetBooleanValueFromLocation(locationID, 133);
                    SAVEInstance.disableHotlandPuzzles  = MiscFunctions.SetBooleanValueFromLocation(locationID, 133);
                    SAVEInstance.coreElevatorUnlocked   = MiscFunctions.SetBooleanValueFromLocation(locationID, 133);
                    SAVEInstance.randomCountersDisabled = MiscFunctions.SetBooleanValueFromLocation(locationID, 212);
                    break;

                case Routes.GameRoutes.TruePacifistDate:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.All);     //These used to be just Toriel and Papyrus! Any reason?
                    SetDateValue(236, Characters.Papyrus, DateStates.PapyrusComplete);
                    SetDateValue(236, Characters.Undyne, DateStates.UndyneComplete);
                    SAVEInstance.pacifistStage       = 2;
                    SAVEInstance.Location            = 236;
                    SAVEInstance.dateAlphysFlag      = true;
                    SAVEInstance.rodeCastleLift      = true;
                    SAVEInstance.unlockedCastleChain = true;
                    SAVEInstance.undyneOnPhone       = true;
                    break;

                case Routes.GameRoutes.TruePacifistLab:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.All);
                    SetDateValue(236, Characters.Papyrus, DateStates.PapyrusComplete);
                    SetDateValue(236, Characters.Undyne, DateStates.UndyneComplete);
                    SAVEInstance.pacifistStage          = 11;
                    SAVEInstance.Location               = 139;
                    SAVEInstance.rodeCastleLift         = true;
                    SAVEInstance.unlockedCastleChain    = true;
                    SAVEInstance.undyneOnPhone          = true;
                    SAVEInstance.randomCountersDisabled = true;
                    break;

                case Routes.GameRoutes.TruePacifistAsriel:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.All);
                    SetDateValue(236, Characters.Papyrus, DateStates.PapyrusComplete);
                    SetDateValue(236, Characters.Undyne, DateStates.UndyneComplete);
                    SAVEInstance.pacifistStage          = 12;
                    SAVEInstance.Location               = 216;
                    SAVEInstance.rodeCastleLift         = true;
                    SAVEInstance.unlockedCastleChain    = true;
                    SAVEInstance.beatTrueLab            = true;
                    SAVEInstance.undyneOnPhone          = true;
                    SAVEInstance.randomCountersDisabled = true;
                    break;

                case Routes.GameRoutes.TruePacifistAsrielTalk:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.All);
                    SetDateValue(236, Characters.Papyrus, DateStates.PapyrusComplete);
                    SetDateValue(236, Characters.Undyne, DateStates.UndyneComplete);
                    SAVEInstance.pacifistStage          = 12;
                    SAVEInstance.Location               = 331;
                    SAVEInstance.rodeCastleLift         = true;
                    SAVEInstance.unlockedCastleChain    = true;
                    SAVEInstance.beatTrueLab            = true;
                    SAVEInstance.undyneOnPhone          = true;
                    SAVEInstance.randomCountersDisabled = true;
                    break;

                case Routes.GameRoutes.TruePacifistEpilogue:
                    SetCharacterStates(locationID, CharacterStates.Spared, Characters.All);
                    SetDateValue(236, Characters.Papyrus, DateStates.PapyrusComplete);
                    SetDateValue(236, Characters.Undyne, DateStates.UndyneComplete);
                    SAVEInstance.pacifistStage          = 12;
                    SAVEInstance.Location               = 236;
                    SAVEInstance.rodeCastleLift         = true;
                    SAVEInstance.unlockedCastleChain    = true;
                    SAVEInstance.beatTrueLab            = true;
                    SAVEInstance.asrielDefeated         = true;
                    SAVEInstance.undyneOnPhone          = true;
                    SAVEInstance.randomCountersDisabled = true;
                    break;
                }

                SetPhoneItems(locationID, routeToSet);
                SetPlotValue(routeToSet, locationID);

                return(SAVEInstance);
            }
Example #4
0
            //WriteSaveFile writes, well, the save file.
            public static bool WriteSaveFile(SAVEFile fileToWrite, INI.INIFile ini)
            {
                //SetFlagFromBool converts a boolean variable or value to a string to be written as a flag in file0
                string SetFlagFromBool(bool booleanToCheck, int valueToSet = 1)
                {
                    if (booleanToCheck)
                    {
                        return(valueToSet.ToString());
                    }

                    else
                    {
                        return("0");
                    }
                }

                //We use an ordered dictionary with the key as the line number in file0 to write the value to
                OrderedDictionary file0Contents = new OrderedDictionary
                {
                    { 1, fileToWrite.PlayerName },
                    { 2, fileToWrite.LOVE.ToString() },
                    { 3, fileToWrite.HP.ToString() },
                    { 4, "0" },
                    { 5, fileToWrite.friskAT.ToString() },
                    { 6, fileToWrite.weaponAT.ToString() },
                    { 7, fileToWrite.friskDF.ToString() },
                    { 8, fileToWrite.armorDF.ToString() },
                    { 9, "4" },
                    { 10, fileToWrite.EXP.ToString() },
                    { 11, fileToWrite.GOLD.ToString() },
                    { 12, fileToWrite.KillCount.ToString() },
                    { 13, fileToWrite.inventoryItems[0].ToString() },
                    { 14, fileToWrite.phoneItems[0].ToString() },
                    { 15, fileToWrite.inventoryItems[1].ToString() },
                    { 16, fileToWrite.phoneItems[1].ToString() },
                    { 17, fileToWrite.inventoryItems[2].ToString() },
                    { 18, fileToWrite.phoneItems[2].ToString() },
                    { 19, fileToWrite.inventoryItems[3].ToString() },
                    { 20, fileToWrite.phoneItems[3].ToString() },
                    { 21, fileToWrite.inventoryItems[4].ToString() },
                    { 22, "0" },
                    { 23, fileToWrite.inventoryItems[5].ToString() },
                    { 24, "0" },
                    { 25, fileToWrite.inventoryItems[6].ToString() },
                    { 26, "0" },
                    { 27, fileToWrite.inventoryItems[7].ToString() },
                    { 28, "0" },
                    { 29, fileToWrite.Weapon },
                    { 30, fileToWrite.Armor },
                    { 38, Convert.ToInt16(fileToWrite.asrielDefeated) },
                    { 39, Convert.ToInt16(fileToWrite.randomCountersDisabled) },
                    { 45, (int)fileToWrite.ruinsDummyState },
                    { 76, (int)fileToWrite.torielState },
                    { 83, (int)fileToWrite.doggoState },
                    { 84, (int)fileToWrite.dogamyState },
                    { 85, (int)fileToWrite.greaterDogState },
                    { 88, (int)fileToWrite.comedianState },
                    { 98, (int)fileToWrite.papyrusState },
                    { 112, (int)fileToWrite.shyrenState },
                    { 119, (int)fileToWrite.papyrusDated },
                    { 232, fileToWrite.KillCount },
                    { 233, fileToWrite.ruinsKills },
                    { 234, fileToWrite.snowdinKills },
                    { 235, fileToWrite.waterfallKills },
                    { 236, fileToWrite.hotlandKills },
                    { 282, (int)fileToWrite.undyneState },
                    { 283, (int)fileToWrite.madDummyState },
                    { 381, (int)fileToWrite.undyneState },
                    { 398, Convert.ToInt16(fileToWrite.disableAlphysCalls) },
                    { 399, Convert.ToInt16(fileToWrite.disableAlphysCalls) },
                    { 402, Convert.ToInt16(fileToWrite.disableHotlandPuzzles) },
                    { 404, Convert.ToInt16(fileToWrite.disableHotlandPuzzles) },
                    { 405, Convert.ToInt16(fileToWrite.disableHotlandPuzzles) },
                    { 406, Convert.ToInt16(fileToWrite.disableHotlandPuzzles) },
                    { 420, (int)fileToWrite.undyneDated },
                    { 428, (int)fileToWrite.muffetState },
                    { 430, Convert.ToInt16(fileToWrite.disableHotlandPuzzles) },
                    { 431, Convert.ToInt16(fileToWrite.disableHotlandPuzzles) },
                    { 433, (int)fileToWrite.broGuardsState },
                    { 449, SetFlagFromBool(fileToWrite.coreElevatorUnlocked) },
                    { 456, (int)fileToWrite.mettatonState },
                    { 462, SetFlagFromBool(fileToWrite.insideCastle) },
                    { 463, SetFlagFromBool(fileToWrite.rodeCastleLift) },
                    { 481, SetFlagFromBool(ini.skipAsrielStory, 17) },
                    { 483, SetFlagFromBool(fileToWrite.unlockedCastleChain) },
                    { 484, SetFlagFromBool(fileToWrite.unlockedCastleChain) },
                    { 485, SetFlagFromBool(fileToWrite.unlockedCastleChain) },
                    { 486, SetFlagFromBool(ini.skipAsrielStory) },
                    { 487, SetFlagFromBool(ini.skipAsrielStory, 2) },
                    { 496, Convert.ToInt16(fileToWrite.undyneOnPhone) },
                    { 510, SetFlagFromBool(fileToWrite.asrielDefeated, 2) },
                    { 512, SetFlagFromBool(fileToWrite.beatTrueLab, 3) },
                    { 513, SetFlagFromBool(fileToWrite.beatTrueLab, 3) },
                    { 514, SetFlagFromBool(fileToWrite.beatTrueLab, 3) },
                    { 515, SetFlagFromBool(fileToWrite.beatTrueLab, 3) },
                    { 516, SetFlagFromBool(fileToWrite.beatTrueLab) },
                    { 517, SetFlagFromBool(fileToWrite.beatTrueLab, 10) },
                    { 518, SetFlagFromBool(fileToWrite.beatTrueLab, 0) },
                    { 519, SetFlagFromBool(fileToWrite.beatTrueLab) },
                    { 520, SetFlagFromBool(fileToWrite.beatTrueLab) },
                    { 521, SetFlagFromBool(fileToWrite.beatTrueLab) },
                    { 522, SetFlagFromBool(fileToWrite.beatTrueLab) },
                    { 523, SetFlagFromBool(fileToWrite.dateAlphysFlag) },
                    { 524, fileToWrite.pacifistStage },
                    { 543, fileToWrite.Plot },
                    { 544, "1" },
                    { 545, "1" },
                    { 546, SetFlagFromBool(MiscFunctions.SetBooleanValueFromLocation(fileToWrite.Location, 12)) }, //Cell Phone
                    { 547, "0" },
                    { 548, fileToWrite.Location.ToString() },
                    { 549, "0" }
                };

                if (fileToWrite.Location == 998)
                {
                    fileToWrite.Location = 235;
                    FileOperations.setGenocide(GenocideStates.Abyss);
                }

                else if (fileToWrite.Location == 999)
                {
                    fileToWrite.Location = 237;
                }

                try
                {
                    StreamWriter file0Writer = new StreamWriter(File.Open(Constants.SavesPath + fileToWrite.SaveName + "//file0", FileMode.Create), Encoding.ASCII);

                    //We iterate through every line and key in file0Contents and if the key value matches lineNumber, we write the corresponding value
                    for (int lineNumber = 1; lineNumber <= 549; lineNumber++)
                    {
                        foreach (DictionaryEntry file0Entry in file0Contents)
                        {
                            if ((int)file0Entry.Key == lineNumber)
                            {
                                file0Writer.WriteLine(file0Entry.Value.ToString());
                                break;
                            }

                            else if ((int)file0Entry.Key > lineNumber)
                            {
                                file0Writer.WriteLine("0");
                                break;
                            }
                        }
                    }

                    file0Writer.Close();

                    if (fileToWrite.Location >= 238 || fileToWrite.Plot >= 208)
                    {
                        File.Copy(Constants.SavesPath + fileToWrite.SaveName + "//file0", Constants.SavesPath + fileToWrite.SaveName + "//file8", true);
                    }
                    return(true);
                }

                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("An exception occurred when writing the save file. Cannot continue. The exception was: \n\n" + ex, "Error!",
                                                   MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
            }
Example #5
0
            //GetClosestEnding checks variables within the SAVEFile and returns the route that most closely matches the SAVEFile content
            public static Routes.GameRoutes GetClosestRoute(SAVEFile actualSave)
            {
                Dictionary <Routes.GameRoutes, int> likenessDict = new Dictionary <Routes.GameRoutes, int>();

                int likeness = 0;

                if (actualSave.pacifistStage == 2)
                {
                    return(Routes.GameRoutes.TruePacifistDate);
                }

                else if (actualSave.pacifistStage == 11)
                {
                    return(Routes.GameRoutes.TruePacifistLab);
                }

                else if (actualSave.pacifistStage == 12)
                {
                    if (actualSave.Location == 331)
                    {
                        return(Routes.GameRoutes.TruePacifistAsrielTalk);
                    }

                    else if (actualSave.asrielDefeated)
                    {
                        return(Routes.GameRoutes.TruePacifistEpilogue);
                    }

                    else
                    {
                        return(Routes.GameRoutes.TruePacifistAsriel);
                    }
                }

                else if (actualSave.disableAlphysCalls && actualSave.disableHotlandPuzzles)
                {
                    return(Routes.GameRoutes.Genocide);
                }

                else
                {
                    Routes.GameRoutes[] routesToIgnore = new Routes.GameRoutes[] { Routes.GameRoutes.TruePacifistDate, Routes.GameRoutes.TruePacifistLab, Routes.GameRoutes.TruePacifistAsriel, Routes.GameRoutes.TruePacifistAsrielTalk, Routes.GameRoutes.TruePacifistEpilogue };
                    foreach (Routes.GameRoutes route in Enum.GetValues(typeof(Routes.GameRoutes)))
                    {
                        if (!routesToIgnore.Contains(route))
                        {
                            SAVEFile compareSave = new SAVEFile();
                            compareSave = SetSaveForRoute(compareSave, actualSave.Location, route);

                            foreach (var actualCharacterState in compareSave.GetType().GetProperties())
                            {
                                foreach (CharacterStates stateToCheck in Enum.GetValues(typeof(CharacterStates)))
                                {
                                    if ((CharacterStates)actualCharacterState.GetValue(actualCharacterState) == stateToCheck)
                                    {
                                        likeness++;
                                    }
                                }
                            }

                            foreach (var actualDateState in compareSave.GetType().GetProperties())
                            {
                                foreach (DateStates stateToCheck in Enum.GetValues(typeof(DateStates)))
                                {
                                    if ((DateStates)actualDateState.GetValue(actualDateState) == stateToCheck)
                                    {
                                        likeness++;
                                    }
                                }
                            }

                            if (compareSave.KillCount <= actualSave.KillCount)
                            {
                                likeness++;
                            }

                            if (Routes.GetMurderLevelForLocation(compareSave.Location, 16) == Routes.GetMurderLevelForLocation(actualSave.Location, 16))
                            {
                                likeness++;
                            }

                            likenessDict.Add(route, likeness);
                            likeness = 0;
                        }
                    }
                }

                return(likenessDict.Where(key => key.Value == likenessDict.Max(value => value.Value)).Select(key => key.Key).FirstOrDefault());
            }
Example #6
0
            //LoadSaveFile is the public function we can call from other classes and scopes to read file0 at the location of the saveFileDirectory parameter
            public static SAVEFile LoadSaveFile(string saveFileDirectory)
            {
                SAVEFile saveFile = readSaveFile(saveFileDirectory);

                return(saveFile);
            }