示例#1
0
    def set_gamecontapp_info(self, hitter, pitcher, inn, how):
        gamecontapp_data = record.Record().get_gamecontapp(
            self.game_key, hitter, pitcher, inn, how)

        if gamecontapp_data and self.gamecontapp_serno != gamecontapp_data[0][
                'serno']:
            # region 주루 상황 관련
            gamecontapp = gamecontapp_data[0]
            self.gamecontapp_serno = gamecontapp['serno']
            tb = gamecontapp['tb']
            base1 = int(
                gamecontapp['base1a']) if len(gamecontapp['base1a']) > 0 else 0
            base2 = int(
                gamecontapp['base2a']) if len(gamecontapp['base2a']) > 0 else 0
            base3 = int(
                gamecontapp['base3a']) if len(gamecontapp['base3a']) > 0 else 0
            base_state = [base1, base2, base3]
            self.base_player = ['', '', '']

            for i, b in enumerate(base_state):
                if b > 0:
                    for player in self.whole_selection_player[tb]:
                        if b == player['turn']:
                            self.base_player[i] = player['name']
                else:
                    self.base_player[i] = ''
            # endregion

            # region 점수 상황 관련
            self.tscore = gamecontapp['tscore']
            self.bscore = gamecontapp['bscore']
    def get_first_ball_info(cls, hitter, ball_type):
        data_dict = {'HITTER': hitter, 'OPPONENT': 'NA', 'LEAGUE': 'NA', 'PITCHER': 'NA', 'PITNAME': 'NA',
                     'GYEAR': 'NA', 'PITTEAM': 'NA', 'STATE': 'FIRSTBALL'}

        result = []
        first_ball_data = record.Record().get_hitter_first_ball(hitter)

        if first_ball_data:
            first_ball_info = first_ball_data[0]

            if ball_type == 'S':
                if first_ball_info['T_CNT_RNK'] < 30:
                    first_ball_dict = data_dict.copy()
                    first_ball_dict['HITNAME'] = first_ball_info['HITNAME']
                    first_ball_dict['RANK'] = 1
                    first_ball_dict['STATE_SPLIT'] = '0S'
                    first_ball_dict['PA'] = first_ball_info['PA']
                    first_ball_dict['RESULT'] = first_ball_info['T_CNT_RNK']  # 아무데이터
                    result.append(first_ball_dict)

            elif ball_type == 'T':
                if first_ball_info['S_CNT_RNK'] < 30:
                    first_ball_dict = data_dict.copy()
                    first_ball_dict['HITNAME'] = first_ball_info['HITNAME']
                    first_ball_dict['RANK'] = 1
                    first_ball_dict['STATE_SPLIT'] = '0T'
                    first_ball_dict['PA'] = first_ball_info['PA']
                    first_ball_dict['RESULT'] = first_ball_info['S_CNT_RNK']  # 아무데이터
                    result.append(first_ball_dict)

        return result
示例#3
0
    def get_game_info(cls, game_key):
        stadium_info_list = record.Record().get_gameinfo_data(game_key)
        if stadium_info_list:
            stadium_info = stadium_info_list[0]

        if stadium_info:
            temp = int(stadium_info['Temp']) * 0.1
            result = [{
                'STADIUM': stadium_info['Stadium'],
                'VTEAM': stadium_info['Vteam'],
                'HTEAM': stadium_info['Hteam'],
                'UMPC': stadium_info['Umpc'],
                'UMP1': stadium_info['Ump1'],
                'UMP2': stadium_info['Ump2'],
                'UMP3': stadium_info['Ump3'],
                'MOIS': stadium_info['Mois'],
                'CHAJUN': stadium_info['Chajun'],
                'TEMP': temp,
                'STATE': 'GAMEINFO',
                'STATE_SPLIT': 'GAMEINFO',
                'RANK': 1
            }]
            return result
        else:
            return None
示例#4
0
 def set_team_info_record(self, game_key):
     game_date = game_key[:4]
     tteam = self.TEAM_KOR[game_key[8:10]]
     bteam = self.TEAM_KOR[game_key[10:12]]
     line_up = record.Record().get_teamrank(game_date, tteam, bteam)
     self.team_info['tteam'] = [
         team for team in line_up if team['TEAM'] == tteam
     ][0]
     self.team_info['bteam'] = [
         team for team in line_up if team['TEAM'] == bteam
     ][0]
示例#5
0
    def __init__(self):
        self.BALL_STUFF = kor_dic.ball_stuff_dict
        self.TEAM_KOR = record.Record().get_team_korean_names()
        self.english_team = ['SK', 'NC', 'LG', 'KT']
        self.POSITION_WORD = kor_dic.position_dict
        self.WPA_HOW_KOR = kor_dic.how_kor_dict

        self.continue_ball_stuff = {}
        self.continue_ball_count_b = 0
        self.continue_ball_count_f = 0
        self.max_li = 0
    def __init__(self):
        self.BALL_STUFF = {'FAST': '패스트볼', 'CUTT': '커터', 'SLID': '슬라이더', 'CURV': '커브',
                       'CHUP': '체인지업', 'SPLI': '스플리터', 'SINK': '싱커볼', 'TWOS': '투심패스트볼',
                       'FORK': '포크볼', 'KNUC': '너클볼'}
        self.TEAM_KOR = record.Record().get_team_korean_names()
        self.english_team = ['SK', 'NC', 'LG', 'KT']
        self.POSITION_WORD = {"1": "P", "2": "C", "3": "1B", "4": "2B", "5": "3B", "6": "SS"
                              , "7": "LF", "8": "CF", "9": "RF", "D": "DH"}
        self.WPA_HOW_KOR = {'BB': '볼넷', 'BN': '번트', 'H1': '1루타', 'H2': '2루타', 'H3': '3루타',
                        'HB': '번트안타', 'HI': '내야안타', 'HP': '사구', 'HR': '홈런', 'IB': '고의4구', 'KP': '포일',
                        'KW': '폭투', 'SF': '희생플라이', 'SH': '희생번트', 'B2': '보크', 'PB': '패스트볼',
                        'P2': '포일', 'SB': '도루', 'SD': '더블스틸', 'ST': '트리플스틸', 'WP': '폭투', 'W2': '폭투'}

        self.continue_ball_stuff = {}
        self.continue_ball_count_b = 0
        self.continue_ball_count_f = 0
        self.max_li = 0
示例#7
0
    def __init__(self, game_key):
        self.TEAM_KOR = record.Record().get_team_korean_names()
        self.game_key = game_key
        self.game_score = None
        self.gamecontapp_serno = 0
        self.current_seq_no = 0
        self.last_how_seq_no = 0
        self.tscore = 0
        self.bscore = 0
        self.inning = 1
        self.base_player = ['', '', '']

        self.team_info = {}
        self.stadium_info_dict = {}
        self.starting_line_up = {}
        self.whole_selection_player = {}
        self.initialize_game_info(game_key)
示例#8
0
    def set_starting_line_up(self, game_key):
        line_up = record.Record().get_starting_line_up(game_key)

        if line_up:
            self.starting_line_up['T'] = [
                x for x in line_up if int(x['turn']) < 20
                and x['posi'][0] == '1' and x['tb'] == 'T'
            ]
            self.starting_line_up['B'] = [
                x for x in line_up if int(x['turn']) < 20
                and x['posi'][0] == '1' and x['tb'] == 'B'
            ]
            self.whole_selection_player['T'] = [
                x for x in line_up if x['tb'] == 'T'
            ]
            self.whole_selection_player['B'] = [
                x for x in line_up if x['tb'] == 'B'
            ]
示例#9
0
import time
import threading
import config
import argparse
from lib import record
from lib import game_app

# Program Start
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--gamekey", help="game key")
    parser.add_argument("--clear", help="game key")
    args = parser.parse_args()

    if args.clear:
        record.Record().set_clear_message_log()
        exit()

    if args.gamekey:
        game_id = args.gamekey
    else:
        game_id = '20170909SSHT0'  # 20170609SSHH0  20170912OBNC0 20170914SKOB0 20170926HHLT0 20170909NCHH0 20170923SSHH0
    sleep_second = config.SLEEP_TIME
    gm_app = game_app.GameApp(game_id)

    msg_thread = threading.Thread(target=gm_app.message_printer_thread,
                                  name='Message Thread')
    msg_thread.start()

    caster_thread = threading.Thread(target=gm_app.message_maker_thread,
                                     name='Score Table Thread')
示例#10
0
    def get_live_text_info(self, live_data):
        game_id = live_data['gameID']
        if live_data['bTop'] == 1:
            hit_team = game_id[8:10]
            pit_team = game_id[10:12]
            t_score = live_data['H_Run'] - live_data['A_Run']
        else:
            t_score = live_data['A_Run'] - live_data['H_Run']
            hit_team = game_id[10:12]
            pit_team = game_id[8:10]

        if t_score < 0:
            t = 'L'
        elif t_score == 0:
            t = 'D'
        else:
            t = 'W'

        if abs(t_score) == 1 or abs(t_score) == 0:
            score = "{0}{1}".format(abs(t_score), t)
        else:
            score = "{0}{0}".format(t)

        if t_score == 0:
            score_detail = "0D"
        else:
            score_detail = "{0}{1}".format(abs(t_score), t)

        if live_data['base1'] + live_data['base2'] + live_data['base3'] == 0:
            base = 'NOB'
        elif live_data['base2'] + live_data['base3'] > 0:
            base = 'SCORE_B'
        else:
            base = 'ONB'

        if live_data['base1'] + live_data['base2'] + live_data['base3'] == 0:
            base_detail = '0B'
        elif live_data[
                'base1'] > 0 and live_data['base2'] + live_data['base3'] == 0:
            base_detail = '1B'
        elif live_data[
                'base2'] > 0 and live_data['base1'] + live_data['base3'] == 0:
            base_detail = '2B'
        elif live_data[
                'base3'] > 0 and live_data['base1'] + live_data['base1'] == 0:
            base_detail = '3B'
        elif live_data['base1'] > 0 and live_data['base2'] > 0 and live_data[
                'base3'] == 0:
            base_detail = '12B'
        elif live_data['base1'] > 0 and live_data['base3'] > 0 and live_data[
                'base2'] == 0:
            base_detail = '13B'
        elif live_data['base2'] > 0 and live_data['base3'] > 0 and live_data[
                'base1'] == 0:
            base_detail = '23B'
        else:
            base_detail = '123B'

        hitter = live_data['batter']
        pitcher = live_data['pitcher']
        out_count = live_data['out']
        full_count = [live_data['ball'], live_data['strike'], live_data['out']]
        bat_order = live_data['batorder']
        ball_count = live_data['ballcount']
        text_style = live_data['textStyle']
        ball_type = live_data['ball_type']
        home_score = live_data['H_Run']
        away_score = live_data['A_Run']
        self.current_seq_no = live_data['seqNO']
        how = live_data['HOW']
        inning = live_data['inning']
        year = live_data['GYEAR']
        tb = 'T' if live_data['bTop'] == 1 else 'B'

        if bat_order > 0:
            hitname = record.Record().get_player_info(hitter)[0]['NAME']
            pitname = record.Record().get_player_info(pitcher)[0]['NAME']
            # hitname = [player['name'] for player in self.whole_selection_player['T' if live_data['bTop'] == 1 else 'B'] if player['pcode'] == hitter][0]
            # pitname = [player['name'] for player in self.whole_selection_player['B' if live_data['bTop'] == 1 else 'T'] if player['pcode'] == pitcher][0]
        else:
            pitname = ''
            hitname = ''

        result_dict = {
            'hitter': hitter,
            'hitteam': hit_team,
            'pitcher': pitcher,
            'pitteam': pit_team,
            'score': score,
            'base': base,
            'game_id': game_id,
            'out_count': out_count,
            'full_count': full_count,
            'base_detail': base_detail,
            'score_detail': score_detail,
            'batorder': bat_order,
            'ballcount': ball_count,
            'textStyle': text_style,
            'pitname': pitname,
            'hitname': hitname,
            'home_score': home_score,
            'away_score': away_score,
            'tb': tb,
            'seq_no': self.current_seq_no,
            'how': how,
            'inning': inning,
            'ball_type': ball_type,
            'gyear': year
        }
        return result_dict
示例#11
0
 def set_stadium_info(self, game_key):
     stadium_info_list = record.Record().get_gameinfo_data(game_key)
     if stadium_info_list:
         stadium_info = stadium_info_list[0]
         self.stadium_info_dict = stadium_info
