Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match data is parsed poorly #6

Open
ErikBoesen opened this issue Nov 18, 2017 · 0 comments
Open

Match data is parsed poorly #6

ErikBoesen opened this issue Nov 18, 2017 · 0 comments
Labels

Comments

@ErikBoesen
Copy link
Member

ErikBoesen commented Nov 18, 2017

Match data is quite complicated, and handling it through a statically typed language like Go can be troublesome.

The score_breakdown JSON property is particularly problematic here. A typical match request might yield the following JSON:

"score_breakdown": {
    "blue": {
      "adjustPoints": 0, 
      "autoFuelHigh": 0, 
      "autoFuelLow": 0, 
      "autoFuelPoints": 0, 
      "autoMobilityPoints": 15, 
      "autoPoints": 15, 
      "autoRotorPoints": 0, 
      "foulCount": 0, 
      "foulPoints": 0, 
      "kPaBonusPoints": 0, 
      "kPaRankingPointAchieved": false, 
      "robot1Auto": "Mobility", 
      "robot2Auto": "Mobility", 
      "robot3Auto": "Mobility", 
      "rotor1Auto": false, 
      "rotor1Engaged": true, 
      "rotor2Auto": false, 
      "rotor2Engaged": true, 
      "rotor3Engaged": false, 
      "rotor4Engaged": false, 
      "rotorBonusPoints": 0, 
      "rotorRankingPointAchieved": false, 
      "tba_rpEarned": 0, 
      "techFoulCount": 0, 
      "teleopFuelHigh": 8, 
      "teleopFuelLow": 0, 
      "teleopFuelPoints": 2, 
      "teleopPoints": 82, 
      "teleopRotorPoints": 80, 
      "teleopTakeoffPoints": 0, 
      "totalPoints": 97, 
      "touchpadFar": "None", 
      "touchpadMiddle": "None", 
      "touchpadNear": "None"
    }, 
    "red": {
        "same properties as blue"
    }
}

The issue is that the properties of blue and red are different across games.

The only solution I can currently see to this is to write every possible property into the Match struct.

Currently we use this horrible placeholder.

        ScoreBreakdown struct {
		Red  interface{} `json:"red"`
		Blue interface{} `json:"blue"`
	} `json:"score_breakdown"`

We should not stay with this terrible solution.

@ErikBoesen ErikBoesen added the bug label Nov 18, 2017
ErikBoesen added a commit that referenced this issue Jan 6, 2018
I've written specific JSON marshalling code so users will no longer have
to deal with interfaces to get specific match breakdown data.

Fixes #6
@ErikBoesen ErikBoesen reopened this Jan 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant