diff --git a/README.md b/README.md index 9b2362e..c2915c1 100644 --- a/README.md +++ b/README.md @@ -1 +1,19 @@ -# sbs +# paperscore + +*paperscore* is a hybrid paper-computer softball scoring system that I've been using for the last couple of years to score amateur travel softball games. + +Some features and notes: + +* The software computes a variety of batting statistics that it can export in CSV format. The CSV files can be imported into any of a number of other systems for additional analysis. Personally I've been using [hex.tech](https://hex.tech). +* The scoring notation and software support entering "alternate plays", which is a play which in the scorers opinion should have occurred. The software can compute the expected run cost of these errors and misplays. +* The scoring notation is derived from [retrosheet](https://www.retrosheet.org). +* The software is incomplete, and undoubtedly has bugs. Some of the code is experimental was just "left in" possibly to be completely later or more likely not at all. +* The error messages leave a lot to be desired. I've found myself running the code in the debugger just to figure out what the actual error was. +* There's a text UI editor for games that I find helpful. + +## Sample Paper Score + +Here's a sample score sheet: + +![Sample Score](/doc/score.jpeg) + diff --git a/cmd/alt.go b/cmd/alt.go index 4775ad9..0477aa1 100644 --- a/cmd/alt.go +++ b/cmd/alt.go @@ -3,8 +3,8 @@ package cmd import ( "fmt" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/spf13/cobra" ) diff --git a/cmd/batcount.go b/cmd/batcount.go index bca4d04..7452083 100644 --- a/cmd/batcount.go +++ b/cmd/batcount.go @@ -3,8 +3,8 @@ package cmd import ( "fmt" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/spf13/cobra" ) diff --git a/cmd/batting_times.go b/cmd/batting_times.go index 160ede9..0f5c551 100644 --- a/cmd/batting_times.go +++ b/cmd/batting_times.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/spf13/cobra" ) diff --git a/cmd/box.go b/cmd/box.go index fc97c54..48d1dc7 100644 --- a/cmd/box.go +++ b/cmd/box.go @@ -8,9 +8,9 @@ import ( "path/filepath" "strings" - "github.com/slshen/sb/pkg/boxscore" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/boxscore" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/spf13/cobra" "gopkg.in/yaml.v3" ) diff --git a/cmd/dataexport.go b/cmd/dataexport.go index b703121..06cc5d1 100644 --- a/cmd/dataexport.go +++ b/cmd/dataexport.go @@ -3,9 +3,9 @@ package cmd import ( "fmt" - "github.com/slshen/sb/pkg/dataexport" - "github.com/slshen/sb/pkg/dataframe/pkg" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataexport" + "github.com/slshen/paperscore/pkg/dataframe/pkg" + "github.com/slshen/paperscore/pkg/game" "github.com/spf13/cobra" ) diff --git a/cmd/fmt.go b/cmd/fmt.go index 8620be6..7a7a0b6 100644 --- a/cmd/fmt.go +++ b/cmd/fmt.go @@ -1,7 +1,7 @@ package cmd import ( - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/spf13/cobra" ) diff --git a/cmd/newgame.go b/cmd/newgame.go index ef244eb..83bc70c 100644 --- a/cmd/newgame.go +++ b/cmd/newgame.go @@ -1,7 +1,7 @@ package cmd import ( - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" "github.com/spf13/cobra" ) diff --git a/cmd/pitching_times.go b/cmd/pitching_times.go index 4214329..071cd5f 100644 --- a/cmd/pitching_times.go +++ b/cmd/pitching_times.go @@ -3,8 +3,8 @@ package cmd import ( "fmt" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/spf13/cobra" ) diff --git a/cmd/playbyplay.go b/cmd/playbyplay.go index 183e929..59ba052 100644 --- a/cmd/playbyplay.go +++ b/cmd/playbyplay.go @@ -4,8 +4,8 @@ import ( "log" "os" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/playbyplay" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/playbyplay" "github.com/spf13/cobra" ) diff --git a/cmd/re.go b/cmd/re.go index 660adc6..e735499 100644 --- a/cmd/re.go +++ b/cmd/re.go @@ -4,9 +4,9 @@ import ( "fmt" "os" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/spf13/cobra" ) diff --git a/cmd/re_args.go b/cmd/re_args.go index f1be33b..6dad70a 100644 --- a/cmd/re_args.go +++ b/cmd/re_args.go @@ -1,9 +1,9 @@ package cmd import ( - "github.com/slshen/sb/pkg/config" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/config" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/spf13/pflag" ) diff --git a/cmd/read.go b/cmd/read.go index 9ccca7a..e60de9f 100644 --- a/cmd/read.go +++ b/cmd/read.go @@ -3,7 +3,7 @@ package cmd import ( "fmt" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/spf13/cobra" "gopkg.in/yaml.v3" ) diff --git a/cmd/sim.go b/cmd/sim.go index 4d56d91..7b9a46a 100644 --- a/cmd/sim.go +++ b/cmd/sim.go @@ -3,8 +3,8 @@ package cmd import ( "fmt" - "github.com/slshen/sb/pkg/markov" - "github.com/slshen/sb/pkg/markov/expr" + "github.com/slshen/paperscore/pkg/markov" + "github.com/slshen/paperscore/pkg/markov/expr" "github.com/spf13/cobra" ) diff --git a/cmd/stats.go b/cmd/stats.go index 5e1d6e1..8d9979b 100644 --- a/cmd/stats.go +++ b/cmd/stats.go @@ -4,9 +4,9 @@ import ( "fmt" "os" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/spf13/cobra" ) diff --git a/cmd/tournament.go b/cmd/tournament.go index d072cef..29c26b0 100644 --- a/cmd/tournament.go +++ b/cmd/tournament.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/tournament" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/tournament" "github.com/spf13/cobra" ) diff --git a/cmd/ui.go b/cmd/ui.go index 56dfe9f..a42d69d 100644 --- a/cmd/ui.go +++ b/cmd/ui.go @@ -4,7 +4,7 @@ import ( "log" "os" - "github.com/slshen/sb/pkg/ui" + "github.com/slshen/paperscore/pkg/ui" "github.com/spf13/cobra" ) diff --git a/doc/score.jpeg b/doc/score.jpeg new file mode 100644 index 0000000..3343e12 Binary files /dev/null and b/doc/score.jpeg differ diff --git a/go.mod b/go.mod index c540eb4..32633ed 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/slshen/sb +module github.com/slshen/paperscore go 1.22.0 diff --git a/main.go b/main.go index 3ac8ea8..5f8bc74 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/slshen/sb/cmd" + "github.com/slshen/paperscore/cmd" ) func main() { diff --git a/pkg/boxscore/box.go b/pkg/boxscore/box.go index bba60c7..c15fb29 100644 --- a/pkg/boxscore/box.go +++ b/pkg/boxscore/box.go @@ -7,11 +7,11 @@ import ( "strings" "text/template" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/playbyplay" - "github.com/slshen/sb/pkg/stats" - "github.com/slshen/sb/pkg/text" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/playbyplay" + "github.com/slshen/paperscore/pkg/stats" + "github.com/slshen/paperscore/pkg/text" ) //go:embed "*.tmpl" diff --git a/pkg/boxscore/box_test.go b/pkg/boxscore/box_test.go index 1f967e1..23bbcbf 100644 --- a/pkg/boxscore/box_test.go +++ b/pkg/boxscore/box_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/stretchr/testify/assert" ) diff --git a/pkg/boxscore/lineup.go b/pkg/boxscore/lineup.go index 90acc01..2cadb9b 100644 --- a/pkg/boxscore/lineup.go +++ b/pkg/boxscore/lineup.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/stats" - "github.com/slshen/sb/pkg/text" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/stats" + "github.com/slshen/paperscore/pkg/text" ) type Lineup struct { diff --git a/pkg/boxscore/util.go b/pkg/boxscore/util.go index 926a033..6acf629 100644 --- a/pkg/boxscore/util.go +++ b/pkg/boxscore/util.go @@ -6,7 +6,7 @@ import ( "strings" "text/template" - "github.com/slshen/sb/pkg/text" + "github.com/slshen/paperscore/pkg/text" ) func firstWord(s string, w int) string { diff --git a/pkg/dataexport/dataexport.go b/pkg/dataexport/dataexport.go index a849f23..c948a29 100644 --- a/pkg/dataexport/dataexport.go +++ b/pkg/dataexport/dataexport.go @@ -5,11 +5,11 @@ import ( "sort" "time" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/dataframe/pkg" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" - "github.com/slshen/sb/pkg/tournament" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/dataframe/pkg" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" + "github.com/slshen/paperscore/pkg/tournament" ) type DataExport struct { diff --git a/pkg/dataexport/event.go b/pkg/dataexport/event.go index 6846f29..2e206fa 100644 --- a/pkg/dataexport/event.go +++ b/pkg/dataexport/event.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/mitchellh/mapstructure" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" ) type Event struct { diff --git a/pkg/dataexport/event_test.go b/pkg/dataexport/event_test.go index fc0ae79..4f92559 100644 --- a/pkg/dataexport/event_test.go +++ b/pkg/dataexport/event_test.go @@ -3,7 +3,7 @@ package dataexport import ( "testing" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/stretchr/testify/assert" ) diff --git a/pkg/dataexport/game.go b/pkg/dataexport/game.go index 902f388..41e4e00 100644 --- a/pkg/dataexport/game.go +++ b/pkg/dataexport/game.go @@ -4,9 +4,9 @@ import ( "fmt" "path/filepath" - "github.com/slshen/sb/pkg/boxscore" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/boxscore" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type Game struct { diff --git a/pkg/dataexport/gamestats.go b/pkg/dataexport/gamestats.go index 2c28922..d9d350a 100644 --- a/pkg/dataexport/gamestats.go +++ b/pkg/dataexport/gamestats.go @@ -1,9 +1,9 @@ package dataexport import ( - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" ) type GameStats struct { diff --git a/pkg/dataexport/tournament.go b/pkg/dataexport/tournament.go index 29817af..3594e51 100644 --- a/pkg/dataexport/tournament.go +++ b/pkg/dataexport/tournament.go @@ -3,7 +3,7 @@ package dataexport import ( "time" - "github.com/slshen/sb/pkg/tournament" + "github.com/slshen/paperscore/pkg/tournament" ) type Tournament struct { diff --git a/pkg/dataframe/data.go b/pkg/dataframe/data.go index 86792cd..0761bb3 100644 --- a/pkg/dataframe/data.go +++ b/pkg/dataframe/data.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/mitchellh/mapstructure" - "github.com/slshen/sb/pkg/text" + "github.com/slshen/paperscore/pkg/text" ) type Update interface { diff --git a/pkg/dataframe/pkg/datapackage.go b/pkg/dataframe/pkg/datapackage.go index 46c6a5e..1760baa 100644 --- a/pkg/dataframe/pkg/datapackage.go +++ b/pkg/dataframe/pkg/datapackage.go @@ -8,7 +8,7 @@ import ( "os" "path/filepath" - "github.com/slshen/sb/pkg/dataframe" + "github.com/slshen/paperscore/pkg/dataframe" ) type License string diff --git a/pkg/game/advance.go b/pkg/game/advance.go index 5a11d71..15728ce 100644 --- a/pkg/game/advance.go +++ b/pkg/game/advance.go @@ -3,7 +3,7 @@ package game import ( "regexp" - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" ) type Advance struct { diff --git a/pkg/game/advance_test.go b/pkg/game/advance_test.go index f1b9e1d..6e83b3f 100644 --- a/pkg/game/advance_test.go +++ b/pkg/game/advance_test.go @@ -3,7 +3,7 @@ package game import ( "testing" - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" "github.com/stretchr/testify/assert" ) diff --git a/pkg/game/error.go b/pkg/game/error.go index 70df737..3ff0b79 100644 --- a/pkg/game/error.go +++ b/pkg/game/error.go @@ -3,7 +3,7 @@ package game import ( "fmt" - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" ) type Error struct { diff --git a/pkg/game/fieldingerror.go b/pkg/game/fieldingerror.go index efb5d7f..bd0ce4d 100644 --- a/pkg/game/fieldingerror.go +++ b/pkg/game/fieldingerror.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" ) type FieldingError struct { diff --git a/pkg/game/game.go b/pkg/game/game.go index 72110b9..baa9907 100644 --- a/pkg/game/game.go +++ b/pkg/game/game.go @@ -9,7 +9,7 @@ import ( "time" "github.com/hashicorp/go-multierror" - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" ) type Score struct { diff --git a/pkg/game/gamemachine.go b/pkg/game/gamemachine.go index 3906a19..9572a84 100644 --- a/pkg/game/gamemachine.go +++ b/pkg/game/gamemachine.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/alecthomas/participle/v2/lexer" - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" ) type gameMachine struct { diff --git a/pkg/game/gamemachine_test.go b/pkg/game/gamemachine_test.go index 757ff84..155d1ef 100644 --- a/pkg/game/gamemachine_test.go +++ b/pkg/game/gamemachine_test.go @@ -3,7 +3,7 @@ package game import ( "testing" - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" "github.com/stretchr/testify/assert" ) diff --git a/pkg/game/state.go b/pkg/game/state.go index adcd07f..278e23d 100644 --- a/pkg/game/state.go +++ b/pkg/game/state.go @@ -5,7 +5,7 @@ import ( "regexp" "strings" - "github.com/slshen/sb/pkg/gamefile" + "github.com/slshen/paperscore/pkg/gamefile" ) type Pitches string diff --git a/pkg/gamefile/file.go b/pkg/gamefile/file.go index 1e3231a..bb83e65 100644 --- a/pkg/gamefile/file.go +++ b/pkg/gamefile/file.go @@ -235,7 +235,6 @@ func (f *File) writeEvents(w io.Writer, name string, events []*Event) { fmt.Fprintf(w, "final %s\n", event.Final) } } - fmt.Fprintln(w) } func (f *File) writeCodeAdvancesComment(w io.Writer, code string, advances []string, afters []*LineupChange, comment string) { diff --git a/pkg/markov/expr/file.go b/pkg/markov/expr/file.go index 1de2a57..527af1f 100644 --- a/pkg/markov/expr/file.go +++ b/pkg/markov/expr/file.go @@ -5,7 +5,7 @@ import ( "github.com/alecthomas/participle/v2" "github.com/alecthomas/participle/v2/lexer" - "github.com/slshen/sb/pkg/markov" + "github.com/slshen/paperscore/pkg/markov" ) type Position = lexer.Position diff --git a/pkg/markov/expr/model.go b/pkg/markov/expr/model.go index 8cade31..9338fd6 100644 --- a/pkg/markov/expr/model.go +++ b/pkg/markov/expr/model.go @@ -4,7 +4,7 @@ import ( "fmt" "math/rand" - "github.com/slshen/sb/pkg/markov" + "github.com/slshen/paperscore/pkg/markov" ) type ExprModel struct { diff --git a/pkg/markov/expr/model_test.go b/pkg/markov/expr/model_test.go index 04f9f9f..ab432f8 100644 --- a/pkg/markov/expr/model_test.go +++ b/pkg/markov/expr/model_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/slshen/sb/pkg/markov" + "github.com/slshen/paperscore/pkg/markov" "github.com/stretchr/testify/assert" ) diff --git a/pkg/playbyplay/playbyplay.go b/pkg/playbyplay/playbyplay.go index 691344b..229f565 100644 --- a/pkg/playbyplay/playbyplay.go +++ b/pkg/playbyplay/playbyplay.go @@ -5,8 +5,8 @@ import ( "io" "strings" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/text" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/text" ) type Generator struct { diff --git a/pkg/playbyplay/playbyplay_test.go b/pkg/playbyplay/playbyplay_test.go index 5fb18bf..cb9d6f6 100644 --- a/pkg/playbyplay/playbyplay_test.go +++ b/pkg/playbyplay/playbyplay_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/stretchr/testify/assert" ) diff --git a/pkg/sim/wp/freq.go b/pkg/sim/wp/freq.go index 53cd870..641b782 100644 --- a/pkg/sim/wp/freq.go +++ b/pkg/sim/wp/freq.go @@ -9,7 +9,7 @@ import ( "strconv" "time" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/stats" ) type RunFrequency struct { diff --git a/pkg/stats/alt_data.go b/pkg/stats/alt_data.go index 769abc0..654acf9 100644 --- a/pkg/stats/alt_data.go +++ b/pkg/stats/alt_data.go @@ -3,8 +3,8 @@ package stats import ( "fmt" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type AltData struct { diff --git a/pkg/stats/bat_situation.go b/pkg/stats/bat_situation.go index 2ebdc33..ec0c2cd 100644 --- a/pkg/stats/bat_situation.go +++ b/pkg/stats/bat_situation.go @@ -3,8 +3,8 @@ package stats import ( "fmt" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type BattingCountSituations struct { diff --git a/pkg/stats/batting.go b/pkg/stats/batting.go index 654ebd4..60d7909 100644 --- a/pkg/stats/batting.go +++ b/pkg/stats/batting.go @@ -1,7 +1,7 @@ package stats import ( - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" ) type Batting struct { @@ -152,9 +152,9 @@ func (b *Batting) Record(state *game.State) (teamLOB int) { } if state.Complete || state.Incomplete { b.PitchesSeen += len(state.Pitches) - b.Strikes += state.Pitches.CountUp('C', 'S', 'F', 'M', 'L') - b.Swings += state.Pitches.CountUp('S', 'F', 'M') - b.Misses += state.Pitches.CountUp('S', 'M') + b.Strikes += state.Pitches.CountUp('C', 'S', 'F', 'M', 'L', 'T') + b.Swings += state.Pitches.CountUp('S', 'F', 'M', 'T') + b.Misses += state.Pitches.CountUp('S', 'M', 'T') b.CalledStrikes += state.Pitches.CountUp('C') b.MissedBunts += state.Pitches.CountUp('M') b.FoulBunts += state.Pitches.CountUp('L') diff --git a/pkg/stats/batting_funcs.go b/pkg/stats/batting_funcs.go index 5aa70e2..7c5034b 100644 --- a/pkg/stats/batting_funcs.go +++ b/pkg/stats/batting_funcs.go @@ -1,6 +1,6 @@ package stats -import "github.com/slshen/sb/pkg/dataframe" +import "github.com/slshen/paperscore/pkg/dataframe" func OnBase(idx *dataframe.Index, row int) float64 { hbp := idx.GetInt(row, "HitByPitch") diff --git a/pkg/stats/batting_times.go b/pkg/stats/batting_times.go index 2a0b613..1432251 100644 --- a/pkg/stats/batting_times.go +++ b/pkg/stats/batting_times.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type BatterTimesSeenPitcher struct { diff --git a/pkg/stats/columns.go b/pkg/stats/columns.go index 041c72a..2554e60 100644 --- a/pkg/stats/columns.go +++ b/pkg/stats/columns.go @@ -7,7 +7,7 @@ import ( "fmt" "strings" - "github.com/slshen/sb/pkg/dataframe" + "github.com/slshen/paperscore/pkg/dataframe" ) //go:embed *_columns.txt diff --git a/pkg/stats/fielding.go b/pkg/stats/fielding.go index 6e812f3..45996f6 100644 --- a/pkg/stats/fielding.go +++ b/pkg/stats/fielding.go @@ -1,7 +1,7 @@ package stats import ( - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" ) type FieldingStats struct { diff --git a/pkg/stats/gamestats.go b/pkg/stats/gamestats.go index 5883c1d..0e99c26 100644 --- a/pkg/stats/gamestats.go +++ b/pkg/stats/gamestats.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type GameStats struct { diff --git a/pkg/stats/gamestats_test.go b/pkg/stats/gamestats_test.go index 5abdab6..dc50ded 100644 --- a/pkg/stats/gamestats_test.go +++ b/pkg/stats/gamestats_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/stretchr/testify/assert" ) diff --git a/pkg/stats/observed_re.go b/pkg/stats/observed_re.go index 12f4526..c50d684 100644 --- a/pkg/stats/observed_re.go +++ b/pkg/stats/observed_re.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type ObservedRunExpectancy struct { diff --git a/pkg/stats/observed_re_test.go b/pkg/stats/observed_re_test.go index 127485e..41fc41c 100644 --- a/pkg/stats/observed_re_test.go +++ b/pkg/stats/observed_re_test.go @@ -4,7 +4,7 @@ import ( "path/filepath" "testing" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/stretchr/testify/assert" ) diff --git a/pkg/stats/pitching.go b/pkg/stats/pitching.go index f57106b..c6a47b0 100644 --- a/pkg/stats/pitching.go +++ b/pkg/stats/pitching.go @@ -3,7 +3,7 @@ package stats import ( "fmt" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" ) type Pitching struct { diff --git a/pkg/stats/pitching_times.go b/pkg/stats/pitching_times.go index 0a0580f..af75337 100644 --- a/pkg/stats/pitching_times.go +++ b/pkg/stats/pitching_times.go @@ -3,8 +3,8 @@ package stats import ( "fmt" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type PitcherTimesLineup struct { diff --git a/pkg/stats/player.go b/pkg/stats/player.go index 99358c9..7f2c849 100644 --- a/pkg/stats/player.go +++ b/pkg/stats/player.go @@ -1,6 +1,6 @@ package stats -import "github.com/slshen/sb/pkg/game" +import "github.com/slshen/paperscore/pkg/game" type PlayerData struct { Name string diff --git a/pkg/stats/re.go b/pkg/stats/re.go index a30c8af..56ca546 100644 --- a/pkg/stats/re.go +++ b/pkg/stats/re.go @@ -1,8 +1,8 @@ package stats import ( - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type RunExpectancy interface { diff --git a/pkg/stats/re24.go b/pkg/stats/re24.go index 2f08828..99ecbdb 100644 --- a/pkg/stats/re24.go +++ b/pkg/stats/re24.go @@ -1,6 +1,6 @@ package stats -import "github.com/slshen/sb/pkg/dataframe" +import "github.com/slshen/paperscore/pkg/dataframe" func GetBiggestRE24(dat *dataframe.Data, n int) *dataframe.Data { idx := dat.GetIndex() diff --git a/pkg/stats/re_analysis.go b/pkg/stats/re_analysis.go index f5e31af..64b2321 100644 --- a/pkg/stats/re_analysis.go +++ b/pkg/stats/re_analysis.go @@ -1,6 +1,6 @@ package stats -import "github.com/slshen/sb/pkg/dataframe" +import "github.com/slshen/paperscore/pkg/dataframe" type REAnalysis struct { RE RunExpectancy diff --git a/pkg/stats/re_analysis_test.go b/pkg/stats/re_analysis_test.go index 6f32c21..ecf707f 100644 --- a/pkg/stats/re_analysis_test.go +++ b/pkg/stats/re_analysis_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/stretchr/testify/assert" ) diff --git a/pkg/stats/re_data.go b/pkg/stats/re_data.go index 11fc5db..ad45f38 100644 --- a/pkg/stats/re_data.go +++ b/pkg/stats/re_data.go @@ -3,8 +3,8 @@ package stats import ( "strings" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type REData struct { diff --git a/pkg/stats/teamstats.go b/pkg/stats/teamstats.go index 9660293..6b91434 100644 --- a/pkg/stats/teamstats.go +++ b/pkg/stats/teamstats.go @@ -3,8 +3,8 @@ package stats import ( "fmt" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/game" ) type TeamStats struct { diff --git a/pkg/tournament/group.go b/pkg/tournament/group.go index 0c1b5fa..c69fc93 100644 --- a/pkg/tournament/group.go +++ b/pkg/tournament/group.go @@ -5,7 +5,7 @@ import ( "sort" "time" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" ) type Group struct { diff --git a/pkg/tournament/group_test.go b/pkg/tournament/group_test.go index a8a3f52..9c4d71d 100644 --- a/pkg/tournament/group_test.go +++ b/pkg/tournament/group_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/slshen/sb/pkg/game" + "github.com/slshen/paperscore/pkg/game" "github.com/stretchr/testify/assert" ) diff --git a/pkg/tournament/report.go b/pkg/tournament/report.go index 50e46a1..c967a05 100644 --- a/pkg/tournament/report.go +++ b/pkg/tournament/report.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/slshen/sb/pkg/dataframe" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/dataframe" + "github.com/slshen/paperscore/pkg/stats" ) type Report struct { diff --git a/pkg/tournament/report_test.go b/pkg/tournament/report_test.go index 2f078a7..9a64bd1 100644 --- a/pkg/tournament/report_test.go +++ b/pkg/tournament/report_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/stats" "github.com/stretchr/testify/assert" ) diff --git a/pkg/ui/ui.go b/pkg/ui/ui.go index 3f49669..0a51893 100644 --- a/pkg/ui/ui.go +++ b/pkg/ui/ui.go @@ -17,10 +17,10 @@ import ( "github.com/gdamore/tcell/v2" "github.com/hashicorp/go-multierror" "github.com/rivo/tview" - "github.com/slshen/sb/pkg/boxscore" - "github.com/slshen/sb/pkg/game" - "github.com/slshen/sb/pkg/gamefile" - "github.com/slshen/sb/pkg/stats" + "github.com/slshen/paperscore/pkg/boxscore" + "github.com/slshen/paperscore/pkg/game" + "github.com/slshen/paperscore/pkg/gamefile" + "github.com/slshen/paperscore/pkg/stats" ) type UI struct { @@ -73,7 +73,7 @@ func New() *UI { 0, 1, false). AddItem(ui.messages, 6, 0, false). AddItem(tview.NewFlex(). - AddItem(tview.NewTextView().SetText("Quit:^Q Save:^S Choose:^L Swap:^R"), 0, 4, false). + AddItem(tview.NewTextView().SetText("Quit:^Q Save:^S Choose:^L Swap:^R Box:^Z"), 0, 4, false). AddItem(ui.status, 0, 1, false), 1, 0, false) ui.root.AddAndSwitchToPage("main", flex, true) @@ -288,6 +288,9 @@ func (ui *UI) swapHomeAndAway() { } func (ui *UI) inputHandler(event *tcell.EventKey) *tcell.EventKey { + if ui.dialog != nil { + return event + } var focusInc int switch event.Key() { case tcell.KeyCtrlQ: @@ -306,6 +309,9 @@ func (ui *UI) inputHandler(event *tcell.EventKey) *tcell.EventKey { return nil case tcell.KeyCtrlR: ui.swapHomeAndAway() + case tcell.KeyCtrlZ: + ui.showBox() + return nil case tcell.KeyCtrlP: return tcell.NewEventKey(tcell.KeyUp, 0, 0) case tcell.KeyCtrlN: @@ -450,6 +456,40 @@ func (ui *UI) showQuestionDialog(question string, okLabel string, ok func()) { ui.showDialog(modal) } +func (ui *UI) showBox() { + gf, err := gamefile.ParseString(ui.path, ui.getGameText()) + if err != nil { + ui.messages.SetText(fmt.Sprintf("gamefile is invalid: %s", err.Error())) + return + } + g, err := game.NewGame(gf) + if g == nil { + ui.messages.SetText(fmt.Sprintf("game is invalid: %s", err.Error())) + return + } + box, err := boxscore.NewBoxScore(g, ui.RE) + if err != nil { + ui.messages.SetText(fmt.Sprintf("could not generate boxscore: %s", err.Error())) + return + } + box.IncludePlays = true + var s strings.Builder + _ = box.Render(&s) + flex := tview.NewFlex().SetDirection(tview.FlexRow) + flex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { + if event.Key() == tcell.KeyCtrlQ { + ui.closeDialog() + return nil + } + return event + }) + view := tview.NewTextView().SetText(s.String()) + view.SetBorder(true) + flex.AddItem(view, 0, 1, true). + AddItem(tview.NewTextView().SetText("Close:^Q"), 1, 0, false) + ui.showDialog(flex) +} + func (ui *UI) backgroundUpdate(ticker *time.Ticker, done <-chan bool) { for { select {