示例#12
0
    def get_pts_ball_data(self, game_key, bat_order, ball_count, pitcher,
                          hitter, hit_type, pitname):
        result_list = []
        data_dict = {
            'SUBJECT': 'PITCHER',
            'OPPONENT': 'NA',
            'LEAGUE': 'NA',
            'PITNAME': 'NA',
            'GYEAR': 'NA',
            'PITTEAM': 'NA',
            'STATE': 'BALLINFO',
            'RANK': 1
        }

        data_list = record.Record().get_pitzone_info(game_key, bat_order,
                                                     ball_count, hitter,
                                                     pitcher)

        if not data_list:
            return None

        pitch_data = data_list[0]

        if pitch_data['stuff'] in self.BALL_STUFF:
            pitch_type = self.BALL_STUFF[pitch_data['stuff']]
            if pitch_data['stuff'] in self.continue_ball_stuff:
                self.continue_ball_stuff[pitch_data['stuff']] += 1
            else:
                self.continue_ball_stuff.clear()
                self.continue_ball_stuff[pitch_data['stuff']] = 1
        else:
            pitch_type = ''

        area_x = pitch_data['x']
        area_y = pitch_data['y']
        zone_x = pitch_data['zonex']
        zone_y = pitch_data['zoney']
        ball_type = pitch_data['ball']

        comment = ''

        if config.VERSION_LEVEL > 0:
            if ball_type == 'B':  # 볼 판정
                if hit_type == '우타':
                    if zone_x < 2:
                        comment = '바깥으로 빠진 '
                    elif zone_x > 6:
                        comment = '몸 안쪽 '
                else:
                    if zone_x < 2:
                        comment = '몸 안쪽 '
                    elif zone_x > 6:
                        comment = '바깥으로 빠진 '
                if 45 < area_x < 180 and 60 < area_y < 230:
                    comment = '스트라이크 같았는데요. '
            elif ball_type == 'T':  # 기다린 스트라이크
                if hit_type == '우타':  # 우타
                    if zone_x == 1 or zone_x == 2:  # 바깥쪽 스트라이크
                        if 45 < area_x < 60:
                            comment = '바깥쪽 꽉찬 스트라이크 '
                        else:
                            comment = '바깥쪽 스트라이크 '
                    elif zone_x == 6 or zone_x == 7:  # 몸쪽 스트라이크
                        if 210 < area_x < 235:
                            comment = '몸쪽 꽉찬 스크라이크 '
                        else:
                            comment = '몸쪽 스트라이크 '
                else:  # 좌타
                    if zone_x == 1 or zone_x == 2:  # 몸쪽 스트라이크
                        if 45 < area_x < 60:
                            comment = '몸쪽 꽉찬 스크라이크 '
                        else:
                            comment = '몸쪽 스트라이크 '
                    elif zone_x == 6 or zone_x == 7:  # 바깥쪽 스트라이크
                        if 210 < area_x < 235:
                            comment = '바깥쪽 꽉찬 스트라이크 '
                        else:
                            comment = '바깥쪽 스트라이크 '
            elif ball_type == 'S':  # 헛스윙
                if zone_y < 6:
                    comment = '낮은 공이였는데 휘둘렀어요. '

            ball_style_dict = data_dict.copy()
            ball_style_dict['PITNAME'] = pitcher
            ball_style_dict['COMMENT'] = comment
            ball_style_dict['HITTER'] = hitter
            ball_style_dict['STUFF'] = pitch_type
            ball_style_dict['SPEED'] = pitch_data['speed']
            ball_style_dict['STATE_SPLIT'] = 'BALLINFO'
            result_list.append(ball_style_dict)

            if ball_type == 'B':
                ball_dict = data_dict.copy()
                ball_dict['PITNAME'] = pitname
                ball_dict['COMMENT'] = comment
                ball_dict['STUFF'] = pitch_type
                ball_dict['STATE_SPLIT'] = 'BALLINFO_BALL'
                result_list.append(ball_dict)
        else:
            if ball_type == 'T':
                up_down = ''
                right_left = ''

                if area_y < 64:
                    y_distance = 64 - area_y
                elif area_y > 224:
                    y_distance = area_y - 224
                else:
                    y_distance = 0

                if area_x < 51:
                    x_distance = 51 - area_x
                elif area_x > 176:
                    x_distance = area_x - 176
                else:
                    x_distance = 0

                distance = math.sqrt(y_distance**2 + x_distance**2)

                if distance <= 10:
                    distance_kor = "걸친"
                elif distance <= 20:
                    distance_kor = "많이 빠진"
                else:
                    distance_kor = "굉장히 많이 빠진"

                # 상단
                if 51 < area_x < 176 and area_y < 64:
                    up_down = '위'
                # 하단
                elif 51 < area_x < 176 and area_y > 224:
                    up_down = '아래'

                # 오른쪽으로 많이 빠진 공
                if area_x > 176:
                    if hit_type == '우타':
                        right_left = '몸쪽'
                    else:
                        right_left = '바깥쪽'
                # 왼쪽으로 많이 빠진 공
                elif area_x < 51:
                    if hit_type == '우타':
                        right_left = '바깥쪽'
                    else:
                        right_left = '몸쪽'

                if right_left + up_down:
                    ball_area_dict = data_dict.copy()
                    ball_area_dict['PITNAME'] = pitcher
                    ball_area_dict['STUFF'] = pitch_type
                    ball_area_dict['SPEED'] = pitch_data['speed']
                    ball_area_dict['DISTANCE'] = distance_kor
                    ball_area_dict['BALL_COUNT'] = ball_count
                    if right_left and up_down:
                        ball_area_dict['AREA'] = "{} {}".format(
                            right_left, up_down)
                    elif right_left:
                        ball_area_dict['AREA'] = right_left
                    elif up_down:
                        ball_area_dict['AREA'] = up_down

                    ball_area_dict['STATE_SPLIT'] = 'BALL_AREA'
                    result_list.append(ball_area_dict)
            elif ball_type == 'B':
                if 51 < area_x < 176 and 64 < area_y < 224:
                    up_down = ''
                    right_left = ''

                    if 1 < zone_y < 4:
                        up_down = '위'
                    elif 4 < zone_y < 7:
                        up_down = '아래'

                    if 1 < zone_x < 4:
                        if hit_type == '우타':
                            right_left = '바깥쪽'
                        else:
                            right_left = '몸쪽'
                    elif 4 < zone_x < 7:
                        if hit_type == '우타':
                            right_left = '몸쪽'
                        else:
                            right_left = '바깥쪽'

                    ball_dict = data_dict.copy()
                    ball_dict['PITNAME'] = pitcher
                    ball_dict['STUFF'] = pitch_type
                    ball_dict['SPEED'] = pitch_data['speed']
                    ball_dict['BALL_COUNT'] = ball_count
                    if right_left and up_down:
                        ball_dict['AREA'] = "{} {}".format(right_left, up_down)
                    elif right_left:
                        ball_dict['AREA'] = right_left
                    elif up_down:
                        ball_dict['AREA'] = up_down
                    ball_dict['STATE_SPLIT'] = 'BALL_AREA_BALL'
                    result_list.append(ball_dict)
        return result_list
