コード例 #1
0
ファイル: Manager.cs プロジェクト: Puppetplay/BeThe2016_VER02
        // 타자의 분석정보를 가져온다.
        private HitterInfoDetail GetDetailHitterInfo(Int32 playerId,
                                                     BeThe.DataAnalyzer.Manager analyzer, String teamInitial)
        {
            // 연속안타일수를 구한다.
            Int32 hitDay = analyzer.GetHitDay(teamInitial, playerId);
            // HitterInfoDetail 클래스 다시 코딩

            Boolean isAllDayHit5        = analyzer.IsAllDayHit(teamInitial, playerId, 5);
            Boolean isAllDayHit3        = analyzer.IsAllDayHit(teamInitial, playerId, 4);
            Boolean isLongHit           = analyzer.IsLongHitLastGame(teamInitial, playerId, 2);
            Boolean isAllDayFirstNumber = analyzer.IsAllFastNumber(teamInitial, playerId, 4);
            Int32   hitCount            = analyzer.GetHitNumberForNDays(teamInitial, playerId, 3);
            Double  hitRatio            = analyzer.GetHitRatio(teamInitial, playerId, 3);
            String  name = analyzer.GetPlayerName(playerId);

            return(new HitterInfoDetail
            {
                IsAllDayFirstNumber = isAllDayFirstNumber,
                PlayerId = playerId,
                PlayerName = name,
                IsAllDayHit3 = isAllDayHit3,
                IsAllDayHit5 = isAllDayHit5,
                IsLongHit = isLongHit,
                HitCount = hitCount,
                HitRatio = hitRatio,
            });
        }
コード例 #2
0
        //  한경기의 한쪽 팀의 분석정보를 가져온다.
        private List <BatterInfo> GetAnalyzerData(Match match, AttackType attckType,
                                                  String teamInitial, DateTime dateTime, Int32 alldayHitcount)
        {
            // 경기를 가져온다.
            DatabaseManager dbMgr     = new DatabaseManager();
            var             players   = dbMgr.SelectAll <Player>();
            var             matches   = dbMgr.SelectAll <Match>();
            var             schedules = dbMgr.SelectAll <Schedule>();
            var             ths       = dbMgr.SelectAll <Th>();
            var             bats      = dbMgr.SelectAll <Bat>();

            ThType tyType = attckType == AttackType.Home ? ThType.말 : ThType.초;

            // 지난 데이터의 분석기 생성
            BeThe.DataAnalyzer.Manager analyzer = new BeThe.DataAnalyzer.Manager();
            analyzer.MaxDateTime = dateTime;

            var   batterInfos = new List <BatterInfo>();
            Int32 pitcherId;

            // 당일 선발투수 가져오기(분석시 입력 혹은 크롤링 구현)
            try
            {
                pitcherId = (from t in ths
                             join b in bats
                             on t.Id equals b.ThId
                             where t.MatchId == match.Id &&
                             t.Number == 1 && t.ThType == tyType
                             select b).First().PitcherId;



                // 투수 정보 가져오기
                Boolean isQualityStart = analyzer.IsQualityStart(pitcherId);
                if (isQualityStart)
                {
                    return(batterInfos);
                }
            }
            catch
            {
                return(batterInfos);
            }

            // 타자리스트 얻어오기
            var hitters = analyzer.GetStartPlayerForNDays(teamInitial, 3);

            foreach (var hitter in hitters)
            {
                try
                {
                    var   hitRatio        = analyzer.GetHitRatio(teamInitial, hitter.PlayerId, 3);
                    var   allHitRatio     = analyzer.GetHitRatio(teamInitial, hitter.PlayerId, 100);
                    var   isAllFastNumber = analyzer.IsAllFastNumber(teamInitial, hitter.PlayerId, 3);
                    Int32 hitCount        = analyzer.GetHitNumberForNDays(teamInitial, hitter.PlayerId, 1);
                    if (hitRatio > 0.33 && allHitRatio > 0.3 && isAllFastNumber && (hitCount < 2))
                    {
                        var batterInfo = new BatterInfo();
                        batterInfo.PlayerId  = hitter.PlayerId;
                        batterInfo.Name      = hitter.Name;
                        analyzer.MaxDateTime = analyzer.MaxDateTime.AddDays(-1);
                        batterInfo.HitRatio  = analyzer.GetHitRatio(teamInitial, hitter.PlayerId, 7);
                        analyzer.MaxDateTime = analyzer.MaxDateTime.AddDays(1);
                        batterInfos.Add(batterInfo);
                    }
                }
                catch
                {
                }
            }
            return(batterInfos);
        }