From be00a8bf05f177ae9ca8491e7991545d8dbe345f Mon Sep 17 00:00:00 2001 From: Matheus Moraes Date: Thu, 16 Dec 2021 02:00:52 -0300 Subject: [PATCH] add players flags --- README.md | 75 +++++++++++++++++- cmd/clubs.go | 6 +- cmd/players.go | 189 +++++++++++++++++++++++++++++++++++++++----- cmd/players_test.go | 35 ++++++++ cmd/root.go | 4 +- players/client.go | 3 +- players/options.go | 122 ++++++++++++++-------------- players/query.go | 146 ++++++++++++++++++++++++++++++++++ 8 files changed, 485 insertions(+), 95 deletions(-) create mode 100644 cmd/players_test.go create mode 100644 players/query.go diff --git a/README.md b/README.md index 06ccb5b..d1edd52 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,6 @@ go install github.com/matheusfm/futbin@latest # Usage ``` -futbin command line tool - Usage: futbin [command] @@ -37,13 +35,82 @@ Available Commands: totw current TOTW players Flags: - --config string config file (default is $HOME/.futbin.yaml) + --config string Config file (default is $HOME/.futbin.yaml) -h, --help help for futbin - --platform string platform (PS, XB or PC) (default "PS") + --platform string Platform (PS, XB or PC) (default "PS") Use "futbin [command] --help" for more information about a command. ``` +### `players` command examples: + +``` +Usage: + futbin players [flags] + +Examples: +1. # Brazilian players in LaLiga: + futbin players --nation 54 --league 53 +2. # OTW players (see options in 'futbin cardversions' command): + futbin players --version otw +3. # Brazilian players with more than 90 of passing: + futbin players --nation 54 --passing 90- +4. # Icons with a maximum price of 300K: + futbin players --league 2118 --price -300000 +5. # Players with 5 weak foot and 5 skills: + futbin players --wf 5 --skills 5 + +Flags: + --acceleration string Acceleration + --aggression string Aggression + --agility string Agility + --balance string Balance + --ball-control string Ball Control + --club int Club ID + --composure string Composure + --crossing string Crossing + --curve string Curve + --defending string Defending + --dribbling string Dribbling + --finishing string Finishing + --free-kick-accuracy string Free Kick Accuracy + --heading-accuracy string Heading Accuracy + -h, --help help for players + --interceptions string Interceptions + --jumping string Jumping + --league int League ID + --long-passing string Long Passing + --long-shots string Long Shots + --marking string Marking + --nation int Nation ID + --ovr string Rating + --pace string Pace + --page int Page (default 1) + --passing string Passing + --penalties string Penalties + --physicality string Physicality + --positioning string Positioning + --price string Price + --reactions string Reactions + --shooting string Shooting + --short-passing string Short Passing + --shot-power string Shot Power + --skills string Skills + --sliding-tackle string Sliding Tackle + --sprint-speed string Sprint Speed + --stamina string Stamina + --standing-tackle string Standing Tackle + --strength string Strength + --version string Card version + --vision string Vision + --volleys string Volleys + --wf string Weak Foot + +Global Flags: + --config string Config file (default is $HOME/.futbin.yaml) + --platform string Platform (PS, XB or PC) (default "PS") +``` + ## Usage (Library) ```go diff --git a/cmd/clubs.go b/cmd/clubs.go index 833765b..693ac18 100644 --- a/cmd/clubs.go +++ b/cmd/clubs.go @@ -17,9 +17,7 @@ var clubsCmd = &cobra.Command{ cobra.CheckErr(err) data := make([][]string, 1) for _, league := range leagues { - // 0 -> percorre e adiciona - // - if fLeagueID != 0 && fLeagueID != league.ID { + if flagLeagueID != 0 && flagLeagueID != league.ID { continue } for _, club := range league.Clubs { @@ -41,5 +39,5 @@ var clubsCmd = &cobra.Command{ func init() { rootCmd.AddCommand(clubsCmd) - clubsCmd.PersistentFlags().IntVar(&fLeagueID, "league", 0, "league ID") + clubsCmd.PersistentFlags().IntVar(&flagLeagueID, "league", 0, "League ID") } diff --git a/cmd/players.go b/cmd/players.go index a312a8b..8bdcf82 100644 --- a/cmd/players.go +++ b/cmd/players.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "strconv" + "strings" "github.com/dustin/go-humanize" "github.com/fatih/color" @@ -12,12 +13,50 @@ import ( ) var ( - playersClient = players.DefaultClient() - fPage int - fVersion string - fClubID int - fNationID int - fLeagueID int + playersClient = players.DefaultClient() + flagPage int + flagVersion string + flagClubID int + flagNationID int + flagLeagueID int + flagPrice string + flagWeakFoot string + flagSkills string + flagRating string + flagPace string + flagAcceleration string + flagSprintSpeed string + flagShooting string + flagPositioning string + flagFinishing string + flagShotPower string + flagLongShots string + flagVolleys string + flagPenalties string + flagDribbling string + flagAgility string + flagBalance string + flagReactions string + flagBallControl string + flagComposure string + flagDefending string + flagInterceptions string + flagHeadingAccuracy string + flagMarking string + flagStandingTackle string + flagSlidingTackle string + flagPassing string + flagVision string + flagCrossing string + flagFreeKickAccuracy string + flagShortPassing string + flagLongPassing string + flagCurve string + flagPhysicality string + flagJumping string + flagStamina string + flagStrength string + flagAggression string ) // playersCmd represents the players command @@ -27,15 +66,59 @@ var playersCmd = &cobra.Command{ Example: `1. # Brazilian players in LaLiga: futbin players --nation 54 --league 53 2. # OTW players (see options in 'futbin cardversions' command): - futbin players --version otw`, + futbin players --version otw +3. # Brazilian players with more than 90 of passing: + futbin players --nation 54 --passing 90- +4. # Icons with a maximum price of 300K: + futbin players --league 2118 --price -300000 +5. # Players with 5 weak foot and 5 skills: + futbin players --wf 5 --skills 5`, Run: func(cmd *cobra.Command, args []string) { p, err := playersClient.Get(&players.Options{ - Platform: platform, - Page: fPage, - Version: fVersion, - ClubID: fClubID, - NationID: fNationID, - LeagueID: fLeagueID, + Platform: platform, + Page: flagPage, + Version: flagVersion, + ClubID: flagClubID, + NationID: flagNationID, + LeagueID: flagLeagueID, + Price: flagToRange(flagPrice), + WeakFoot: flagToRange(flagWeakFoot), + Skills: flagToRange(flagSkills), + Rating: flagToRange(flagRating), + Pace: flagToRange(flagPace), + Acceleration: flagToRange(flagAcceleration), + SprintSpeed: flagToRange(flagSprintSpeed), + Shooting: flagToRange(flagShooting), + Positioning: flagToRange(flagPositioning), + Finishing: flagToRange(flagFinishing), + ShotPower: flagToRange(flagShotPower), + LongShots: flagToRange(flagLongShots), + Volleys: flagToRange(flagVolleys), + Penalties: flagToRange(flagPenalties), + Dribbling: flagToRange(flagDribbling), + Agility: flagToRange(flagAgility), + Balance: flagToRange(flagBalance), + Reactions: flagToRange(flagReactions), + BallControl: flagToRange(flagBallControl), + Composure: flagToRange(flagComposure), + Defending: flagToRange(flagDefending), + Interceptions: flagToRange(flagInterceptions), + HeadingAccuracy: flagToRange(flagHeadingAccuracy), + Marking: flagToRange(flagMarking), + StandingTackle: flagToRange(flagStandingTackle), + SlidingTackle: flagToRange(flagSlidingTackle), + Passing: flagToRange(flagPassing), + Vision: flagToRange(flagVision), + Crossing: flagToRange(flagCrossing), + FreeKickAccuracy: flagToRange(flagFreeKickAccuracy), + ShortPassing: flagToRange(flagShortPassing), + LongPassing: flagToRange(flagLongPassing), + Curve: flagToRange(flagCurve), + Physicality: flagToRange(flagPhysicality), + Jumping: flagToRange(flagJumping), + Stamina: flagToRange(flagStamina), + Strength: flagToRange(flagStrength), + Aggression: flagToRange(flagAggression), }) cobra.CheckErr(err) printPlayers(p) @@ -44,12 +127,49 @@ var playersCmd = &cobra.Command{ func init() { rootCmd.AddCommand(playersCmd) - - playersCmd.PersistentFlags().IntVar(&fPage, "page", 1, "page") - playersCmd.PersistentFlags().StringVar(&fVersion, "version", "", "card version") - playersCmd.PersistentFlags().IntVar(&fClubID, "club", 0, "club ID") - playersCmd.PersistentFlags().IntVar(&fNationID, "nation", 0, "nation ID") - playersCmd.PersistentFlags().IntVar(&fLeagueID, "league", 0, "league ID") + playersCmd.PersistentFlags().IntVar(&flagPage, "page", 1, "Page") + playersCmd.PersistentFlags().StringVar(&flagVersion, "version", "", "Card version") + playersCmd.PersistentFlags().IntVar(&flagClubID, "club", 0, "Club ID") + playersCmd.PersistentFlags().IntVar(&flagNationID, "nation", 0, "Nation ID") + playersCmd.PersistentFlags().IntVar(&flagLeagueID, "league", 0, "League ID") + playersCmd.PersistentFlags().StringVar(&flagWeakFoot, "wf", "", "Weak Foot") + playersCmd.PersistentFlags().StringVar(&flagSkills, "skills", "", "Skills") + playersCmd.PersistentFlags().StringVar(&flagRating, "ovr", "", "Rating") + playersCmd.PersistentFlags().StringVar(&flagPrice, "price", "", "Price") + playersCmd.PersistentFlags().StringVar(&flagPace, "pace", "", "Pace") + playersCmd.PersistentFlags().StringVar(&flagAcceleration, "acceleration", "", "Acceleration") + playersCmd.PersistentFlags().StringVar(&flagSprintSpeed, "sprint-speed", "", "Sprint Speed") + playersCmd.PersistentFlags().StringVar(&flagShooting, "shooting", "", "Shooting") + playersCmd.PersistentFlags().StringVar(&flagPositioning, "positioning", "", "Positioning") + playersCmd.PersistentFlags().StringVar(&flagFinishing, "finishing", "", "Finishing") + playersCmd.PersistentFlags().StringVar(&flagShotPower, "shot-power", "", "Shot Power") + playersCmd.PersistentFlags().StringVar(&flagLongShots, "long-shots", "", "Long Shots") + playersCmd.PersistentFlags().StringVar(&flagVolleys, "volleys", "", "Volleys") + playersCmd.PersistentFlags().StringVar(&flagPenalties, "penalties", "", "Penalties") + playersCmd.PersistentFlags().StringVar(&flagDribbling, "dribbling", "", "Dribbling") + playersCmd.PersistentFlags().StringVar(&flagAgility, "agility", "", "Agility") + playersCmd.PersistentFlags().StringVar(&flagBalance, "balance", "", "Balance") + playersCmd.PersistentFlags().StringVar(&flagReactions, "reactions", "", "Reactions") + playersCmd.PersistentFlags().StringVar(&flagBallControl, "ball-control", "", "Ball Control") + playersCmd.PersistentFlags().StringVar(&flagComposure, "composure", "", "Composure") + playersCmd.PersistentFlags().StringVar(&flagDefending, "defending", "", "Defending") + playersCmd.PersistentFlags().StringVar(&flagInterceptions, "interceptions", "", "Interceptions") + playersCmd.PersistentFlags().StringVar(&flagHeadingAccuracy, "heading-accuracy", "", "Heading Accuracy") + playersCmd.PersistentFlags().StringVar(&flagMarking, "marking", "", "Marking") + playersCmd.PersistentFlags().StringVar(&flagStandingTackle, "standing-tackle", "", "Standing Tackle") + playersCmd.PersistentFlags().StringVar(&flagSlidingTackle, "sliding-tackle", "", "Sliding Tackle") + playersCmd.PersistentFlags().StringVar(&flagPassing, "passing", "", "Passing") + playersCmd.PersistentFlags().StringVar(&flagVision, "vision", "", "Vision") + playersCmd.PersistentFlags().StringVar(&flagCrossing, "crossing", "", "Crossing") + playersCmd.PersistentFlags().StringVar(&flagFreeKickAccuracy, "free-kick-accuracy", "", "Free Kick Accuracy") + playersCmd.PersistentFlags().StringVar(&flagShortPassing, "short-passing", "", "Short Passing") + playersCmd.PersistentFlags().StringVar(&flagLongPassing, "long-passing", "", "Long Passing") + playersCmd.PersistentFlags().StringVar(&flagCurve, "curve", "", "Curve") + playersCmd.PersistentFlags().StringVar(&flagPhysicality, "physicality", "", "Physicality") + playersCmd.PersistentFlags().StringVar(&flagJumping, "jumping", "", "Jumping") + playersCmd.PersistentFlags().StringVar(&flagStamina, "stamina", "", "Stamina") + playersCmd.PersistentFlags().StringVar(&flagStrength, "strength", "", "Strength") + playersCmd.PersistentFlags().StringVar(&flagAggression, "aggression", "", "Aggression") } func printPlayers(p []players.Player) { @@ -79,7 +199,7 @@ func printPlayers(p []players.Player) { fmt.Sprintf("%s (%d)", nations.Nations[player.NationID], player.NationID), fmt.Sprintf("%s (%d)", player.League, player.LeagueID), player.Position, - humanize.Comma(int64(player.Price(platform))), + color.HiYellowString(humanize.Comma(int64(player.Price(platform)))), colorStat(player.Pace), colorStat(player.Shooting), colorStat(player.Passing), @@ -100,3 +220,32 @@ func colorStat(stat int) string { } return color.GreenString("%d", stat) } + +func flagToRange(s string) players.Range { + values := strings.SplitN(s, "-", 2) + minS := strings.ReplaceAll(values[0], ",", "") // to support comma separated prices + min, err := strconv.Atoi(minS) + minOK := err == nil + if !minOK && minS != "" { + return players.Range{} //invalid character + } + max := 0 + maxOK := false + if len(values) > 1 { + maxS := strings.ReplaceAll(values[1], ",", "") + max, err = strconv.Atoi(maxS) + maxOK = err == nil + } + r := players.Range{} + if minOK { + r.Min = min + } + if maxOK { + r.Max = max + } else if !strings.Contains(s, "-") { + r.Max = min + } else if values[1] != "" { + return players.Range{} //invalid character + } + return r +} diff --git a/cmd/players_test.go b/cmd/players_test.go new file mode 100644 index 0000000..709aa5c --- /dev/null +++ b/cmd/players_test.go @@ -0,0 +1,35 @@ +package cmd + +import ( + "reflect" + "testing" + + "github.com/matheusfm/futbin/players" +) + +func TestFlagToRange(t *testing.T) { + tests := []struct { + name string + arg string + want players.Range + }{ + {name: "exactly", arg: "90", want: players.Range{Min: 90, Max: 90}}, + {name: "range", arg: "80-90", want: players.Range{Min: 80, Max: 90}}, + {name: "invalid", arg: "foo", want: players.Range{}}, + {name: "min invalid", arg: "foo-90", want: players.Range{}}, + {name: "max invalid", arg: "90-bar", want: players.Range{}}, + {name: "min", arg: "90-", want: players.Range{Min: 90}}, + {name: "max", arg: "-99", want: players.Range{Max: 99}}, + {name: "long numbers", arg: "1000000-10000000", want: players.Range{Min: 1000000, Max: 10000000}}, + {name: "comma", arg: "10,000-100,000", want: players.Range{Min: 10000, Max: 100000}}, + {name: "comma min", arg: "10,000-", want: players.Range{Min: 10000}}, + {name: "comma max", arg: "-100,000", want: players.Range{Max: 100000}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := flagToRange(tt.arg); !reflect.DeepEqual(got, tt.want) { + t.Errorf("flagToRange() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/cmd/root.go b/cmd/root.go index 058c82c..c8145e4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -27,8 +27,8 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.futbin.yaml)") - rootCmd.PersistentFlags().StringVar(&platform, "platform", "PS", "platform (PS, XB or PC)") + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "Config file (default is $HOME/.futbin.yaml)") + rootCmd.PersistentFlags().StringVar(&platform, "platform", "PS", "Platform (PS, XB or PC)") viper.BindPFlag("platform", rootCmd.PersistentFlags().Lookup("platform")) } diff --git a/players/client.go b/players/client.go index 49f0195..854cb82 100644 --- a/players/client.go +++ b/players/client.go @@ -29,7 +29,8 @@ type client struct { func (c client) Get(opt *Options) ([]Player, error) { u, _ := url.Parse("https://www.futbin.org/futbin/api/getFilteredPlayers") - q, err := query.Values(opt) + pq := newPlayerQuery(opt) + q, err := query.Values(pq) if err != nil { return nil, err } diff --git a/players/options.go b/players/options.go index d0536f9..261749d 100644 --- a/players/options.go +++ b/players/options.go @@ -1,69 +1,63 @@ package players type Options struct { - Platform string `url:"platform,omitempty"` - - Page int `url:"page,omitempty"` - Sort string `url:"sort,omitempty"` - Order string `url:"order,omitempty"` - - Version string `url:"version,omitempty"` - - Position []Position `url:"position,omitempty"` - NationID int `url:"nation,omitempty"` - LeagueID int `url:"league,omitempty"` - ClubID int `url:"club,omitempty"` - WeakFoot int `url:"wf,omitempty"` - MinWeakFoot int `url:"min_wf,omitempty"` - MaxWeakFoot int `url:"max_wf,omitempty"` - Skills int `url:"skills,omitempty"` - MinSkills int `url:"min_skills,omitempty"` - MaxSkills int `url:"max_skills,omitempty"` - Foot Foot `url:"foot,omitempty"` - PsPrice int `url:"ps4price,omitempty"` - XboxPrice int `url:"xb1price,omitempty"` - PcPrice int `url:"pcprice,omitempty"` - Rating string `url:"rating,omitempty"` - Height string `url:"height,omitempty"` - Weight string `url:"weight,omitempty"` - - Pace string `url:"Pace,omitempty"` - Acceleration string `url:"Acceleration,omitempty"` - SprintSpeed string `url:"Sprintspeed,omitempty"` - - Shooting string `url:"Shooting,omitempty"` - Positioning string `url:"Positioning,omitempty"` - Finishing string `url:"Finishing,omitempty"` - ShotPower string `url:"Shotpower,omitempty"` - LongShots string `url:"Longshots,omitempty"` - Volleys string `url:"Volleys,omitempty"` - Penalties string `url:"Penalties,omitempty"` - - Dribbling string `url:"Dribbling,omitempty"` - Agility string `url:"Agility,omitempty"` - Balance string `url:"Balance,omitempty"` - Reactions string `url:"Reactions,omitempty"` - BallControl string `url:"Ballcontrol,omitempty"` - Composure string `url:"Composure,omitempty"` - - Defending string `url:"Defending,omitempty"` - Interceptions string `url:"Interceptions,omitempty"` - HeadingAccuracy string `url:"Headingaccuracy,omitempty"` - Marking string `url:"Marking,omitempty"` - StandingTackle string `url:"Standingtackle,omitempty"` - SlidingTackle string `url:"Slidingtackle,omitempty"` - - Passing string `url:"Passing,omitempty"` - Vision string `url:"Vision,omitempty"` - Crossing string `url:"Crossing,omitempty"` - FreeKickAccuracy string `url:"Freekickaccuracy,omitempty"` - ShortPassing string `url:"Shortpassing,omitempty"` - LongPassing string `url:"Longpassing,omitempty"` - Curve string `url:"Curve,omitempty"` + Platform string + + Page int + Sort string + Order string + + Version string + + Position []Position + NationID int + LeagueID int + ClubID int + Height string + Weight string + WeakFoot Range + Skills Range + Foot Foot + Rating Range + Price Range + + Pace Range + Acceleration Range + SprintSpeed Range + Shooting Range + Positioning Range + Finishing Range + ShotPower Range + LongShots Range + Volleys Range + Penalties Range + Dribbling Range + Agility Range + Balance Range + Reactions Range + BallControl Range + Composure Range + Defending Range + Interceptions Range + HeadingAccuracy Range + Marking Range + StandingTackle Range + SlidingTackle Range + Passing Range + Vision Range + Crossing Range + FreeKickAccuracy Range + ShortPassing Range + LongPassing Range + Curve Range + Physicality Range + Jumping Range + Stamina Range + Strength Range + Aggression Range +} - Physicality string `url:"Physicality,omitempty"` - Jumping string `url:"Jumping,omitempty"` - Stamina string `url:"Stamina,omitempty"` - Strength string `url:"Strength,omitempty"` - Aggression string `url:"Aggression,omitempty"` +type Range struct { + Min int + Max int } diff --git a/players/query.go b/players/query.go new file mode 100644 index 0000000..838e34c --- /dev/null +++ b/players/query.go @@ -0,0 +1,146 @@ +package players + +import "fmt" + +type playerQuery struct { + Platform string `url:"platform,omitempty"` + + Page int `url:"page,omitempty"` + Sort string `url:"sort,omitempty"` + Order string `url:"order,omitempty"` + + Version string `url:"version,omitempty"` + + Position []Position `url:"position,omitempty"` + NationID int `url:"nation,omitempty"` + LeagueID int `url:"league,omitempty"` + ClubID int `url:"club,omitempty"` + WeakFoot int `url:"wf,omitempty"` + MinWeakFoot int `url:"min_wf,omitempty"` + MaxWeakFoot int `url:"max_wf,omitempty"` + Skills int `url:"skills,omitempty"` + MinSkills int `url:"min_skills,omitempty"` + MaxSkills int `url:"max_skills,omitempty"` + Foot Foot `url:"foot,omitempty"` + PsPrice string `url:"ps4price,omitempty"` + XboxPrice string `url:"xb1price,omitempty"` + PcPrice string `url:"pcprice,omitempty"` + Rating string `url:"rating,omitempty"` + Height string `url:"height,omitempty"` + Weight string `url:"weight,omitempty"` + + Pace string `url:"Pace,omitempty"` + Acceleration string `url:"Acceleration,omitempty"` + SprintSpeed string `url:"Sprintspeed,omitempty"` + Shooting string `url:"Shooting,omitempty"` + Positioning string `url:"Positioning,omitempty"` + Finishing string `url:"Finishing,omitempty"` + ShotPower string `url:"Shotpower,omitempty"` + LongShots string `url:"Longshots,omitempty"` + Volleys string `url:"Volleys,omitempty"` + Penalties string `url:"Penalties,omitempty"` + Dribbling string `url:"Dribbling,omitempty"` + Agility string `url:"Agility,omitempty"` + Balance string `url:"Balance,omitempty"` + Reactions string `url:"Reactions,omitempty"` + BallControl string `url:"Ballcontrol,omitempty"` + Composure string `url:"Composure,omitempty"` + Defending string `url:"Defending,omitempty"` + Interceptions string `url:"Interceptions,omitempty"` + HeadingAccuracy string `url:"Headingaccuracy,omitempty"` + Marking string `url:"Marking,omitempty"` + StandingTackle string `url:"Standingtackle,omitempty"` + SlidingTackle string `url:"Slidingtackle,omitempty"` + Passing string `url:"Passing,omitempty"` + Vision string `url:"Vision,omitempty"` + Crossing string `url:"Crossing,omitempty"` + FreeKickAccuracy string `url:"Freekickaccuracy,omitempty"` + ShortPassing string `url:"Shortpassing,omitempty"` + LongPassing string `url:"Longpassing,omitempty"` + Curve string `url:"Curve,omitempty"` + Physicality string `url:"Physicality,omitempty"` + Jumping string `url:"Jumping,omitempty"` + Stamina string `url:"Stamina,omitempty"` + Strength string `url:"Strength,omitempty"` + Aggression string `url:"Aggression,omitempty"` +} + +func newPlayerQuery(opt *Options) *playerQuery { + price := rangeString(opt.Price, "-", 200, 15000000) + pq := &playerQuery{ + Platform: opt.Platform, + Page: opt.Page, + Sort: opt.Sort, + Order: opt.Order, + Version: opt.Version, + Position: opt.Position, + NationID: opt.NationID, + LeagueID: opt.LeagueID, + ClubID: opt.ClubID, + MinWeakFoot: opt.WeakFoot.Min, + MaxWeakFoot: opt.WeakFoot.Max, + MinSkills: opt.Skills.Min, + MaxSkills: opt.Skills.Max, + Foot: opt.Foot, + Rating: rangeString(opt.Rating, "-", 30, 99), + Height: opt.Height, + Weight: opt.Weight, + + Pace: rangeString(opt.Pace, ",", 0, 99), + Acceleration: rangeString(opt.Acceleration, ",", 0, 99), + SprintSpeed: rangeString(opt.SprintSpeed, ",", 0, 99), + Shooting: rangeString(opt.Shooting, ",", 0, 99), + Positioning: rangeString(opt.Positioning, ",", 0, 99), + Finishing: rangeString(opt.Finishing, ",", 0, 99), + ShotPower: rangeString(opt.ShotPower, ",", 0, 99), + LongShots: rangeString(opt.LongShots, ",", 0, 99), + Volleys: rangeString(opt.Volleys, ",", 0, 99), + Penalties: rangeString(opt.Penalties, ",", 0, 99), + Dribbling: rangeString(opt.Dribbling, ",", 0, 99), + Agility: rangeString(opt.Agility, ",", 0, 99), + Balance: rangeString(opt.Balance, ",", 0, 99), + Reactions: rangeString(opt.Reactions, ",", 0, 99), + BallControl: rangeString(opt.BallControl, ",", 0, 99), + Composure: rangeString(opt.Composure, ",", 0, 99), + Defending: rangeString(opt.Defending, ",", 0, 99), + Interceptions: rangeString(opt.Interceptions, ",", 0, 99), + HeadingAccuracy: rangeString(opt.HeadingAccuracy, ",", 0, 99), + Marking: rangeString(opt.Marking, ",", 0, 99), + StandingTackle: rangeString(opt.StandingTackle, ",", 0, 99), + SlidingTackle: rangeString(opt.SlidingTackle, ",", 0, 99), + Passing: rangeString(opt.Passing, ",", 0, 99), + Vision: rangeString(opt.Vision, ",", 0, 99), + Crossing: rangeString(opt.Crossing, ",", 0, 99), + FreeKickAccuracy: rangeString(opt.FreeKickAccuracy, ",", 0, 99), + ShortPassing: rangeString(opt.ShortPassing, ",", 0, 99), + LongPassing: rangeString(opt.LongPassing, ",", 0, 99), + Curve: rangeString(opt.Curve, ",", 0, 99), + Physicality: rangeString(opt.Physicality, ",", 0, 99), + Jumping: rangeString(opt.Jumping, ",", 0, 99), + Stamina: rangeString(opt.Stamina, ",", 0, 99), + Strength: rangeString(opt.Strength, ",", 0, 99), + Aggression: rangeString(opt.Aggression, ",", 0, 99), + } + switch opt.Platform { + case "XB": + pq.XboxPrice = price + case "PC": + pq.PcPrice = price + default: + pq.PsPrice = price + } + return pq +} + +func rangeString(r Range, sep string, minLimit int, maxLimit int) string { + if r.Min == 0 && r.Max == 0 { + return "" + } + if r.Min < minLimit { + r.Min = minLimit + } + if r.Max > maxLimit { + r.Max = maxLimit + } + return fmt.Sprintf("%d%s%d", r.Min, sep, r.Max) +}