Showing posts with label fantasy. Show all posts
Showing posts with label fantasy. Show all posts

Sunday, November 04, 2007

2007 Fantasy basketball script released

*update - 2/22/2008 - updated the script to handle new yahoo boxscores for in progress games

I couldn't sleep last night (Friday night...actually Sat at 2am to be exact) so I stayed up and implemented the two missing features for the live stats basketball script: maintaining the order of players in the modal window and displaying a summary of all active players' stats.

The first feature was easy to implement since I had already solved that problem for baseball. The old technique of adding a row after retrieving a player's stats leads to indeterminate ordering because we do not wait for a boxscore request to finish before moving on to the next. Therefore, it was possible that a UTIL player who is towards the bottom of the management page would actually be processed faster than a PG depending on how snappy the server handled the request. The solution is to create placeholder rows that have the correct order and then update those rows later.

The second feature is summarizing all your players' stats for the night. Unlike a baseball boxscore where a player's stats appear on multiple parts of the page and some stats need to be derived, all basketball stats appear on one row. That's why I didn't create full blown function objects that had getter/setters for stats like assists, turnovers, pts, boards, etc. Instead, I went the lightweight route and defined two rules that are used to summarize stats. If the stat has a dash, like 7-11, then we keep track of total made and total attempts, else we just sum up the current stat with the running total.

Wednesday, October 31, 2007

halloween treat

No candy to pass out but I did make a few tweaks to my fantasy basketball live scoring script. Like the modified baseball version, the script no longer automatically loads. The user has to trigger it by clicking on the 'show freebie stats' link. I also ripped out the autocenter on scroll code since that was causing display issues for users on low resolution monitors.

The two biggest missing features that I will tackle next are maintaining the order on the display and totaling all your active players' stats. But I probably won't get to that until the weekend. don't fret, yahoo provides free stats for the first couple of weeks of the season so you're covered.

Thursday, April 12, 2007

2007 yahoo fantasy baseball script

update 4/24/2007
Script updated. Fixed issues 3 and 6 reported by Rodric Rabbah and lots of code refactoring. The script no longer automatically loads the window. You have to activate it by pressing on the blue "Show Freebie Stats" button on the top right.

update 4/18/2007
Script updated. Fixed issues 4 and 5 reported by Ethan Herbertson.

update 4/16/2007 To use the script, follow these 3 steps

  1. download firefox
  2. install greasemonkey extension
  3. after installing greasemonkey, install the script

I just updated my fantasy baseball script for 2007. The most obvious change is that I incorporated the UI from my fantasy basketball script but there are also a bunch of under-the-hood fixes too. I go into some detail in those two blog postings on how the scripts are implemented so I won't recap any of that here but I will describe one bug fix. Stolen bases and homers are not part of the boxscore and they require extra parsing.

The stolen base string is of the form: D. Roberts 2 (2nd Inning off J. Bard), B. Bonds (3rd inning off J. Bard)

My old regular expression was a simple check to see if a players name was part of the string. The problem was that if I had J. Bard on my team, then he got a stolen base even though he was the one that allowed the steal. To fix the problem, I deleted everything in parentheses first.

That regular expression looks like: statLine = statLine.replace(/\([^\)].+?\)/gi,''); The key is '?' which makes it a non greedy match and [^\)] which tells the engine when to stop.

Another thing that bothered me was calling mozilla's childNodes method on a table row returned some unexpected results. Instead of returning a list of td elements, it would also return some additional children. To remedy this annoyance, I call row.getElementsByTagName("TD") and then I get a list of td elements that I expect. That said, I'm much happier with Mozilla's handling of the dom api and the development plugins available in FireFox. My day job is as web developer for a high traffic site where we strive for pixel, perfect perfection between IE 6,7 and firefox so developing for just one browser was a nice break.

Install the script.