Skip to content

Commit

Permalink
Further updates for JRDA 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSmasherDerby committed Feb 5, 2023
1 parent a2a0643 commit c53d853
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/index.js
Expand Up @@ -50,6 +50,8 @@ let sbData = {}, // derbyJSON formatted statsbook data
const teamList = ['home','away']
let anSP = /^sp\*?$/i
let mySP = /^sp$/i
let anINJ = /^inj\*?$/i
//let myINJ = /^inj$/i Save this in case we need it later.

// Check for new version
ipc.on('do-version-check', (event, version) => {
Expand Down Expand Up @@ -420,7 +422,7 @@ let readScores = (workbook) => {
let tab = 'score'
let npRe = /(\d)\+NP/
let ippRe = /(\d)\+(\d)/
let jamNoRe = /^(\d+|SP|SP\*)$/i
let jamNoRe = /^(\d+|SP|SP\*|INJ|INJ\*)$/i

for(let period = 1; period < 3; period ++){
// For each period, import data
Expand Down Expand Up @@ -480,7 +482,7 @@ let readScores = (workbook) => {
throw new Error(`Invalid Jam Number: ${jamNumber.v}`)
}

// handle star passes
// handle star passes and injuries
if (anSP.test(jamNumber.v)) {
starPass = true
if (mySP.test(jamNumber.v)) {
Expand All @@ -492,8 +494,11 @@ let readScores = (workbook) => {
)
}
starPasses.push({period: period, jam: jam})
} else if (anINJ.test(jamNumber.v)) {
// Will we need more code here? Stay tuned.
continue
} else {
// Not a star pass
// Not a star pass or injury

// Error check - is this jam number out of sequence?
if (parseInt(jamNumber.v) != (jam+1)){
Expand All @@ -513,7 +518,7 @@ let readScores = (workbook) => {
starPass = false
}

// If there isn't currently an numbered object for this jam, create it
// If there isn't currently a numbered object for this jam, create it
// Note that while the "number" field is one indexed, the jams array itself is zero indexed
if (!sbData.periods[pstring].jams.find(o => o.number === jam)){
sbData.periods[pstring].jams[jam-1] = {number: jam, events: []}
Expand Down Expand Up @@ -1135,9 +1140,13 @@ let readLineups = (workbook) => {
`Team: ${ucFirst(team)}, Period: ${period}, Jam: ${jam}`
)
}

} else if(anINJ.test(jamText.v)){
// If this is an injury line (INJ or INJ*)
// TODO: add an error check to see if skaters
// other than the jammer were subbed.
continue
} else {
// Not a starpass line, update the jam number
// Not a starpass or an injury line, update the jam number
jam = jamText.v
starPass = false
skaterList = []
Expand Down Expand Up @@ -1412,6 +1421,7 @@ let readLineups = (workbook) => {
}
break
case '2019':
case '2023jrda':
// Possible codes - -, +, S, $, 3

// - - Enter box
Expand Down

0 comments on commit c53d853

Please sign in to comment.