public static void ProcessClubData(OdbcDataReader reader)
        {
            int ClubCountFile = 0, ClubCountDB = 0;

            logger.Info("Started Processing Club Details");
            List <ClubEntity> sList = new List <ClubEntity>();

            while (reader.Read())
            {
                sList.Add(
                    new ClubEntity()
                {
                    ClubCode = reader["Team_abbr"].ToString(),
                    ClubName = reader["Team_name"].ToString()
                });
            }
            List <ClubEntity> dList = new List <ClubEntity>();

            ClubCountFile = sList.Count;
            dList         = ClubRepo.GetClubs();

            List <ClubEntity> newClub = sList.Except(dList).ToList();

            ClubCountDB = newClub.Count;
            if (newClub.Count != 0)
            {
                foreach (ClubEntity x in newClub)
                {
                    ClubRepo.AddClub(x);
                }
            }
            logger.Info($"Total Clubs in File :{ ClubCountFile }");
            logger.Info($"New Clubs added to Database :{ ClubCountDB }");
            logger.Info("Processing Club Details Completed");
        }
Exemple #2
0
        public static void SimulateRound(int round)
        {
            List <(int id, int host, int visitor)> games = ScheduleRepo.GetRound(round);
            Random rnd = new Random();

            foreach (var game in games)
            {
                double visitorLuck = rnd.Next(8, 15) / 10.0;
                double hostLuck    = rnd.Next(8, 15) / 10.0;

                Dictionary <string, double> host    = game.host == ClubStatus.ClubId ? Calculation.GetSquad() : Calculation.GetBotSquad(game.host);
                Dictionary <string, double> visitor = game.visitor == ClubStatus.ClubId ? Calculation.GetSquad() : Calculation.GetBotSquad(game.visitor);

                int hostChances    = (int)((host["mid"] * 2 - visitor["def"]) * 1.1 * hostLuck / 11);
                int visitorChances = (int)((visitor["mid"] * 2 - host["def"]) * visitorLuck / 11);

                double hostGoalChance    = (host["st"] * 2 - visitor["gk"]) * 1.1 * hostLuck / 300;
                double visitorGoalChance = (visitor["st"] * 2 - host["gk"]) * visitorLuck / 300;

                int hostGoals    = (int)(Math.Round((hostChances < 0 ? 0 : hostChances) * (hostGoalChance < 0.20 ? 0 : hostGoalChance)));
                int visitorGoals = (int)(Math.Round((visitorChances < 0 ? 0 : visitorChances) * (visitorGoalChance < 0.20 ? 0 : visitorGoalChance)));

                ScheduleRepo.UpdateGame(game.id, hostGoals, visitorGoals);
                ClubRepo.UpdateTable(game.host, hostGoals, visitorGoals);
                ClubRepo.UpdateTable(game.visitor, visitorGoals, hostGoals);
            }
        }
Exemple #3
0
        public static void ProcessClubData(OdbcDataReader reader)
        {
            logger.Info("Started Processing Club Details");
            while (reader.Read())
            {
                ClubEntity club = new ClubEntity();
                club.ClubCode = reader["Team_abbr"].ToString();
                club.ClubName = reader["Team_name"].ToString();

                try
                {
                    ClubRepo.AddClub(club);
                }
                catch (Exception e)
                {
                    if (e.Message.Contains("Violation of PRIMARY KEY constraint"))
                    {
                        logger.Info("Duplicate:" + club.ClubCode);
                    }
                }

                finally { }
            }
            logger.Info("Processing Club Details Completed");
        }
Exemple #4
0
 public static void NextSeason()
 {
     Contract();
     ClubStatus.Round = ClubStatus.LeagueId == 2 ? 5 : 1;
     ClubStatus.SeasonEnd.AddYears(1);
     ClubStatus.SeasonStart.AddYears(1);
     ClubStatus.CurrentDate = ClubStatus.LeagueId == 2 ? new DateTime(ClubStatus.SeasonStart.Year, 8, 19) : new DateTime(ClubStatus.SeasonStart.Year, 7, 19);
     NewSchedule(1);
     NewSchedule(2);
     PlayerRepo.UpdateOve();
     Regen();
     Retire();
     ClubRepo.Reset();
     PlayerRepo.UpdateVal();
     ClubStatus.SerializeSave();
 }
Exemple #5
0
 public TeamViewModel()
 {
     CurrentClub = ClubRepo.GetYourClub(ClubStatus.ClubName);
 }