Beispiel #1
0
        /// <summary>
        /// For Players we don't copy PGID, TGID, POID = Player Id, Team Id , Player Original Id
        /// </summary>
        /// <param name="continuation"></param>
        /// <param name="playersSource"></param>
        /// <param name="depthChartSource"></param>
        /// <param name="playersDestination"></param>
        /// <param name="depthChartDestination"></param>
        static void CopyPlayers(ContinuationData continuation, MaddenTable playersSource, MaddenTable depthChartSource, MaddenTable playersDestination, MaddenTable depthChartDestination)
        {
            // first we group by team, so what we have is a Dictionary key'd by team id, and each bucket has a Dictionary keyed by PlayerId
            var sourceTeams      = playersSource.lRecords.GroupBy(mr => mr["TGID"].ToInt32()).ToDictionary(group => group.Key, group => group.ToList().ToDictionary(mr => mr["PGID"].ToInt32()));
            var sourceDepthChart = depthChartSource.lRecords.GroupBy(mr => mr["TGID"].ToInt32()).ToDictionary(group => group.Key, group => group.ToList().ToDictionary(mr => new DepthChartKey(mr["PPOS"].ToInt32(), mr["ddep"].ToInt32())));
            var destTeams        = playersDestination.lRecords.GroupBy(mr => mr["TGID"].ToInt32()).ToDictionary(group => group.Key, group => group.ToList().ToDictionary(mr => mr["PGID"].ToInt32()));
            var destDepthChart   = depthChartDestination.lRecords.GroupBy(mr => mr["TGID"].ToInt32()).ToDictionary(group => group.Key, group => group.ToList().ToDictionary(mr => new DepthChartKey(mr["PPOS"].ToInt32(), mr["ddep"].ToInt32())));

            foreach (var key in destDepthChart.Keys)
            {
                // only copy over for valid teams
                if (key.IsValidTeam() == false)
                {
                    continue;
                }

                // uconn and nmsu are gone!
                if (key == 61 || key == 100)
                {
                    continue;
                }

                var sourceId = key.SourceKeyFromDesintation(out var value) ? value : key;

                CopyPlayersForTeam(sourceTeams[sourceId], sourceDepthChart[sourceId], destTeams[key], destDepthChart[key]);
            }
        }
Beispiel #2
0
        static void CopyCoachSkillTable(ContinuationData continuation, MaddenTable source, MaddenTable destination)
        {
            var levelsData = File.ReadAllText("levels.txt");
            Dictionary <int, int> levelsAndXp = null;

            using (var stream = new MemoryStream())
            {
                var bytes = Encoding.UTF8.GetBytes(levelsData);
                stream.Write(bytes, 0, bytes.Length);
                stream.Position = 0;
                var ser = new DataContractJsonSerializer(typeof(Dictionary <int, int>));
                levelsAndXp = (Dictionary <int, int>)ser.ReadObject(stream);
            }


            var exclude        = new[] { "CCID", "CFUC", "TOID", "BLCS", "NLVL" };
            var coachSkillKeys = File.ReadAllText("coachSkill.txt").Split(',').Where(s => !exclude.Contains(s)).ToArray();
            var sourceData     = source.CreateDictionary(
                record => continuation.OldToNewCoachMap[CreateCoachSkillKey(record)],
                record => continuation.OldToNewCoachMap.ContainsKey(CreateCoachSkillKey(record)),
                (a, b) =>
            {
                if (a["CLVL"].Data.ToInt32() > b["CLVL"].Data.ToInt32())
                {
                    return(a);
                }
                return(b);
            });
            var destinationData = destination.CreateDictionary(CreateCoachSkillKey, null);

            CopyData(
                sourceData,
                destinationData,
                null,

                /*                 (a,b,s,d)=>
                 *                   {
                 *                       var key = s["CLVL"].Data.ToInt32();
                 *                       if (levelsAndXp.ContainsKey(key) == false)
                 *                       {
                 *                           key++;
                 *                       }
                 *                       s["CEXP"].Data = levelsAndXp[key].ToString();
                 *                   },*/
                null,
                key => coachSkillKeys.Contains(key)
                );
        }
