-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
executable file
·123 lines (108 loc) · 3.09 KB
/
models.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
# ---------------------------------------------------------------------
class Game(object):
id = ''
status = ''
team = ''
teamRuns = 0
teamHits = 0
teamErrors = 0
opponent = ''
opponentRuns = 0
opponentHits = 0
opponentErrors = 0
def make_game(id, status, team, teamRuns, teamHits, teamErrors, opponent, opponentRuns, opponentHits, opponentErrors):
game = Game()
game.id = id
game.status = status
game.team = team
game.teamRuns = teamRuns
game.teamHits = teamHits
game.teamErrors = teamErrors
game.opponent = opponent
game.opponentRuns = opponentRuns
game.opponentHits = opponentHits
game.opponentErrors = opponentErrors
# ---------------------------------------------------------------------
class Inning(object):
number = 0
half = 'top'
def make_inning(number, half):
inning = Inning()
inning.number = number
inning.half = half
# ---------------------------------------------------------------------
class Player(object):
id = ''
first = ''
last = ''
team = ''
number = 0
handed = ''
bats = ''
position = ''
status = ''
avg = '.000'
hr = 0
rbi = 0
wins = 0
losses = 0
era = 0
def make_player (id, first, last, team, number, handed, bats, position, status, avg, hr, rbi, wins, losses, era):
player = Player()
player.id = id
player.first = first
player.last = last
player.team = team
player.number = number
player.handed = rl
player.bats = bats
player.position = position
player.status = status
player.avg = avg
player.hr = hr
player.rbi = rbi
player.wins = wins
player.losses = losses
player.era = era
return player
# ---------------------------------------------------------------------
class AtBat(object):
number = 0
balls = 0
strikes = 0
outs = 0
pitcher = None
batter = None
onFirst = None
onSecond = None
onThird = None
description = ''
guid = ''
def make_inning(number, balls, strikes, outs, pitcher, batter, onFirst, onSecond, onThird, description, guid):
atBat = AtBat()
atBat.number = number
atBat.balls = balls
atBat.strikes = strikes
atBat.outs = outs
atBat.pitcher = pitcher
atBat.batter = batter
atBat.onFirst = onFirst
atBat.onSecond = onSecond
atBat.onThird = onThird
atBat.description
atBat.guid = guid
# ---------------------------------------------------------------------
class Pitch(object):
id = ''
call = '' # B or S
callDescription = ''
speed = 0
pitchType = ''
def make_pitch(id, call, callDescription, speed, pitchType):
pitch = Pitch()
pitch.id = id
pitch.call = call
pitch.callDescription = callDescription
pitch.speed = speed
pitch.pitchType = pitchType
# ---------------------------------------------------------------------