-
Notifications
You must be signed in to change notification settings - Fork 2
/
resource.py
248 lines (198 loc) · 7.6 KB
/
resource.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
class Resource():
frame = []
seq = 1
prev_annotation_text = ""
prev_annotation = ""
annotation = "중계방송 준비중입니다."
break_time = False
strike = 0
ball = 0
out = 0
action = 0
def set_annotation(self, annotation):
self.prev_annotation = self.annotation
self.annotation = annotation
def is_new_annotation(self):
if not (self.prev_annotation == self.annotation):
self.prev_annotation = self.annotation
return 1
else:
return 0
def is_new_annotation_video(self):
if not (self.prev_annotation_text == self.annotation):
self.prev_annotation_text = self.annotation
return 1
else:
return 0
def get_annotation(self):
if(self.break_time):
return "중계방송 준비중입니다."
else:
return self.annotation
def set_frameno(self, frameno):
self.frameno = frameno
def set_frame(self, frame):
self.frame = frame
def get_frame(self):
return self.frame
def get_frameno(self):
return self.frameno
def add_seq(self):
self.seq = self.seq + 1
def get_seq(self):
return self.seq
def set_gameinfo(self, game_info):
self.stadium = game_info["stadium"]
self.date = game_info["date"]
self.DateHomeAway = game_info["DateHomeAway"]
self.home_name = game_info["homeTeam"]
self.away_name = game_info["awayTeam"]
self.home_Fname = game_info["FhomeTeam"]
self.away_Fname = game_info["FawayTeam"]
def get_gameinfo(self):
return [self.stadium, self.date, [self.home_name, self.away_name], [self.home_Fname, self.away_Fname]]
def set_gamescore(self, homescore, awayscore):
self.homescore = homescore
self.awayscore = awayscore
def get_gamescore(self):
return [self.homescore, self.awayscore]
def get_date(self):
return self.date
def get_stadium(self):
return self.stadium
def get_gamecode(self):
return self.DateHomeAway
def clear_strike_ball_out(self):
self.strike = 0
self.ball = 0
self.out = 0
def clear_strike_ball(self):
self.strike = 0
self.ball = 0
def set_strike_ball_out(self, strike=False, ball=False, foul=False, out=False):
if(strike):
self.strike = self.strike + 1
elif(ball):
self.ball = self.ball + 1
elif(foul):
if(self.strike < 2):
self.strike = self.strike + 1
elif(out):
self.out = self.out + 1
def get_strike_ball_out(self):
return [self.strike, self.ball, self.out]
def set_action(self, judge):
actions = ["strike", "ball", "foul", "hit", "hits", "out", "homerun", "etc"]
self.action = judge
def get_action(self):
return self.action
def set_batterbox(self, batterbox, pitcher, batter):
self.batterbox = batterbox
self.pitcher = pitcher
self.batter = batter
def get_batterbox(self):
return self.batterbox
def get_pitcher(self):
return self.pitcher
def set_batter(self, batter):
self.batter = batter
def get_batter(self):
return self.batter
def set_inn(self, inn, btop):
self.inn = inn
self.btop = btop
def get_inn(self):
return self.inn
def get_btop(self):
return self.btop
def set_LineUp(self, LineUp):
sett = {"catcher":None, "1st":None, "2nd":None, "3rd":None, "ss":None, "ROF":None, "LOF":None, "COF":None}
hometeam = LineUp["HomePitchers"] + LineUp["HomeBatters"]
awayteam = LineUp["AwayPitchers"] + LineUp["AwayBatters"]
for player in LineUp["HomeBatters"]:
if(player["posName"] == "1루수"):
sett["1st"] = player
elif(player["posName"] == "2루수"):
sett["2nd"] = player
elif (player["posName"] == "3루수"):
sett["3rd"] = player
elif (player["posName"] == "유격수"):
sett["ss"] = player
elif (player["posName"] == "포수"):
sett["catcher"] = player
elif (player["posName"] == "좌익수"):
sett["LOF"] = player
elif (player["posName"] == "우익수"):
sett["ROF"] = player
elif (player["posName"] == "중견수"):
sett["COF"] = player
self.homeTeam = sett
sett = {"catcher":None, "1st":None, "2nd":None, "3rd":None, "ss":None, "ROF":None, "LOF":None, "COF":None}
for player in LineUp["AwayBatters"]:
if(player["posName"] == "1루수"):
sett["1st"] = player
elif(player["posName"] == "2루수"):
sett["2nd"] = player
elif (player["posName"] == "3루수"):
sett["3rd"] = player
elif (player["posName"] == "유격수"):
sett["ss"] = player
elif (player["posName"] == "포수"):
sett["catcher"] = player
elif (player["posName"] == "좌익수"):
sett["LOF"] = player
elif (player["posName"] == "우익수"):
sett["ROF"] = player
elif (player["posName"] == "중견수"):
sett["COF"] = player
self.awayTeam = sett
self.LineUp = LineUp
def change_LineUp(self, player_in, player_out):
pos = player_in["posName"]
if (pos == "1루수"):
if (self.homeTeam["1st"] == player_out):
self.homeTeam["1st"] = player_in
if (self.awayTeam["1st"] == player_out):
self.awayTeam["1st"] = player_in
elif (pos == "2루수"):
if (self.homeTeam["2nd"] == player_out):
self.homeTeam["2nd"] = player_in
if (self.awayTeam["2nd"] == player_out):
self.awayTeam["2nd"] = player_in
elif (pos == "3루수"):
if (self.homeTeam["3rd"] == player_out):
self.homeTeam["3rd"] = player_in
if (self.awayTeam["3rd"] == player_out):
self.awayTeam["3rd"] = player_in
elif (pos == "유격수"):
if (self.homeTeam["ss"] == player_out):
self.homeTeam["ss"] = player_in
if (self.awayTeam["ss"] == player_out):
self.awayTeam["ss"] = player_in
elif (pos == "포수"):
if (self.homeTeam["catcher"] == player_out):
self.homeTeam["catcher"] = player_in
if (self.awayTeam["catcher"] == player_out):
self.awayTeam["catcher"] = player_in
elif (pos == "좌익수"):
if (self.homeTeam["LOF"] == player_out):
self.homeTeam["LOF"] = player_in
if (self.awayTeam["LOF"] == player_out):
self.awayTeam["LOF"] = player_in
elif (pos == "우익수"):
if (self.homeTeam["ROF"] == player_out):
self.homeTeam["ROF"] = player_in
if (self.awayTeam["ROF"] == player_out):
self.awayTeam["ROF"] = player_in
elif (pos == "중견수"):
if (self.homeTeam["COF"] == player_out):
self.homeTeam["COF"] = player_in
if (self.awayTeam["COF"] == player_out):
self.awayTeam["COF"] = player_in
def get_player_with_position(self, position):
btop = self.get_btop()
if btop == 0:
lineup = self.awayTeam
else:
lineup = self.homeTeam
return lineup[position]["name"]