-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpitching_appearance.js
66 lines (54 loc) · 1.34 KB
/
pitching_appearance.js
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
// Constructor
function PitchingAppearance() {
this.pitches = null;
this.gid = null;
this.pid = null;
this.pitcher_name = null;
this.out = null;
this.inn = null;
this.bf = null;
this.er = null;
this.r = null;
this.h = null;
this.so = null;
this.hr = null;
this.bb = null;
this.w = null;
this.l = null;
this.era = null;
this.note = null;
this.start = null;
};
// Used to initialize from box score data
PitchingAppearance.prototype.init = function(gid, pitcher, count) {
this.pitches = [];
this.gid = gid;
this.pid = pitcher.$.id;
this.pitcher_name = pitcher.$.name;
this.out = pitcher.$.out;
this.inn = this.convert_out_to_inn(pitcher.$.out);
this.bf = pitcher.$.bf;
this.er = pitcher.$.er;
this.r = pitcher.$.r;
this.h = pitcher.$.h;
this.so = pitcher.$.so;
this.hr = pitcher.$.hr;
this.bb = pitcher.$.bb;
this.w = pitcher.$.w;
this.l = pitcher.$.l;
this.era = pitcher.$.era;
this.note = pitcher.$.note;
if (count == 1) {
this.start = true;
}
else {
this.start = false;
}
};
PitchingAppearance.prototype.convert_out_to_inn = function(outs) {
var num_out = parseInt(outs);
var part = num_out % 3;
return (Math.floor(num_out/3)).toString() + '.' + part.toString();
};
// export the class
module.exports = PitchingAppearance;