Skip to content

Commit

Permalink
feat(player): allow mark player as inactive and will not show in anal…
Browse files Browse the repository at this point in the history
…ysis by default
  • Loading branch information
crispgm committed Jul 1, 2024
1 parent f2b2088 commit 7b189fe
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions cmd/kicker-cli/cmd/event_analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
rankMinPlayed int
rankHead int
rankTail int
rankShowInactive bool
rankSortBy string
rankPlayerName string
rankOutputFormat string
Expand All @@ -27,6 +28,7 @@ var (
func init() {
analyzeCmd.Flags().StringVarP(&rankGameMode, "mode", "m", "", "rank mode")
analyzeCmd.Flags().StringVarP(&rankSortBy, "sort-by", "o", "KRP", "sort by (KRP/ITSF/ATSA/ELO/WR)")
analyzeCmd.Flags().BoolVarP(&rankShowInactive, "show-inactive", "i", false, "show inactive players")
analyzeCmd.Flags().IntVarP(&rankMinPlayed, "minimum-played", "p", 0, "minimum matches played")
analyzeCmd.Flags().IntVarP(&rankHead, "head", "", 0, "display the head part of rank")
analyzeCmd.Flags().IntVarP(&rankTail, "tail", "", 0, "display the last part of rank")
Expand Down Expand Up @@ -132,6 +134,7 @@ var analyzeCmd = &cobra.Command{
Head: rankHead,
Tail: rankTail,
PlayerName: rankPlayerName,
ShowInactive: rankShowInactive,

OutputFormat: strings.ToLower(rankOutputFormat),
WithHeader: !globalNoHeaders,
Expand Down
7 changes: 6 additions & 1 deletion cmd/kicker-cli/cmd/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func listPlayerCommand(cmd *cobra.Command, args []string) {
instance := initInstanceAndLoadConf()
// load tournaments
var table [][]string
header := []string{"ID", "Name", "ITSF_ID", "ATSA_ID", "A.K.A"}
header := []string{"ID", "Name", "ITSF_ID", "ATSA_ID", "A.K.A", "Inactive?"}
if !globalNoHeaders {
table = append(table, header)
}
Expand All @@ -45,12 +45,17 @@ func listPlayerCommand(cmd *cobra.Command, args []string) {
instance.Conf.Players[i].ID = p.ID
needWrite = true
}
inactiveStatus := ""
if p.Inactive {
inactiveStatus = "Y"
}
table = append(table, []string{
p.ID,
p.Name,
dashIfEmpty(p.ITSFID),
dashIfEmpty(p.ATSAID),
dashIfEmpty(strings.Join(p.Aliases, ", ")),
inactiveStatus,
})
}
_ = pterm.DefaultTable.WithHasHeader(!globalNoHeaders).WithData(table).WithBoxed(!globalNoBoxes).Render()
Expand Down
11 changes: 6 additions & 5 deletions internal/entity/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (

// Player is a real world player
type Player struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Aliases []string `yaml:"aliases"`
ATSAID string `yaml:"atsa_id,omitempty"`
ITSFID string `yaml:"itsf_id,omitempty"`
ID string `yaml:"id"`
Name string `yaml:"name"`
Aliases []string `yaml:"aliases"`
ATSAID string `yaml:"atsa_id,omitempty"`
ITSFID string `yaml:"itsf_id,omitempty"`
Inactive bool `yaml:"inactive,omitempty"`
// major statistical data, not write
EventsPlayed int `yaml:"-"`
GamesPlayed int `yaml:"-"`
Expand Down
1 change: 1 addition & 0 deletions internal/operator/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Operator interface {
type Option struct {
OrderBy string
MinimumPlayed int
ShowInactive bool
Head int
Tail int
PlayerName string
Expand Down
3 changes: 3 additions & 0 deletions internal/operator/single_player_rank.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ func (o *SinglePlayerRank) Output() {
header := []string{"#", "Name", "Events", "Games", "Win", "Loss", "Draw", "WR%", "ELO", "KRP", "ATSA", "ITSF"}
table := [][]string{}
for i, d := range sliceData {
if o.options.ShowInactive && d.Inactive {
continue
}
item := []string{
fmt.Sprintf("%d", i+1),
d.Name,
Expand Down

0 comments on commit 7b189fe

Please sign in to comment.