Пример #1
0
        private List<Pick> GetBestBatters(Match match)
        {
            List<Pick> picks = new List<Pick>();

            var lineUps = dbMgr.SelectAll<LineUp>();

            // 홈팀 타자 가지고오기
            var homeTeamLineUps = from l in lineUps
                                  where l.MatchId == match.Id && l.AttackType == AttackType.Home
                                  && l.EntryType == EntryType.Starting
                                  select l;

            // 어웨이팀 타자 가지고 오기
            var awayTeamLineUps = from l in lineUps
                                  where l.MatchId == match.Id && l.AttackType == AttackType.Away
                                    && l.EntryType == EntryType.Starting
                                  select l;

            // 투수 가지고 오기
            var matchs = dbMgr.SelectAll<Match>();
            var schedules = dbMgr.SelectAll<Schedule>();
            var ths = dbMgr.SelectAll<Th>();
            var bats = dbMgr.SelectAll<Bat>();

            var players = dbMgr.SelectAll<Player>();

            var queryTh = from m in matchs
                          join s in schedules
                          on m.GameId equals s.GameId
                          join t in ths
                          on m.Id equals t.MatchId
                          where m.GameId == match.GameId && t.Number == 1
                          select t;

            var queryPitcher = (from t in queryTh
                                join b in bats
                                on t.Id equals b.ThId
                                join p in players
                                on b.PitcherId equals p.PlayerId
                                where b.DetailResult.StartsWith("1번")
                                select new { PlayerId = p.PlayerId, Name = p.Name }).ToList();

            var homeTeamPitcher = queryPitcher.ToList()[0];
            var awayTeamPitcher = queryPitcher.ToList()[1];

            foreach (var batter in homeTeamLineUps)
            {
                var ratio = CalcRatio(match.GameId, batter.PlayerId, awayTeamPitcher.PlayerId);
                Double addRatio = ((10 - batter.BatNumber) * 0.02);
                ratio = ratio + addRatio;
                var pick = new Pick();
                pick.MatchId = match.Id;
                pick.PlayerId = batter.PlayerId;
                pick.Ratio = ratio;
                picks.Add(pick);
            }

            foreach (var batter in awayTeamLineUps)
            {
                var ratio = CalcRatio(match.GameId, batter.PlayerId, homeTeamPitcher.PlayerId);
                Double addRatio = ((10 - batter.BatNumber) * 0.05);
                ratio = ratio + addRatio;
                var pick = new Pick();
                pick.MatchId = match.Id;
                pick.PlayerId = batter.PlayerId;
                pick.Ratio = ratio;
                picks.Add(pick);
            }
            return picks;

        }
Пример #2
0
        private List <Pick> GetBestBatters(Match match)
        {
            List <Pick> picks = new List <Pick>();

            var lineUps = dbMgr.SelectAll <LineUp>();

            // 홈팀 타자 가지고오기
            var homeTeamLineUps = from l in lineUps
                                  where l.MatchId == match.Id && l.AttackType == AttackType.Home &&
                                  l.EntryType == EntryType.Starting
                                  select l;

            // 어웨이팀 타자 가지고 오기
            var awayTeamLineUps = from l in lineUps
                                  where l.MatchId == match.Id && l.AttackType == AttackType.Away &&
                                  l.EntryType == EntryType.Starting
                                  select l;

            // 투수 가지고 오기
            var matchs    = dbMgr.SelectAll <Match>();
            var schedules = dbMgr.SelectAll <Schedule>();
            var ths       = dbMgr.SelectAll <Th>();
            var bats      = dbMgr.SelectAll <Bat>();

            var players = dbMgr.SelectAll <Player>();

            var queryTh = from m in matchs
                          join s in schedules
                          on m.GameId equals s.GameId
                          join t in ths
                          on m.Id equals t.MatchId
                          where m.GameId == match.GameId && t.Number == 1
                          select t;

            var queryPitcher = (from t in queryTh
                                join b in bats
                                on t.Id equals b.ThId
                                join p in players
                                on b.PitcherId equals p.PlayerId
                                where b.DetailResult.StartsWith("1번")
                                select new { PlayerId = p.PlayerId, Name = p.Name }).ToList();

            var homeTeamPitcher = queryPitcher.ToList()[0];
            var awayTeamPitcher = queryPitcher.ToList()[1];

            foreach (var batter in homeTeamLineUps)
            {
                var    ratio    = CalcRatio(match.GameId, batter.PlayerId, awayTeamPitcher.PlayerId);
                Double addRatio = ((10 - batter.BatNumber) * 0.02);
                ratio = ratio + addRatio;
                var pick = new Pick();
                pick.MatchId  = match.Id;
                pick.PlayerId = batter.PlayerId;
                pick.Ratio    = ratio;
                picks.Add(pick);
            }

            foreach (var batter in awayTeamLineUps)
            {
                var    ratio    = CalcRatio(match.GameId, batter.PlayerId, homeTeamPitcher.PlayerId);
                Double addRatio = ((10 - batter.BatNumber) * 0.05);
                ratio = ratio + addRatio;
                var pick = new Pick();
                pick.MatchId  = match.Id;
                pick.PlayerId = batter.PlayerId;
                pick.Ratio    = ratio;
                picks.Add(pick);
            }
            return(picks);
        }