コード例 #1
0
        /// <summary>
        /// Exports all teams from the PES database and creates clubs and teams.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public async Task <List <Club> > ReadClubsAsync(string path)
        {
            MemoryStream memory = await this.CreateMemoryStreamAsync(path + teamsPath);

            var reader = new BinaryReader(memory);

            int index;
            int length = Convert.ToInt32(reader.BaseStream.Length / teamsBlock);

            //reader.BaseStream.Position = 0;
            //string one = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(teamsBlock));

            List <PESTeam> tempList = new List <PESTeam>();

            for (int i = 0; i < length; i++)
            {
                index = (i * teamsBlock);
                reader.BaseStream.Position = index;

                // Read the 11 4-Byte uint values which contain all the player data.
                uint coach     = reader.ReadUInt32();
                uint feeder    = reader.ReadUInt32();
                uint idXparent = reader.ReadUInt32();
                uint temp      = reader.ReadUInt32();
                uint stadium16 = reader.ReadUInt16();
                uint temp2     = reader.ReadUInt16();

                uint checks = reader.ReadUInt32();


                reader.BaseStream.Position = index + 24;
                string japName = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(45)).TrimEnd('\0');

                reader.BaseStream.Position = index + 94;
                string spanish = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(45)).TrimEnd('\0');

                reader.BaseStream.Position = index + 234;
                string english = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(45)).TrimEnd('\0');

                PESTeam team = new PESTeam()
                {
                    ManagerId    = coach,
                    Id           = idXparent,
                    StadiumId    = stadium16,
                    FeederTeamId = feeder,
                    Name         = english,
                    National     = (uint)(idXparent < 100 ? 1 : 0), // ToDo: (checks << 7) >> 26,
                    CountryId    = (checks << 23) >> 23
                };

                tempList.Add(team);
            }

            return(await ClubConverter.ConvertMany(tempList));
        }
コード例 #2
0
ファイル: ClubConverter.cs プロジェクト: baLR0n/coal-server
        /// <summary>
        /// Convert a DB-Club to the PES format.
        /// </summary>
        /// <param name="sourcePlayer"></param>
        /// <returns></returns>
        public static Task <PESTeam> ConvertBack(Club sourceClub)
        {
            PESTeam converted = new PESTeam()
            {
                Position = sourceClub.DatabasePosition,
                Id       = System.Convert.ToUInt32(sourceClub.SourceId),
                Name     = sourceClub.Name
            };

            return(Task.FromResult(converted));
        }
コード例 #3
0
ファイル: ClubConverter.cs プロジェクト: baLR0n/coal-server
        /// <summary>
        /// Converts a PES team to the DB format.
        /// </summary>
        /// <param name="sourcePlayer"></param>
        /// <returns></returns>
        public static Task <Club> Convert(PESTeam sourceTeam)
        {
            var  guid      = Guid.NewGuid().ToString();
            Club converted = new Club()
            {
                ClubId           = guid,
                FirstTeamId      = guid.ToString() + "T1",
                ReservesTeamId   = guid.ToString() + "T2",
                YouthTeamId      = guid.ToString() + "T3",
                SourceId         = sourceTeam.Id.ToString(),
                DatabasePosition = sourceTeam.Position,
                Name             = sourceTeam.Name,
                CountryId        = (int)sourceTeam.CountryId,
                IsNationalTeam   = sourceTeam.National == 1
            };

            return(Task.FromResult(converted));
        }