示例#13
0
    def get_explain_how_event(self, hitter, pitcher, inn, how):
        result_list = []
        data_dict = {'LEAGUE': 'SEASON', 'STATE': 'CURRENT_INFO'}
        defender_dict = {
            '1': "투수",
            '2': "포수",
            '3': "1루수",
            '4': "2루수",
            '5': "3루수",
            '6': "유격수",
            '7': "좌익수",
            '8': "중견수",
            '9': "우익수",
            '78': "좌중간",
            '89': "우중간",
            '67': "좌전",
            '77': "좌전",
            '88': "중전",
            '99': "우전"
        }
        base_dict = {'A': '1루', 'B': '2루', 'C': '3루'}
        out_count = ['0', '1', '2', '3']
        how_kor = {
            "HR": "홈런",
            "GR": "땅볼",
            "FL": "플라이",
            "ER": "실책",
            "H1": "1루타",
            "H2": "2루타",
            "H3": "3루타"
        }
        basic_how_list = ["H1", "H2", "H3", "HR"]

        gamecontapp_data = record.Record().get_gamecontapp(
            self.game_key, hitter, pitcher, inn, how)
        if not gamecontapp_data:
            return None

        gamecontapp = gamecontapp_data[0]
        if self.last_how_seq_no != gamecontapp['serno']:
            self.last_how_seq_no = gamecontapp['serno']

            how = gamecontapp['how']
            place = gamecontapp['place']
            runner = gamecontapp['rturn']
            field_list = list(
                filter(None, re.split('(\d+)', gamecontapp['field'])))

            how_event = data_dict.copy()

            if how == "FL":
                field = field_list[0]
                how_event['POS'] = defender_dict[field]
                if field_list[1] == 'E':
                    how_event['STATE_SPLIT'] = 'HOW_FL_ER'
                else:
                    how_event['STATE_SPLIT'] = 'HOW_FL'

                if place in base_dict:
                    how_event['BASE'] = base_dict[place]

            elif how == "BB":
                how_event['STATE_SPLIT'] = 'HOW_BB'
                if len(gamecontapp['base1a']) > 0 and len(
                        gamecontapp['base2a']) > 0 and len(
                            gamecontapp['base3a']) > 0:
                    how_event['BASE'] = '만'
                elif len(gamecontapp['base1a']) > 0 and len(
                        gamecontapp['base2a']) > 0:
                    how_event['BASE'] = '1, 2'
                else:
                    how_event['BASE'] = '1'

            elif how == "KK":
                how_event['STATE_SPLIT'] = 'HOW_KK'
            elif how == "GR":
                field = field_list[0]
                how_event['POS'] = defender_dict[field]
                if place in out_count:
                    how_event['STATE_SPLIT'] = 'HOW_GR'
                else:
                    how_event['STATE_SPLIT'] = 'HOW_GR_ER'

                if place in base_dict:
                    how_event['BASE'] = base_dict[place]

            elif how in basic_how_list:
                how_event['STATE_SPLIT'] = 'HOW_HIT'
                how_event['POS'] = defender_dict[field_list[1]]
                how_event['HIT'] = how_kor[how]

            if "STATE_SPLIT" in how_event:
                result_list.append(how_event)
                return result_list
            else:
                return None
示例#14
0
 def __init__(self):
     self.personal_dict = {}
     self.season_dict = {}
     self.total_dict = {}
     self.today_dict = {}
     self.TEAM_KOR = record.Record().get_team_korean_names()
     self.SCORE_KR = {
         "0D": "동점",
         "1W": "1점차 이기고 있을 때",
         "1L": "1점차 지고 있을 때",
         "WW": "이기고 있을 때",
         "LL": "지고 있을 때"
     }
     self.FLOAT_STATE = ['HRA', 'OBA', 'SLG']
     self.HITTER_STATE_KOR = {
         "HR": "홈런",
         "HIT": "안타",
         "H2": "2루타",
         "H3": "3루타",
         "BB": "볼넷",
         "SO": "삼진",
         "RBI": "타점",
         "HRA": "타율",
         "OBA": "출루율",
         "SLG": "장타율",
         "AB": "타수",
         "PA": "타석"
     }
     self.PITCHER_STATE = {
         "NO_HIT": "노히트로런",
         "SHO": "완봉승",
         "CG_W": "완투승",
         "CG_L": "완투패",
         "WINS": "승",
         "LOSSES": "패",
         "QS": "퀄리티스타트",
         "HOLDS": "홀드",
         "SAVES": "세이브",
         "HIT": "피안타",
         "HR": "피홈런",
         "HP": "사구",
         "PB": "범타",
         "SO": "삼진",
         "BB": "볼넷"
     }
     self.PITCHER_STATE_KOR = {
         "NO_HIT": "노히트로런 {}번",
         "SHO": "완봉승 {}번",
         "CG_W": "완투승 {}번",
         "CG_L": "완투패 {}번",
         "WINS": "{}승",
         "LOSSES": "{}패",
         "QS": "퀄리티스타트 {}개",
         "HOLDS": "홀드 {}개",
         "SAVES": "세이브 {}개",
         "HIT": "피안타 {}개",
         "HR": "피홈런 {}개",
         "PB": "범타 {}개",
         "HP": "사구 {}개",
         "SO": "삼진 {}개",
         "BB": "볼넷 {}개"
     }
     self.PITCHER_STATE_ORDER = [
         "NO_HIT", "SHO", "CG_W", "CG_L", "WINS", "LOSSES", "QS", "HOLDS",
         "SAVES", "HIT", "HR", "HP", "PB", "SO", "BB"
     ]
     self.df_template = connect_gsheet.Gspread().get_df_template()
