diff --git a/assets/lang/cs.json b/assets/lang/cs.json index c427b1d..cc2b30c 100644 --- a/assets/lang/cs.json +++ b/assets/lang/cs.json @@ -240,6 +240,7 @@ "noER1" : "Je vybrán umožněný doběh (R1), ale to není možné, pokud nastal decessive error.", "noER2" : "Je vybrán umožněný doběh (R2), ale to není možné, pokud nastal decessive error.", "noER3" : "Je vybrán umožněný doběh (R3), ale to není možné, pokud nastal decessive error.", + "noTieER" : "Doběh běžce, který byl umístěn na metu jako TIE, musí být unearned.", "missingOAdv" : "Je vybrán další postup na 'FC - Occupied)', ale chybí odpovídající FC situace.", "window" : { "title" : "Neplatný vstup", diff --git a/assets/lang/en.json b/assets/lang/en.json index 249cf07..7b75f45 100644 --- a/assets/lang/en.json +++ b/assets/lang/en.json @@ -240,6 +240,7 @@ "noER1" : "Earned run is selected (Runner at 1st), \nbut this is not possible with a decisive error.", "noER2" : "Earned run is selected (Runner at 2nd), \nbut this is not possible with a decisive error.", "noER3" : "Earned run is selected (Runner at 3rd), \nbut this is not possible with a decisive error.", + "noTieER" : "If a run is scored with a runner placed as TIE, it must be an unearned run.", "missingOAdv" : "Advance after 'FC - Occupied' is selected, \nbut no corresponding FC play was given.", "window" : { "title" : "Invalid input", diff --git a/utils/wbsc-validation.ts b/utils/wbsc-validation.ts index 463919d..1a50719 100644 --- a/utils/wbsc-validation.ts +++ b/utils/wbsc-validation.ts @@ -582,9 +582,18 @@ function checkEarnedRuns (inputs: WBSCInput[]) { let errR2 = false let errR3 = false + // only relevant for runners at 1st and 2nd + // run marked as team-unearned + let r1TU = false + let r2TU = false + // it was a TIE runner + let tieR1 = false + let tieR2 = false + inputs.forEach((input) => { const err = isError(input, decisiveErrorActions) const earned = isEarnedRun(input) + const teamUnearned = isTeamUnearnedRun(input) switch (input.group) { case inputB: @@ -599,6 +608,8 @@ function checkEarnedRuns (inputs: WBSCInput[]) { } break case inputR1: + tieR1 = input.tie + // falls through case inputR1a: case inputR1b: if (err) { @@ -607,8 +618,13 @@ function checkEarnedRuns (inputs: WBSCInput[]) { if (earned) { r1ER = true } + if (teamUnearned) { + r1TU = true + } break case inputR2: + tieR2 = input.tie + // falls through case inputR2a: if (err) { errR2 = true @@ -616,6 +632,9 @@ function checkEarnedRuns (inputs: WBSCInput[]) { if (earned) { r2ER = true } + if (teamUnearned) { + r2TU = true + } break case inputR3: if (err) { @@ -640,6 +659,9 @@ function checkEarnedRuns (inputs: WBSCInput[]) { if (r3ER && errR3) { validation = attachValidation(validation, useT('editor.validation.noER3')) } + if ((tieR1 && (r1ER || r1TU)) || (tieR2 && (r2ER || r2TU))) { + validation = attachValidation(validation, useT('editor.validation.noTieER')) + } return validation } @@ -683,6 +705,10 @@ function isError (input: WBSCInput, actionList: string[]): boolean { function isEarnedRun (input: WBSCInput): boolean { return (input?.output?.base === 4 || input?.output?.errorTarget === 4) && input?.output?.run === 'e' } +// helper to decide whether there is a team unearned run in current input +function isTeamUnearnedRun (input: WBSCInput): boolean { + return (input?.output?.base === 4 || input?.output?.errorTarget === 4) && input?.output?.run === 'tu' +} // helper to attach new part of validation message to previous contents function attachValidation (validation: string, newMessage: string) {