Example #1
0
        internal async Task SavePokemonInfo(PokemonInfoTable table, ReferencedGarc garcPokeInfo)
        {
            Assertions.AssertVersion(this.Version, table.GameVersion);

            var files = await garcPokeInfo.GetFiles();

            files[garcPokeInfo.Garc.FileCount - 1] = table.Write();

            await garcPokeInfo.SetFiles(files);
        }
Example #2
0
        internal async Task SaveLearnsets(IEnumerable <Learnset> learnsets, ReferencedGarc garcLearnsets)
        {
            var list = learnsets.ToList();

            foreach (var l in list)
            {
                Assertions.AssertVersion(this.Version, l.GameVersion);
            }

            var files = list.Select(l => l.Write()).ToArray();

            await garcLearnsets.SetFiles(files);
        }
Example #3
0
        internal async Task SaveMoves(IEnumerable <Move> moves, ReferencedGarc garcMoves)
        {
            var list = moves.ToList();

            foreach (var move in list)
            {
                Assertions.AssertVersion(this.Version, move.GameVersion);
            }

            if (this.Version.IsORAS() || this.Version.IsGen7())
            {
                var file = Mini.PackMini(list.Select(m => m.Write()).ToArray(), "WD");
                await garcMoves.SetFile(0, file);
            }
            else
            {
                await garcMoves.SetFiles(list.Select( m => m.Write()).ToArray());
            }
        }
Example #4
0
        internal async Task SaveEncounterData(IEnumerable <Gen6.EncounterWild> encounters, ReferencedGarc garcEncounters)
        {
            var array = encounters.ToArray();
            var files = await garcEncounters.GetFiles();

            var zoneDataFileIndex = garcEncounters.Garc.FileCount - this.ZoneDataPositionFromEnd;

            Assertions.AssertLength(zoneDataFileIndex, array, exact: true);

            for (var i = 0; i < array.Length; i++)
            {
                if (!array[i].HasEntries)
                {
                    continue;
                }

                var encounterBuffer = array[i].Write();

                if (this.Version.IsORAS())                   // Have to write encounter zone data to DexNav database too
                {
                    // Last file is dexNavData
                    const int Offset       = 0xE;
                    var       dexNavData   = files[files.Length - 1];
                    var       entryPointer = BitConverter.ToInt32(dexNavData, (i + 1) * sizeof(int)) + Offset;

                    var dataPointer = BitConverter.ToInt32(encounterBuffer, Gen6.EncounterWild.DataOffset);
                    dataPointer += array[i].DataStart;
                    var dataLength = array[i].GetAllEntries().Count() * Gen6.EncounterWild.Entry.Size;

                    Array.Copy(encounterBuffer, dataPointer, dexNavData, entryPointer, dataLength);
                }

                files[i] = encounterBuffer;
            }

            await garcEncounters.SetFiles(files);
        }
Example #5
0
        internal void SaveTmsHms(TmsHms tmsHms, CodeBin codeBin)
        {
            Assertions.AssertVersion(this.Version, tmsHms.GameVersion);

            codeBin.WriteStructure(tmsHms);
        }