-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
18,312 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
optionKey | ||
|
||
0: { // Sex | ||
0, // Male | ||
1, // Female | ||
}, | ||
|
||
1 - 3 | ||
|
||
4: { // Throws | ||
0, // Left | ||
1, // Right | ||
}, | ||
5: { // Bats | ||
0, // Left | ||
1, // Right | ||
2, // Switch | ||
}, | ||
|
||
6 - 7 | ||
|
||
8 - Personality | ||
|
||
9 - 11 | ||
|
||
12 - Head # | ||
|
||
13 | ||
|
||
14 - Eyebrows # | ||
15 - Hair # | ||
16 - Facial Hair # | ||
17 - Eye black | ||
18 - Helmet Tar | ||
19 - Eyewear | ||
20 - Jersey Number | ||
|
||
21 | ||
|
||
22 - Physique | ||
|
||
23 - 24 | ||
|
||
25 - Elbow Guard | ||
26 - Angle Guard | ||
27 - Elbow | ||
28 - Left Tatoo | ||
29 - Right Tatoo | ||
30 - Left Sleeve | ||
31 - Right Sleeve | ||
32 - Pants | ||
|
||
33 - 35 | ||
|
||
36 - Wristband | ||
|
||
37 - 38 | ||
|
||
39 - Batting Glove | ||
40 - Cleats | ||
41 - Wrist tape | ||
|
||
42 - 47 | ||
|
||
48 - Pitcher Windup | ||
49 - Pitcher Angle | ||
50 - Batting Routine | ||
51 - Batting Stance | ||
52 - Walkup Song | ||
|
||
53 - Player Rating !!! (closer to 0 the better) | ||
|
||
54 - Position | ||
55 - { // Secondary Position !!! | ||
2, | ||
3, | ||
4, | ||
5, | ||
6, | ||
7, | ||
9, | ||
10, ??? | ||
11, ??? | ||
12, ??? | ||
13, ??? | ||
} | ||
|
||
56 | ||
|
||
57 - Pitcher Type | ||
58 - 4F Pitch | ||
59 - 2F Pitch | ||
60 - SB Pitch | ||
61 - CW Pitch | ||
62 - FK Pitch | ||
63 - CB Pitch | ||
64 - SL Pitch | ||
65 - CF Pitch | ||
66 - First Name | ||
67 - Last Name | ||
|
||
68 - 91 | ||
|
||
92 - Bat Style | ||
93 - Bat Grip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { keys, pick, values, mean } from 'lodash'; | ||
import { positions, pitcherPositions } from './helper'; | ||
|
||
const buildAverage = (data, isPitcher) => { | ||
const attributesToAverage = isPitcher | ||
? ['accuracy', 'velocity', 'junk'] | ||
: ['arm', 'contact', 'fielding', 'power', 'speed']; | ||
const avgValues = values(pick(data, attributesToAverage)); | ||
const averaged = mean(avgValues.map((val) => +val)).toFixed(0); | ||
|
||
return { ...data, averaged }; | ||
}; | ||
|
||
export const createPlayer = (info) => { | ||
const isPitcher = info.primaryPosition === '1'; | ||
const position = isPitcher | ||
? pitcherPositions[info.pitcherRole] | ||
: positions[info.primaryPosition]; | ||
const position2 = !isPitcher ? positions[info['55']] : null; | ||
let pitcherStats = {}; | ||
const stats = { | ||
team: info.teamName, | ||
name: `${info.firstName} ${info.lastName}`, | ||
position, | ||
position2, | ||
age: info.age, | ||
power: info.power, | ||
contact: info.contact, | ||
speed: info.speed, | ||
fielding: info.fielding, | ||
arm: info.arm, | ||
}; | ||
|
||
const traits = { | ||
trait: info.trait, | ||
trait2: info.subType, | ||
}; | ||
|
||
if (isPitcher) { | ||
pitcherStats = { | ||
velocity: info.velocity, | ||
junk: info.junk, | ||
accuracy: info.accuracy, | ||
}; | ||
} | ||
|
||
const display = buildAverage( | ||
{ ...stats, ...pitcherStats, ...traits }, | ||
isPitcher | ||
); | ||
|
||
return { | ||
isPitcher, | ||
display, | ||
info, | ||
}; | ||
}; | ||
|
||
// accuracy: "46" | ||
// age: "22" | ||
// arm: "" | ||
// contact: "38" | ||
// fielding: "98" | ||
// firstName: "Fran" | ||
// junk: "54" | ||
// lastName: "Gipani" | ||
// pitcherRole: "1" | ||
// power: "2" | ||
// primaryPosition: "1" | ||
// speed: "35" | ||
// teamName: "Beewolves" | ||
// velocity: "66" | ||
// trait: "1" | ||
// trait2: "5" | ||
|
||
// baseballPlayerLocalID: '1'; | ||
// optionKey: '0'; | ||
// optionType: '0'; | ||
// optionValue: '0'; | ||
export const compileOptions = (info) => { | ||
return info.reduce((acc, option) => { | ||
const optionKeys = keys(option); | ||
acc[option.baseballPlayerLocalID] = acc[option.baseballPlayerLocalID] ?? { | ||
id: option.baseballPlayerLocalID, | ||
}; | ||
|
||
optionKeys.forEach((key) => { | ||
if ( | ||
!acc[option.baseballPlayerLocalID][key] && | ||
!['optionKey', 'optionType', 'optionValue'].includes(key) | ||
) { | ||
acc[option.baseballPlayerLocalID][key] = option[key]; | ||
} else if (key === 'optionKey') { | ||
acc[option.baseballPlayerLocalID][option.optionKey] = | ||
option.optionValue; | ||
} | ||
}); | ||
return acc; | ||
}, {}); | ||
}; |
Oops, something went wrong.