Rule Check - Highscore Tables

Ok, tentatively, this will be added as support in the current contest, if there are no objections.

As long as there are no problems, I’ll make available a jar (both for development/mocking and production), hopefully tomorrow, although I’ll need to test it first.

At least you can make the assumption for your game(s) that this will be supported.

Will the table be displayed on the game page as HTML, or will we be getting the current table back from the API and expected to render it using game logic?

Also, a suggestion: could the jar have several methods that could do the same thing with different names? So even though the actual method is something like sendToHighScoreTable(String, int), there are aliases like drawString(String, int, int) that just call the real thing, but allow people to pick whichever one will compress best for their game.

The single public static method I’m thinking of having in the API goes something like this:

public static String postScore(String playerName, int score);

Returned value: The resulted highscore table in a csv string, e.g. “name1,score1;name2,score2;…;nameN,scoreN”. I thought about returning a List or something like that, but won’t it add to size of the game jar?

That way the developer can choose if he wishes to display the highscore in his game, so player won’t have to reload the web page to see his position. But this is optional, although offered. And yes, it will be displayed on the page for the games that have enabled highscore feature.

The API identifies the game by using a parameter in the applet tag.

Developer can define the order of the highscore list for his game when he submits the game (or edits it). I can be ordered by score either descending or ascending (lower or higher is better). Number of results on highscore might be either 10 or 20, rest is omitted.

Just what I’m thinking.

I had the idea of creating a high score lib to take just the score in a constructor, then applet/image/graphics and returning a boolean for done in an update function. The lib would then take care of getting the user name and displaying the list, so that the impact of adding highscore would be minimal. But if active rendering is not working then it might be problematic, didn’t quite follow what the problem was there.

The code change to use highscore would be to create the highscore object and call it each loop until it returns true. Not sure how to handle username input in a 100% reliable way across platforms nowadays especially that works for most types of games, but I am sure that can be handled collectively if it need be. I have to sync with appel tomorrow so that we head in the same direction.

Then again having just a function that takes just name and score is very simple, so that is elegant, but more bytes will be used to gather user name from inside the game, and more effort will have to be made in order to use this feature, so less games will probably use it.

By the way left 4k dead doesn’t work on OS X and FF, but fine on Safari and Chrome for me. That could be some specific problem with FF on my machine, since many applets don’t work there.

In terms of username input, for logged in users you could add a param tag to the applet and then read that in the library.

Such a long method name :slight_smile:
precious bits being wasted in an environment where one letter methods are common :slight_smile:

Really like the idea of using the site login for the username. Would encourage people outside of the 4k community who play to register.

Kev

Yes, that is exactly what I am doing at games4j.com, but the drawback is that you have to be logged in before starting the game. The encouragement to get into the highscore list is not enough for people to go through a registration process in most cases. I plan to add authentication via facebook gmail and the rest to get rid of the whole registration prcess on games4j to see if that works better. We could possibly test that on java4k as well. You also get rid of all the obscenities that are bound to pop up if anyone can type in anything for name, and the whole clientside lib is ready. I could just take the games4j lib and refactor the calls to one letter names. Serverside stuff still remains.

Problem with that is, they have to be logged in before playing the game.

I think “Type your player name to submit highscore” is the best way.

There will be some penalty in terms of bytes in doing highscore, but I don’t think it will be enormous.

In that case can we do as described above and have the library pop up a joptionpane instead - can customise the look and feel to fit the site and add all that good stuff (geolocation etc), maybe even add the top 10/5 scores to it.

Kev

Ok, it’s ready and working.

I’m gonna have jojoh peer-review it with me tomorrow before I release it in the open, hard to change afterwards, so better get it right the first time. Then tomorrow night I’ll put up the option in the game edit/submit where you can enable this feature, and I’ll also publish the jar.

The method is:

public static String[][] p(Applet caller, String name, int score) 

returned is a two dimensional array, list of results, where each row is: 0 = playername, 1 = score
or it returns null on any exception.

The invocation would go something like:


String[][] results = HScore.p(this, "appel", 999);
if(results != null) { ... show results.. } else { ...oops!... }

The reason for applet reference is to retrieve an applet property.

Mocking this will be mostly up to you.

Hmmmm… need to think about this, but getting too late here now.

Have a method in the highscore.jar that calls out to JavaScript with the score. JS would display an animated GIF for a few seconds to get the user’s attention and show a submit button. If the user is not logged in it would allow them to specify their name, which could be remembered with a cookie. It would also allow them to specify a password, so we can both accept their high score submission and create a new account in one go. Unregistered users could be annotated in the high score list to differentiate them from real users. Finally, the JS would submit the score via AJAX and refresh the high score table, all without the user leaving the page.

Oh, that’s nice. I’ll look into that.

Yup, that suggestion sounds like it combines the best of all ideas.

I’ve decided to expand a bit on the idea, so it won’t be ready until by tomorrow or saturday. ty.

Yaaay! What do I win? :smiley:

At my work, if you come up with a good idea… it means that you get to implement it :wink:

Booo, way to stifle innovation! :slight_smile:

How’s it coming?