Skip to content

Commit

Permalink
#111 - fix validation of 'no advance' actions
Browse files Browse the repository at this point in the history
  • Loading branch information
AloisSeckar committed Jul 9, 2023
1 parent a36fa31 commit c4c6699
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This software is distributed under [http://unlicense.org/](UNLICENSE) (free to u
- [BackstopJS](https://github.com/garris/BackstopJS) visual testing
- New "Report bug" page
- Validations - GitHub issues #109, #110
- Bug-fixing - GitHub issues #100, #104 + various others unreported
- Bug-fixing - GitHub issues #100, #104, #111 + various others unreported

### Version 0.12 (2023-06-15)
- New actions supported: new set of OBRs according to 2019 manual, KS + FC, KL + FC
Expand Down
10 changes: 9 additions & 1 deletion assets/json/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"name": "Strike out (L) + PB"
},
{
"file": "1b-lf",
"file": "1b-7",
"name": "Single to LF"
},
{
Expand Down Expand Up @@ -183,6 +183,14 @@
"file": "1b-9-e9t",
"name": "Single to RF + extra base throwing error"
},
{
"file": "1b-9-94e3-na",
"name": "Single to RF + RF to 2B to 1B, error, no advance"
},
{
"file": "1b-7-r1-7e5t-na",
"name": "Single to LF + LF to 3B, thr. error, no advance (R1)"
},
{
"file": "out-31-r1-e3t",
"name": "Ground out - 1B to P + runner from 1st scores (FC + e3T)"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/json/1b-7-r1-7e5t-na.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"group":"input-r1a","baseAction":"err","specAction":"ENT","origBase":2,"base":3,"tie":false,"runtype":"e","pos":"75"},{"group":"input-r1","baseAction":"adv","specAction":"ADV","origBase":1,"base":2,"tie":false,"runtype":"e","pos":""},{"group":"input-b","baseAction":"Hit","specAction":"1B","origBase":0,"base":1,"tie":false,"runtype":"e","pos":"7"}]
File renamed without changes.
1 change: 1 addition & 0 deletions public/json/1b-9-94e3-na.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"group":"input-b1","baseAction":"err","specAction":"ENF","origBase":1,"base":2,"tie":false,"runtype":"e","pos":"943"},{"group":"input-b","baseAction":"Hit","specAction":"1B","origBase":0,"base":1,"tie":false,"runtype":"e","pos":"9"}]
2 changes: 1 addition & 1 deletion todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ v0.13
- - BackstopJS visual testing
- - New "Report bug" page
- Validations: #109, #110
- Bug-fixing: #100, #104 + various other unreported
- Bug-fixing: #100, #104, #111 + various other unreported
- Refactoring:


Expand Down
5 changes: 4 additions & 1 deletion utils/wbsc-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const decisiveErrorActions = [
'GDPE', 'SHE', 'SHET', 'SHEF', 'SFE', 'CSE', 'CSET', 'CSN', 'CSNT', 'POE'
]
const errorActions = [...decisiveErrorActions, 'eF', 'eT']
const noAdvActions = ['ENF', 'ENT', 'CSN', 'CSNT']

// validation sequence to be run over given outputs
// (this should be the single point of entry to validatons)
Expand Down Expand Up @@ -127,6 +128,7 @@ function checkOutcome (inputs: WBSCInput[]) {
if (output) {
if (currentBatter === output.batter) {
if (output.out) {
// this is probably a dead code after #60
if (playerWasOut) {
validation = attachValidation(validation, 'One player cannot be out more than once')
} else {
Expand All @@ -136,11 +138,12 @@ function checkOutcome (inputs: WBSCInput[]) {
}
const maxReachedBase = reachedBases[reachedBases.length - 1]
const currentReachedBase = Math.max(output.base, output.errorTarget)
if (currentReachedBase > maxReachedBase || (currentReachedBase === maxReachedBase && output.na === false)) {
if (currentReachedBase > maxReachedBase || (currentReachedBase === maxReachedBase && noAdvActions.includes(input.specAction))) {
validation = attachValidation(validation, 'Extra advances of one player must happen in order')
}
} else {
// special case for "batter + same error"
// this is probably a dead code after #60
if (input.group === inputB) {
if (output.base === 0 && output.errorTarget > 1) {
playerWasOut = true
Expand Down

0 comments on commit c4c6699

Please # to comment.