示例#1
0
        public static XDocument BuildXml(BattleDataOptions battleData, FighterDataOptions fighterData)
        {
            var type = fighterData.GetFighters().GetType().Name.ToLower();

            type = type.Remove(type.Length - 2);

            XDocument doc =
                new XDocument(new XDeclaration("1.0", "utf-8", null),
                              new XElement("struct",
                                           // <list hash="battle_data_tbl">	// <*DataList.Type* hash="*DataTbl.Type*">
                                           new XElement(type,
                                                        new XAttribute("hash", battleData.GetXmlName()),
                                                        //<struct index="0">	// <struct index="*DataListItem.GetIndex*">
                                                        battleData.GetBattles().Select(battle =>
                                                                                       battle.GetAsXElement(battleData.GetBattleIndex(battle)
                                                                                                            )
                                                                                       )
                                                        ),
                                           // <list hash="fighter_data_tbl">	// <*DataList.Type* hash="*DataTbl.Type*">
                                           new XElement(type,
                                                        new XAttribute("hash", fighterData.GetXmlName()),
                                                        //<struct index="0">	// <struct index="*DataListItem.GetIndex*">
                                                        fighterData.GetFighters().Select(fighter =>
                                                                                         fighter.GetAsXElement(fighterData.GetFighterIndex(fighter)
                                                                                                               )
                                                                                         )
                                                        )
                                           )
                              );

            return(doc);
        }
示例#2
0
        public void EmptySpiritData()
        {
            var options = dataOptions.OfType <BattleDataOptions>();

            battleData  = new BattleDataOptions();
            fighterData = new FighterDataOptions();
        }
示例#3
0
        // Replace Save calls to calls here.
        public static void SaveUnencrypted(BattleDataOptions battleData, FighterDataOptions fighterData, string fileLocation, string fileName)
        {
            fileLocation = FixFolderEndPath(fileLocation);

            // Save the version for local editing.
            Directory.CreateDirectory(fileLocation);

            SaveToFile(ConvertDataToXDocument(battleData, fighterData), fileLocation + fileName);
        }
示例#4
0
        public static void SaveEncrypted(BattleDataOptions battleData, FighterDataOptions fighterData, string fileLocation, string fileName, bool useFolderStructure = false)
        {
            fileLocation = FixFolderEndPath(fileLocation);

            // Save an encrypted version for direct placement on SD card.
            if (useFolderStructure)
            {
                fileLocation += GetFilePath(fileName);
            }
            Directory.CreateDirectory(fileLocation);
            SaveToEncryptedFile(ConvertDataToXDocument(battleData, fighterData), fileLocation + fileName);
        }
示例#5
0
        public static void SaveRandomized(BattleDataOptions battleData, FighterDataOptions fighterData, int seed = -1, int iteration = 0)
        {
            // Do multiple randomizers, in case an impossible battle happens.
            var fileName         = config.file_name_encr;
            var randomizerString = iteration > 0 ? ".Randomizer " : "Randomizer ";
            var directory        = config.file_directory_randomized + randomizerString + seed + " " + iteration; // Randomizer ### 1

            Save(battleData, fighterData, directory, fileName, unencrypted: false, useFolderStructure: true, saveSpiritTitles: false);

            CopyPreloadFiles(directory);
            CopySpiritImages(directory);
        }
示例#6
0
        public static void Save(BattleDataOptions battleData, FighterDataOptions fighterData, string fileLocation, string fileName, SpiritDataOptions spiritData = null, bool unencrypted = true, bool encrypted = true, bool useFolderStructure = false, bool saveSpiritTitles = true)
        {
            fileLocation += @"\";

            if (unencrypted)
            {
                var pathMod = useFolderStructure ? "" : config.unencr_sub;
                SaveUnencrypted(battleData, fighterData, fileLocation + pathMod, fileName);
            }
            if (encrypted)
            {
                SaveEncrypted(battleData, fighterData, fileLocation, fileName, useFolderStructure);
                if (spiritData?.HasData() ?? false)
                {
                    var loc = MiscDbsToSave();
                    SaveEncrypted(spiritData, Path.GetDirectoryName(loc), Path.GetFileName(loc));
                }
            }

            if (saveSpiritTitles)
            {
                SaveSpiritTitles(battleData.GetBattles(), config.file_directory_preload);
            }
        }
示例#7
0
 public void ImportBattle(BattleDataOptions battles, FighterDataOptions fighters)
 {
     battleData.ReplaceBattles(battles);
     fighterData.ReplaceFighters(fighters);
 }
示例#8
0
 public static XDocument ConvertDataToXDocument(BattleDataOptions battleData, FighterDataOptions fighterData)
 {
     return(XmlHelper.BuildXml(battleData, fighterData));
 }