These are chat archives for Ian-Stewart-Binks/Foosball

10th
Mar 2016
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 18:52
/all Should we be able to merge our own PRs for small things?
/all development seems to be hanging
Anirudh Mukundan
@Anirudh94
Mar 10 2016 18:53
its up to you, my team prefers everything be reviewed and imo it might save time in the long run
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 18:59
/all We don't seem to have any structure in the JSON.
var data = {
  people: [
    {name: 'Matt', country: 'NZ'},
    {name: 'Pete', country: 'AU'},
    {name: 'Mikey', country: 'NZ'}
  ]
}
This is how it should look
well
without the var data =
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:02
Not sure I get your point
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:03
In JavaScript, write a function that gets the name of each rule from the given JSON notation that @emmettu provided.
@Anirudh94 You can't really.
For instance, we create an object with the field "Beers".
As such, we would do something like obj["Beers"] to get the value of "Beers"
But we can't determine that we need "Beers" ahead of time.
so its obj[???]
@Anirudh94 Do you agree?
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:07
you can't?
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:08
@Anirudh94 I'll give you a challenge to understand this.
Are you ready?
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:08
wouldn't for (var key in rules) loop through the rules?
@Ian-Stewart-Binks sure lol
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:09
Write me a JavaScript script that queries the JSON, then loops through the rules, and prints each rule's name, then prints its contents. Each item in the rule's contents should be indented 4 spaces.
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:19
@Ian-Stewart-Binks according to emmets JSON notation theres only one item per rule right?
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:19
@Anirudh94 What do you mean?
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:20
oops nvm
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:28
var rules = require('./rules.json');

for (var i in rules) {
  console.log(i);
  for (var j of rules[i]) {
    console.log("    " + j);
  }
}
@Ian-Stewart-Binks ^
wouldn't that work?
also (in node anyways) the requiring a json file automatically does the JSON.parse() for I think
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:31
First of all, scrape.py doesn't actually work.
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:31
LOL
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:31
"": ["(if tied) one point sudden death."]
Second, let's try.
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:33
@emmettu ^^
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:35
@Anirudh94 That does work. Can it be better? Are we actually using JSON the way it was intended to be used?
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:35
@Ian-Stewart-Binks thats actually been bugging me for a while too
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:35
If we created a database schema
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:35
need to do some research into that, I'm not sure manually writing rules into a JSON file is a very good idea either
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:36
@Anirudh94 what would you suggest instead?
And, if we created a database schema, we wouldn't have the names of rules as the schema
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:36
@Ian-Stewart-Binks I'm not sure, hence we need to do some research
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:36
It's nicer to go rule.description and rule.contents than for var j of json for var i of json[j]
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:37
yeah I was thinking the same :)
one sec
Schema like this?
{
  "name": "string",
  "contents": ["rules"]
}
^edited
or contents could be description
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:39
Something like that.
Yes.
Each object itself would be contained in an array
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:43
what do u mean?
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:43
[{
  "name": "string",
  "contents": ["rules"]
},
{
  "name": "string",
  "contents": ["rules"]
},
{
  "name": "string",
  "contents": ["rules"]
}
]
Anirudh Mukundan
@Anirudh94
Mar 10 2016 19:44
oh yep thats what i want
so schema per rule and 'rules' is just an array
of rule objects
one problem to note is ensuring an order
being a website we may want certains rules towards the top dunno
well its not a problem so much as something to keep in mind
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 19:45
The schema can change
Emmett Underhill
@emmettu
Mar 10 2016 20:21
I could adjust the the schema to parse as such
also I'd like to give myself at least some recognition in saying that scrape.py does work. However the html does not have a consistent format
so if we want the rules to be perfect then in my opinion we should just do it by hand
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 20:35
@emmettu It was a good attempt.
Anirudh Mukundan
@Anirudh94
Mar 10 2016 20:36
@emmettu np yo, the html wasnt consistent
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 20:36
And if you think we should just do it by hand, then you should note that at an earlier point. Also, if the scraper doesn't do a good job, you should note that in the PR description.
In the future, I'll make sure to run the code and check the output.
Emmett Underhill
@emmettu
Mar 10 2016 20:38
I did check the output
nevermind I misread
You're right it should have been noted in the PR description. Also the dialogue from the very beginning of this feature was that it might not be practical
Ian Stewart-Binks
@Ian-Stewart-Binks
Mar 10 2016 21:43
I vote that we do not fall back on the rules of foosball.com
And that we port over rules that we like, incrementally.
The current system of falling back on 'official' foosball rules is flawed.
/all thoughts?
Anirudh Mukundan
@Anirudh94
Mar 10 2016 22:38
+1