Beispiel #3
0
        static void CopyTeamData(ContinuationData continuation, MaddenTable teamSource, MaddenTable teamDestination)
        {
            Action <int, int, Dictionary <string, DBData>, Dictionary <string, DBData> > action = null;

            if (MessageBox.Show("W-L records and Championships will be set to 0", "Do you want to change Team W-L", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                action = SetTeamStatsToZero;
            }

            var columnsToCopy = new[] { "PCHV", "PPFV", "PAFV", "PTDV", "TMAR", "TDPB", "TOPB", "PCLV", "PAPV", "PCPV", "PPSV", "PTVV", "TPRX", "TPST", "TPSL", "TPSW", "TCRK", "TMRK", "TCHS" };

            CopyTeamData(
                teamSource.CreateDictionary(mr => mr["TGID"].ToInt32(), mr => mr.IsValidTeam()),
                teamDestination.CreateDictionary(mr => mr["TGID"].ToInt32(), mr => mr.IsValidTeam()),
                action,
                new string[0],
                ck => columnsToCopy.Contains(ck));
        }
Beispiel #4
0
        static void CopyCoachTable(ContinuationData continuationData, MaddenTable source, MaddenTable destination)
        {
            var exclude        = new[] { "CCID", "CLPS", "CFUC", "CSXP", "PTID", "TOID", "CLPS", "TGID" };
            var coachSkillKeys = File.ReadAllText("coachColumns.txt").Split(',').Where(s => !exclude.Contains(s)).ToArray();

            //CCID is coach ID
            //TGID is team id
            //COPS is position
            var destinationTable = destination.CreateDictionary(CreateCoachKey, mr => mr.IsValidTeam());
            var sourceTable      = source.CreateDictionary(CreateCoachKey, mr => mr.IsValidTeam());

            foreach (var key in destinationTable.Keys)
            {
                // dont modify uncc/ccu, you dont have to do this for the next continuation
                if (key.Team == 61 || key.Team == 100)
                {
                    continue;
                }

                // source key for gaso/appst are different
                var sourceKey = key.Team.SourceKeyFromDesintation(out var value) ? new CoachKey {
                    Team = value, Position = key.Position
                } : key;

                if (sourceTable.TryGetValue(sourceKey, out var sourceRow))
                {
                    var rowKey = sourceTable.Keys.First(myKey => myKey.Equals(sourceKey));

                    continuationData.CoachMapping.Add(
                        new CoachMapping
                    {
                        OldCoachId = rowKey.CoachId,
                        NewCoachId = key.CoachId,
                    });

                    CopyRecordData(sourceRow, destinationTable[key], fieldKey => coachSkillKeys.Contains(fieldKey));
                }
            }
        }
Beispiel #5
0
        public static void LoadSource(Form1 form, MaddenDatabase destination, CopyAction copyAction)
        {
            ContinuationData continuation   = new ContinuationData();
            OpenFileDialog   openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = @"D:\OneDrive\ncaa";
            openFileDialog.AddExtension     = true;
            openFileDialog.DefaultExt       = ".*";
            openFileDialog.Filter           = "(*.*)|*.*";
            openFileDialog.Multiselect      = false;
            openFileDialog.Title            = "Select MC02 file to open...";

            if (System.Windows.Forms.DialogResult.OK == openFileDialog.ShowDialog())
            {
                var maddenDB = new MaddenDatabase(openFileDialog.FileName);
                var tables   = new List <string>(new[] { "CSKL", "COCH", "DCHT", "PLAY", "TEAM", "RCPT", "RCPR" });

                var sourceTablesForRoster = maddenDB.lTables.Where(t => tables.Contains(t.Table.TableName)).ToList();
                continuation.Teams = MaddenTable.FindMaddenTable(maddenDB.lTables, "TEAM").lRecords.Where(mr => mr["TGID"].ToInt32().IsValidTeam()).Select(mr => new TeamData(mr)).ToList();

                // walked each table and field and add in the mapped elements
                foreach (MaddenTable mt in sourceTablesForRoster)
                {
                    MaddenTable mtmapped = MaddenTable.FindTable(lMappedTables, mt.Table.TableName);
                    mt.Abbreviation = mt.Table.TableName;
                    if (mtmapped != null)
                    {
                        mt.Name = mtmapped.Name;
                    }

                    foreach (Field f in mt.lFields)
                    {
                        Field fmapped = lMappedFields.FindField(f.name);
                        f.Abbreviation = f.name;
                        if (fmapped != null)
                        {
                            f.Name = fmapped.Name;
                        }
                    }
                }

                if (copyAction == CopyAction.Coach)
                {
                    CopyCoachTable(continuation, FindTable(sourceTablesForRoster, "COCH"), FindTable(destination.lTables, "COCH"));
                    CopyCoachSkillTable(continuation, FindTable(sourceTablesForRoster, "CSKL"), FindTable(destination.lTables, "CSKL"));

                    if (MessageBox.Show("Do you want to copy over Bowl Tie-ins, NCAA Records and School Records?", "Copy", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        CopyTeamRecordData(maddenDB.lTables[159], destination.lTables[159]);
                        //CopyNCAARecordData(maddenDB.lTables[91], destination.lTables[91]);
                        CopyBowlData(maddenDB.lTables[129], destination.lTables[129]);
                        CopyStadiumData(MaddenTable.FindTable(maddenDB.lTables, "STAD"), MaddenTable.FindTable(destination.lTables, "STAD"));
                    }
                }
                else if (copyAction == CopyAction.Roster)
                {
                    CopyPlayers(continuation, FindTable(sourceTablesForRoster, "PLAY"), FindTable(sourceTablesForRoster, "DCHT"), FindTable(destination.lTables, "PLAY"), FindTable(destination.lTables, "DCHT"));


                    if (MessageBox.Show("Recruit ratings and playbook, etc", "Do you want to copy over team data?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        CopyTeamData(continuation, FindTable(sourceTablesForRoster, "TEAM"), FindTable(destination.lTables, "TEAM"));
                    }
                }
                else if (copyAction == CopyAction.HSAA)
                {
                    var source = FindTable(sourceTablesForRoster, "RCPT");
                    RecruitAllAmericans.GetRecruits(source, FindTable(sourceTablesForRoster, "RCPR"));
                    var dest = FindTable(destination.lTables, "PLAY");
                    CopyHSAARoster(source, dest);
                }

                form.PostProcessMaps();
                form.UpdateTableBoundViews();
            }

            SerializeToFile(continuation, "continuationfile.txt");
        }