示例#15
0
    def get_end_inn_info(self, live_dict):
        data_dict = {
            'LEAGUE': 'SEASON',
            'PITCHER': 'NA',
            'PITNAME': 'NA',
            'GYEAR': 'NA',
            'PITTEAM': 'NA',
            'STATE': 'END_INNING'
        }
        result_list = []
        game_id = live_dict['game_id']
        score_detail = live_dict['score_detail']
        score_simple = live_dict['score']
        seq_no = live_dict['seq_no']
        base_detail = live_dict['base_detail']
        out_count = live_dict['out_count']
        bat_order = live_dict['batorder']
        ball_count = live_dict['ballcount']
        full_count = live_dict['full_count']
        how = live_dict['how']
        inning = live_dict['inning']
        tb = live_dict['tb']
        hit_team = live_dict['hitteam']
        year = live_dict['gyear']
        home_team = game_id[10:12]
        away_team = game_id[8:10]

        df_record_matrix = record.Record().get_record_matrix_mix(game_id, year)
        df_inning_record_matrix = record.Record().get_ie_inningrecord(
            game_id, year)

        if df_record_matrix.empty or df_inning_record_matrix.empty:
            return None

        if int(inning) > 1 and tb == 'T':
            prev_inning = inning - 1
        else:
            prev_inning = inning

        df_inning = df_inning_record_matrix[
            (df_inning_record_matrix['tb'] == tb)
            & (df_inning_record_matrix['inning'] == prev_inning)]
        df_pa_record = df_record_matrix[(df_record_matrix['TB_SC'] == tb) & (
            df_record_matrix['INN_NO'] == prev_inning)]

        # region 타자 시점
        if df_inning['run'].values[0] == 0:
            # 무득점 : LI가 가장 높았을 때 & 득점권 상황 but 점수를 못 냄
            df_max_li = df_pa_record[df_pa_record['AFTER_LI_RT'] ==
                                     df_pa_record['AFTER_LI_RT'].max()]
            runner_sc = str(df_max_li['AFTER_RUNNER_SC'].values[0])
            if '2' in runner_sc or '3' in runner_sc:
                before_out_cn = df_max_li['BEFORE_OUT_CN'].values[0]
                before_runner_sc = str(df_max_li['BEFORE_RUNNER_SC'].values[0])
                hitter_code = df_max_li['BAT_P_ID'].values[0]
                how_kor = self.WPA_HOW_KOR[df_max_li['HOW_ID'].values[0]]
                hitter_name = record.Record().get_player_info(
                    hitter_code)[0]['NAME']
                no_score_dict = data_dict.copy()
                if before_out_cn == 0:
                    no_score_dict['BEFORE_OUT_CN'] = "무"
                else:
                    no_score_dict['BEFORE_OUT_CN'] = before_out_cn
                if before_runner_sc == '123':
                    no_score_dict['BEFORE_RUNNER_SC'] = "만루"
                elif before_runner_sc == '0':
                    no_score_dict['BEFORE_RUNNER_SC'] = ""
                else:
                    no_score_dict['BEFORE_RUNNER_SC'] = "{0}루".format(
                        ','.join(before_runner_sc))

                if runner_sc == '123':
                    no_score_dict['AFTER_RUNNER_SC'] = "만루"
                elif runner_sc == '0':
                    no_score_dict['AFTER_RUNNER_SC'] = ""
                else:
                    no_score_dict['AFTER_RUNNER_SC'] = "{0}루".format(
                        ','.join(runner_sc))
                no_score_dict['HOW_KOR'] = how_kor
                no_score_dict['HITNAME'] = hitter_name
                no_score_dict['STATE_SPLIT'] = 'NO_RUN_SCORE_BASE'
                result_list.append(no_score_dict)
        else:
            # 득점 : 시간 순서대로 득점(적시타, 홈런)상황
            for idx, row in df_pa_record.iterrows():
                before_score_gap = row['BEFORE_SCORE_GAP_CN']
                after_score_gap = row['AFTER_SCORE_GAP_CN']
                before_out_cn = row['BEFORE_OUT_CN']
                before_runner_sc = row['BEFORE_OUT_CN']
                how_kor = self.WPA_HOW_KOR[row['HOW_ID']]
                hitter_name = record.Record().get_player_info(
                    row['BAT_P_ID'])[0]['NAME']
                score_dict = data_dict.copy()

                if 'T' == row['TB_SC']:
                    score_cn = before_score_gap - after_score_gap
                else:
                    score_cn = after_score_gap - before_score_gap

                if before_out_cn == 0:
                    score_dict['BEFORE_OUT_CN'] = "무"
                else:
                    score_dict['BEFORE_OUT_CN'] = before_out_cn
                if before_runner_sc == '123':
                    score_dict['BEFORE_RUNNER_SC'] = "만루"
                elif before_runner_sc == '0':
                    score_dict['BEFORE_RUNNER_SC'] = ""
                else:
                    score_dict['BEFORE_RUNNER_SC'] = "{0}루".format(
                        ','.join(before_runner_sc))
                score_dict['HOW_KOR'] = how_kor
                score_dict['SCORE_CN'] = score_cn
                score_dict['HITNAME'] = hitter_name

                if before_score_gap == 0 and after_score_gap != 0:
                    score_dict['STATE_SPLIT'] = 'FIRST_GET_SCORE'
                elif before_score_gap != after_score_gap and row[
                        'HOW_ID'] != 'HR':
                    score_dict['STATE_SPLIT'] = 'GET_RBI_HIT'
                elif before_score_gap != after_score_gap and row[
                        'HOW_ID'] == 'HR':
                    score_dict['STATE_SPLIT'] = 'GET_HR_HIT'

                if 'STATE_SPLIT' in score_dict:
                    result_list.append(score_dict)
        # endregion 타자 시점

        # region 투수 시점
        if df_inning['run'].values[0] == 0:
            # 무실점 방어성공
            df_pitzone = record.Record().get_pitzone_df(game_id, year)
            df_pitzone = df_pitzone[(df_pitzone['tb'] == tb)
                                    & (df_pitzone['inning'] == prev_inning)]

            pitcher_count = df_pitzone.groupby(['PIT_P_ID']).count().shape[0]
            pitcher_name = record.Record().get_player_info(
                df_pitzone.iloc[0]['PIT_P_ID'])[0]['NAME']
            inning_ball_count = df_pitzone.shape[0]

            no_run_dict = data_dict.copy()
            no_run_dict['PITNAME'] = pitcher_name
            no_run_dict['BALL_COUNT'] = inning_ball_count
            # 투수 혼자 던진 공이 9개 이하 일 경우
            if pitcher_count == 1 and inning_ball_count <= 9:
                ball_count_dict = data_dict.copy()
                ball_count_dict['PITNAME'] = pitcher_name
                ball_count_dict['BALL_COUNT'] = inning_ball_count
                ball_count_dict['STATE_SPLIT'] = 'BALL_COUNT_UNDER_9'
                result_list.append(ball_count_dict)

            # 실점 위기
            if '3' in str(df_inning['AFTER_RUNNER_SC']):
                ball_count_dict = data_dict.copy()
                ball_count_dict['PITNAME'] = pitcher_name
                ball_count_dict['BALL_COUNT'] = inning_ball_count
                ball_count_dict['STATE_SPLIT'] = 'BALL_COUNT_UNDER_9'
                result_list.append(ball_count_dict)

            result_list.append(no_run_dict)
        else:
            # 실점
            pass
    def get_ball_style_data(self, game_key, bat_order, ball_count, pitcher, hitter, hit_type, pitname):
        result_list = []
        data_dict = {'SUBJECT': 'PITCHER', 'OPPONENT': 'NA', 'LEAGUE': 'NA', 'PITNAME': 'NA',
                       'GYEAR': 'NA', 'PITTEAM': 'NA', 'STATE': 'BALLINFO',
                       'RANK': 1}

        data_list = record.Record().get_pitzone_info(game_key, bat_order, ball_count, hitter, pitcher)

        if data_list:
            pitch_data = data_list[0]
            ball_style_dict = data_dict.copy()
            ball_dict = data_dict.copy()

            if pitch_data['stuff'] in self.BALL_STUFF:
                pitch_type = self.BALL_STUFF[pitch_data['stuff']]
                if pitch_data['stuff'] in self.continue_ball_stuff:
                    self.continue_ball_stuff[pitch_data['stuff']] += 1
                else:
                    self.continue_ball_stuff.clear()
                    self.continue_ball_stuff[pitch_data['stuff']] = 1
            else:
                pitch_type = ''

            area_x = pitch_data['x']
            area_y = pitch_data['y']
            zone_x = pitch_data['zonex']
            zone_y = pitch_data['zoney']
            ball_type = pitch_data['ball']
            comment = ''

            if ball_type == 'B':  # 볼 판정
                if hit_type == '우타':
                    if zone_x < 2:
                        comment = '바깥으로 빠진 '
                    elif zone_x > 6:
                        comment = '몸 안쪽 '
                else:
                    if zone_x < 2:
                        comment = '몸 안쪽 '
                    elif zone_x > 6:
                        comment = '바깥으로 빠진 '
                if 45 < area_x < 180 and 60 < area_y < 230:
                    comment = '스트라이크 같았는데요. '
            elif ball_type == 'T':  # 기다린 스트라이크
                if hit_type == '우타':  # 우타
                    if zone_x == 1 or zone_x == 2:  # 바깥쪽 스트라이크
                        if 45 < area_x < 60:
                            comment = '바깥쪽 꽉찬 스트라이크 '
                        else:
                            comment = '바깥쪽 스트라이크 '
                    elif zone_x == 6 or zone_x == 7:  # 몸쪽 스트라이크
                        if 210 < area_x < 235:
                            comment = '몸쪽 꽉찬 스크라이크 '
                        else:
                            comment = '몸쪽 스트라이크 '
                else:  # 좌타
                    if zone_x == 1 or zone_x == 2:  # 몸쪽 스트라이크
                        if 45 < area_x < 60:
                            comment = '몸쪽 꽉찬 스크라이크 '
                        else:
                            comment = '몸쪽 스트라이크 '
                    elif zone_x == 6 or zone_x == 7:  # 바깥쪽 스트라이크
                        if 210 < area_x < 235:
                            comment = '바깥쪽 꽉찬 스트라이크 '
                        else:
                            comment = '바깥쪽 스트라이크 '
            elif ball_type == 'S':  # 헛스윙
                if zone_y < 6:
                    comment = '낮은 공이였는데 휘둘렀어요. '

            ball_style_dict['PITNAME'] = pitcher
            ball_style_dict['COMMENT'] = comment
            ball_style_dict['HITTER'] = hitter
            ball_style_dict['STUFF'] = pitch_type
            ball_style_dict['SPEED'] = pitch_data['speed']
            ball_style_dict['STATE_SPLIT'] = 'BALLINFO'
            result_list.append(ball_style_dict)

            if ball_type == 'B':
                ball_dict['PITNAME'] = pitname
                ball_dict['COMMENT'] = comment
                ball_dict['STUFF'] = pitch_type
                ball_dict['STATE_SPLIT'] = 'BALLINFO_BALL'
                result_list.append(ball_dict)

            return result_list
        else:
            return None
    def get_current_game_info(self, live_dict):
        result_list = []
        data_dict = {'OPPONENT': 'NA', 'LEAGUE': 'NA', 'PITCHER': 'NA', 'PITNAME': 'NA',
                     'GYEAR': 'NA', 'PITTEAM': 'NA', 'STATE': 'CURRENT_INFO'}
        game_id = live_dict['game_id']
        score_detail = live_dict['score_detail']
        score_simple = live_dict['score']
        seq_no = live_dict['seq_no']
        base_detail = live_dict['base_detail']
        out_count = live_dict['out_count']
        bat_order = live_dict['batorder']
        ball_count = live_dict['ballcount']
        text_style = live_dict['textStyle']
        full_count = live_dict['full_count']
        ball_type = live_dict['ball_type']
        how = live_dict['how']
        inning = live_dict['inning']
        tb = live_dict['tb']
        hit_team = live_dict['hitteam']
        year = live_dict['gyear']
        home_team = game_id[10:12]
        away_team = game_id[8:10]

        # region Detail Version
        if config.VERSION_LEVEL > 0:
            # region 팀 시즌 정보
            if seq_no == 0:
                away_team_info = record.Record().get_teamrank_daily(self.TEAM_KOR[away_team])
                if away_team_info:
                    away_team_info = away_team_info[0]
                    if away_team_info['GAME'] > 0:
                        away_team_dict = data_dict.copy()
                        away_team_dict['LEAGEU'] = 'SEASON'
                        away_team_dict['TEAM_NAME'] = away_team_info['TEAM']
                        if int(away_team_info['CONTINUE'][0]) > 1:
                            away_team_dict['STATE_SPLIT'] = 'SEASON_TEAM_INFO_CONTINUE'
                            away_team_dict['CONTINUE'] = '{0}연{1}'.format(away_team_info['CONTINUE'][0], away_team_info['CONTINUE'][1])
                        else:
                            away_team_dict['STATE_SPLIT'] = 'SEASON_TEAM_INFO'
                        away_team_dict.update(away_team_info)
                        result_list.append(away_team_dict)
            elif bat_order == 0 and inning == 1 and tb == 'B':
                home_team_info = record.Record().get_teamrank_daily(self.TEAM_KOR[home_team])
                if home_team_info:
                    home_team_info = home_team_info[0]
                    if home_team_info['GAME'] > 0:
                        home_team_dict = data_dict.copy()
                        home_team_dict['LEAGEU'] = 'SEASON'
                        home_team_dict['TEAM_NAME'] = home_team_info['TEAM']
                        if int(home_team_info['CONTINUE'][0]) > 1:
                            home_team_dict['STATE_SPLIT'] = 'SEASON_TEAM_INFO_CONTINUE'
                            home_team_dict['CONTINUE'] = '{0}연{1}'.format(home_team_info['CONTINUE'][0], home_team_info['CONTINUE'][1])
                        else:
                            home_team_dict['STATE_SPLIT'] = 'SEASON_TEAM_INFO'
                        home_team_dict.update(home_team_info)
                        result_list.append(home_team_dict)
            # endregion 팀 시즌 정보

            # region 팀 대결 정보
            if seq_no == 0:
                team_vs_team_info = record.Record().get_team_vs_team(home_team, away_team, 2017)
                if team_vs_team_info:
                    versus_info = team_vs_team_info[0]
                    versus_dict = data_dict.copy()
                    versus_dict['HOME_TEAM'] = self.TEAM_KOR[home_team]
                    versus_dict['AWAY_TEAM'] = self.TEAM_KOR[away_team]
                    versus_dict['STATE_SPLIT'] = 'VERSUS_TEAM'
                    if home_team in self.english_team:
                        versus_dict['TEAM_NAME'] = '{name}는'.format(name=self.TEAM_KOR[home_team])
                    else:
                        versus_dict['TEAM_NAME'] = '{name:는}'.format(name=Noun(self.TEAM_KOR[home_team]))
                    versus_dict.update(versus_info)
                    if versus_info['LOSS'] > versus_info['WIN']:
                        if home_team in self.english_team:
                            versus_dict['TEAM_NAME'] = '{name}는'.format(name=self.TEAM_KOR[away_team])
                        else:
                            versus_dict['TEAM_NAME'] = '{name:는}'.format(name=Noun(self.TEAM_KOR[away_team]))
                        versus_dict['WIN'] = versus_info['LOSS']
                        versus_dict['LOSS'] = versus_info['WIN']
                    elif versus_info['WIN'] == versus_info['LOSS']:
                        versus_dict['STATE_SPLIT'] = 'VERSUS_TEAM_SAME'
                    result_list.append(versus_dict)
            # endregion 팀 대결 정보

            # region 등판시 주루상황, 점수상황, 아웃상황
            if bat_order > 1 and ball_count == 0 and text_style == 8:
                self.continue_ball_count_b = 0  # 연속 볼
                self.continue_ball_count_f = 0  # 연속 파울
                self.continue_ball_stuff.clear()
                if out_count == 0:
                    out = '노'
                elif out_count == 1:
                    out = '원'
                else:
                    out = '투'

                if base_detail == '0B':
                    base = '없는 상황'
                elif base_detail == '1B':
                    base = '1루'
                elif base_detail == '2B':
                    base = '2루'
                elif base_detail == '3B':
                    base = '3루'
                elif base_detail == '12B':
                    base = '1,2루'
                elif base_detail == '13B':
                    base = '1,3루'
                elif base_detail == '23B':
                    base = '2,3루'
                else:
                    base = '만루'

                if score_detail == '0D':
                    score = '동점인 상황'
                else:
                    if score_detail[1] == 'L':
                        score_temp = " 지고 있는 상황"
                    else:
                        score_temp = " 이기고 있는 상황"
                    score = "{0}점차로 {1}".format(score_detail[0], score_temp)

                current_game = data_dict.copy()
                current_game['LEAGUE'] = 'SEASON'
                current_game['STATE_SPLIT'] = 'CURRENT_INFO'
                current_game['out'] = out
                current_game['base'] = base
                current_game['score'] = score

                result_list.append(current_game)
            # endregion

            # region 홈인 후 다음 타자 등판 상황

            # endregion 홈인 후 다음 타자 등판 상황

            # region 선수 정보
            if text_style == 8:
                hitter_info = record.Record().get_player_info(live_dict['hitter'])[0]
                pitcher_info = record.Record().get_player_info(live_dict['pitcher'])[0]

                if hitter_info['CAREER2'] == pitcher_info['CAREER2']:
                    players_dict = data_dict.copy()
                    players_dict['HITTER'] = hitter_info['NAME']
                    players_dict['PITCHER'] = pitcher_info['NAME']
                    players_dict['CAREER'] = pitcher_info['CAREER2']
                    players_dict['STATE_SPLIT'] = 'SAME_CAREER'
                    result_list.append(players_dict)

                if hitter_info['BIRTH'][4:8] == game_id[4:8]:
                    birth_dict = data_dict.copy()
                    birth_dict['PLAYER'] = hitter_info['NAME']
                    birth_dict['STATE_SPLIT'] = 'PLAYER_BIRTHDAY'
                    result_list.append(birth_dict)
                elif pitcher_info['BIRTH'][4:8] == game_id[4:8]:
                    birth_dict = data_dict.copy()
                    birth_dict['PLAYER'] = pitcher_info['NAME']
                    birth_dict['STATE_SPLIT'] = 'PLAYER_BIRTHDAY'
                    result_list.append(birth_dict)
            # endregion 선수 정보

            # region Ball Count 설명
            if text_style == 1:
                if ball_type == 'S' or ball_type == 'T':
                    strike_counting = full_count[1]
                    if strike_counting == 1:
                        print("캐스터: 원스트라이크")
                    elif strike_counting == 2:
                        print("캐스터: 투스트라이크")
                elif ball_type == 'B':
                    ball_counting = full_count[0]
                    if ball_counting == 1:
                        print("캐스터: 원볼")
                    elif ball_counting == 2:
                        print("캐스터: 투볼")
                    elif ball_counting == 3:
                        print("캐스터: 쓰리볼")
            # endregion

            # region Full count
            if full_count[0] == 2 and full_count[1] == 3 and text_style == 1:
                full_count_dict = data_dict.copy()
                full_count_dict['LEAGUE'] = 'SEASON'
                full_count_dict['STATE_SPLIT'] = 'FULL_COUNT'
                result_list.append(full_count_dict)
            # endregion

            # region 연속 볼, 연속 파울 설정
            if ball_type == 'B' and text_style == 1:
                self.continue_ball_count_b += 1
                self.continue_ball_count_f = 0
            elif ball_type == 'F' and text_style == 1:
                self.continue_ball_count_f += 1
                self.continue_ball_count_b = 0
            else:
                self.continue_ball_count_b = 0
                self.continue_ball_count_f = 0

            if 2 < self.continue_ball_count_b < 4:
                continue_ball_dict = data_dict.copy()
                continue_ball_dict['LEAGUE'] = 'SEASON'
                continue_ball_dict['STATE_SPLIT'] = 'CONTINUE_BALL'
                continue_ball_dict['type'] = '볼'
                continue_ball_dict['count'] = self.continue_ball_count_b
                result_list.append(continue_ball_dict)
            elif self.continue_ball_count_f > 2:
                continue_ball_dict = data_dict.copy()
                continue_ball_dict['LEAGUE'] = 'SEASON'
                continue_ball_dict['STATE_SPLIT'] = 'CONTINUE_BALL'
                continue_ball_dict['type'] = '파울'
                continue_ball_dict['count'] = self.continue_ball_count_f
                result_list.append(continue_ball_dict)
            # endregion

            # region 사구일 경우
            if how == 'HP':
                how_hp = data_dict.copy()
                how_hp['LEAGUE'] = 'SEASON'
                how_hp['STATE_SPLIT'] = 'HOW_HP'
                result_list.append(how_hp)
            # endregion

            # region 매 이닝 시작시 어디 공격 점수는 몇점
            if bat_order == 0:
                inning_start_dict = data_dict.copy()
                inning_start_dict['LEAGUE'] = 'SEASON'
                inning_start_dict['STATE_SPLIT'] = 'START_INNING'
                inning_start_dict['INNING'] = inning
                inning_start_dict['TB'] = '회초' if tb == 'T' else '회말'
                inning_start_dict['TEAM'] = self.TEAM_KOR[hit_team]
                inning_start_dict['WHAT'] = '반격' if score_simple[1] == 'L' else '공격'
                result_list.append(inning_start_dict)
            # endregion
        # endregion Detail Version

        # region 공수 교체시
        if bat_order == 0 and seq_no > 0:
            if score_detail[1] == 'L':
                when_loss = data_dict.copy()
                when_loss['LEAGUE'] = 'SEASON'
                if hit_team in self.english_team:
                    when_loss['TEAM'] = '{team}가'.format(team=self.TEAM_KOR[hit_team])
                else:
                    when_loss['TEAM'] = '{team:이}'.format(team=Noun(self.TEAM_KOR[hit_team]))
                when_loss['STATE_SPLIT'] = 'WHEN_LOSS'
                result_list.append(when_loss)
        # endregion

        # region 연속 같은 볼
        if ball_type == 'H':
            self.continue_ball_stuff.clear()
        else:
            ball_stuff_value_list = list(self.continue_ball_stuff.values())
            ball_stuff_key_list = list(self.continue_ball_stuff.keys())
            if ball_stuff_value_list and ball_stuff_value_list[0] > 2:
                ball_stuff_dict = data_dict.copy()
                ball_stuff_dict['LEAGUE'] = 'SEASON'
                if ball_stuff_value_list[0] > 4:
                    ball_stuff_dict['STATE_SPLIT'] = 'BALL_STUFF_COUNT_MANY'
                else:
                    ball_stuff_dict['STATE_SPLIT'] = 'BALL_STUFF_COUNT'
                ball_stuff_dict['count'] = ball_stuff_value_list[0]
                ball_stuff_dict['ball_type'] = self.BALL_STUFF[ball_stuff_key_list[0]]
                result_list.append(ball_stuff_dict)
        # endregion

        # region Max LI
        if inning > 5:
            max_li_rt = record.Record().get_max_li_rate(game_id, seq_no)[0]['VALUE']
            curr_li_rt = record.Record().get_li_rate(year, inning, tb, out_count, base_detail, score_detail)[0]['VALUE']

            if self.max_li < max_li_rt:
                self.max_li = max_li_rt

            if self.max_li < curr_li_rt:
                self.max_li = curr_li_rt
                if self.max_li < 3:
                    state_split = 'MAX_LI_MIDDLE'
                elif 3 <= self.max_li < 6:
                    state_split = 'MAX_LI_PEAK'
                elif 6 <= self.max_li:
                    state_split = 'MAX_LI_DONE'
                max_li = data_dict.copy()
                max_li['HITNAME'] = live_dict['hitname']
                max_li['LEAGUE'] = 'SEASON'
                max_li['STATE_SPLIT'] = state_split
                result_list.append(max_li)
        # endregion Max LI

        # region WPA 변화량에 따른 승리 확률
        if inning > 3 and how in self.WPA_HOW_KOR:
            record_matrix_dict = None
            record_matrix = record.Record().get_record_matrix_mix(game_id, year, seq_no)
            if record_matrix:
                record_matrix_dict = record_matrix[0]

            if record_matrix_dict and record_matrix_dict['WPA_RT'] > 0.1:
                wpa_rt = record_matrix_dict['WPA_RT']
                after_we_rt = record_matrix_dict['AFTER_WE_RT']
                before_we_rt = record_matrix_dict['BEFORE_WE_RT']

                home_after_we_rt = round(after_we_rt * 100)
                away_after_we_rt = round((1 - after_we_rt) * 100)
                wpa_rt = round(wpa_rt * 100)

                if (tb == 'T' and after_we_rt - before_we_rt < 0) or (tb == 'B' and after_we_rt - before_we_rt > 0):
                    wpa_rate = data_dict.copy()
                    wpa_rate['LEAGUE'] = 'SEASON'
                    wpa_rate['STATE_SPLIT'] = 'WPA_RATE'
                    wpa_rate['HOW'] = "{state:이}".format(state=Noun(self.WPA_HOW_KOR[how]))
                    if tb == 'T':
                        wpa_rate['TEAM'] = self.TEAM_KOR[away_team]
                    else:
                        wpa_rate['TEAM'] = self.TEAM_KOR[home_team]
                    wpa_rate['WPA_RT'] = wpa_rt
                    wpa_rate['HOME_TEAM'] = self.TEAM_KOR[home_team]
                    wpa_rate['AWAY_TEAM'] = self.TEAM_KOR[away_team]
                    wpa_rate['HOME_WE_RT'] = home_after_we_rt
                    wpa_rate['AWAY_WE_RT'] = away_after_we_rt
                    result_list.append(wpa_rate)
        # endregion WPA 변화량에 따른 승리 확률
        return result_list