Esempio n. 1
0
        public static Dictionary <int, Staff> GetDataFileStaffDictionary(SaveGameFile savegame, SaveGameData gameData, out List <Staff> duplicateStaff)
        {
            Dictionary <int, Staff> dic = new Dictionary <int, Staff>();

            duplicateStaff = new List <Staff>();
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == DataFileType.Staff);
            var bytes     = GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);

            StaffConverter converter = new StaffConverter();

            foreach (var item in bytes)
            {
                var staff = converter.Convert(item);
                staff.Value = staff.Value * gameData.ValueMultiplier;
                staff.Wage  = staff.Wage * gameData.ValueMultiplier;

                if (staff.StaffPlayerId != -1)
                {
                    if (dic.ContainsKey(staff.StaffPlayerId))
                    {
                        duplicateStaff.Add(staff);
                    }
                    else
                    {
                        dic.Add(staff.StaffPlayerId, staff);
                    }
                }
            }

            return(dic);
        }
Esempio n. 2
0
        public static Dictionary <int, T> GetDataFileConvertedIdDictionary <T>(ITupleConverter <T> converter, SaveGameFile savegame, DataFileType type, out List <T> duplicates) where T : class
        {
            duplicates = new List <T>();
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == type);
            var bytes     = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);

            Dictionary <int, T> dic        = new Dictionary <int, T>();
            List <T>            invalidIds = new List <T>();

            foreach (var item in bytes)
            {
                var converted = converter.Convert(item);

                if (converted.Item1 == -1)
                {
                    invalidIds.Add(converted.Item2 as T);
                }
                else
                {
                    if (dic.ContainsKey(converted.Item1))
                    {
                        duplicates.Add(converted.Item2 as T);
                    }
                    else
                    {
                        dic.Add(converted.Item1, converted.Item2 as T);
                    }
                }
            }

            return(dic);
        }
Esempio n. 3
0
        private static List <T> GetDataFileConverted <T>(SaveGameFile savegame, DataFileType type)
        {
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == type);
            var bytes     = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);
            var converter = ConverterFactory.CreateConverter <T>();
            var collect   = ConvertToCMObject <T>(bytes, converter).ToList();

            return(collect);
        }
Esempio n. 4
0
        private static void LoadGameData(SaveGameFile savegame)
        {
            var general   = savegame.DataBlockNameList.First(x => x.FileType == DataFileType.General);
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == DataFileType.General);

            ByteHandler.GetAllDataFromFile(general, savegame.FileName, fileFacts.DataSize);

            var fileData = ByteHandler.GetAllDataFromFile(general, savegame.FileName, fileFacts.DataSize);

            savegame.GameDate = ByteHandler.GetDateFromBytes(fileData[0], fileFacts.DataSize - 8).Value;
        }
Esempio n. 5
0
        private static Dictionary <int, string> GetDataFileStringsDictionary(SaveGameFile savegame, DataFileType type)
        {
            Dictionary <int, string> fileContents = new Dictionary <int, string>();
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == type);
            var fileData  = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);

            for (int i = 0; i < fileData.Count; i++)
            {
                fileContents.Add(i, ByteHandler.GetStringFromBytes(fileData[i], 0, fileFacts.StringLength));
            }

            return(fileContents);
        }
Esempio n. 6
0
        private static List <PlayerData> GetDataFilePlayerData(SaveGameFile savegame)
        {
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == DataFileType.Players);
            var bytes     = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);
            var converter = new PlayerDataConverter();
            var collect   = new List <PlayerData>();

            foreach (var source in bytes)
            {
                collect.Add(converter.Convert(source));
            }

            return(collect);
        }
Esempio n. 7
0
        public static Dictionary <int, Club_Comp> GetDataFileClubCompetitionDictionary(SaveGameFile savegame)
        {
            Dictionary <int, Club_Comp> dic = new Dictionary <int, Club_Comp>();
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == DataFileType.Club_Comps);
            var bytes     = GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);

            var converter = new ClubCompConverter();

            foreach (var item in bytes)
            {
                var comp = converter.Convert(item);
                dic.Add(comp.Id, comp);
            }

            return(dic);
        }
Esempio n. 8
0
        public static Dictionary <int, Nation> GetDataFileNationDictionary(SaveGameFile savegame)
        {
            Dictionary <int, Nation> dic = new Dictionary <int, Nation>();
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == DataFileType.Nations);
            var bytes     = GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);

            NationConverter converter = new NationConverter();

            foreach (var item in bytes)
            {
                var nation = converter.Convert(item);

                if (nation.Id != -1)
                {
                    if (!dic.ContainsKey(nation.Id))
                    {
                        dic.Add(nation.Id, nation);
                    }
                }
            }

            return(dic);
        }
Esempio n. 9
0
        public static Dictionary <int, Club> GetDataFileClubDictionary(SaveGameFile savegame)
        {
            Dictionary <int, Club> dic = new Dictionary <int, Club>();
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == DataFileType.Clubs);
            var bytes     = GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);

            ClubConverter converter = new ClubConverter();

            foreach (var item in bytes)
            {
                var club = converter.Convert(item);

                if (club.ClubId != -1)
                {
                    if (!dic.ContainsKey(club.ClubId))
                    {
                        dic.Add(club.ClubId, club);
                    }
                }
            }

            return(dic);
        }