Mogade is a free web-based service which allows game developers to quickly enchance their games with auxiliary functionality (such as leaderboards).
This is the official Java library – which is meant not only to be used within games, but also to serve as the basis for platform specific implementations. Developers interested in building a library for their own language will hopefully find this library to be decent documentation of the mogade API.
For a list of other libraries, please visit http://mogade.com/manage/libraries
The http://groups.google.com/group/mogadedev google group is the best place for developers, either of games or libraries, to visit.
I have also tried to put these in order of typical session usage as well.
String leaderboardId = "1cc425bf5346ed081f0000ef"; //leaderboards are created and assigned an id by mogade.com String gameKey = "1cc3cb835346ed081f0000ee"; //the game key and secret are provided by mogade.com String secret = "aT4][A;28q]V?!!"; Mogade mogade = MogadeImpl.create(gameKey, secret);
int savedConfigVersion = PersistentLocalDatastore.getConfigVersion();
GetConfigVersionResponse response = mogade.getConfigVersion();
if (!response.isOk())
{
//do something with response.getStatus();
return;
}
if (savedConfigVersion != response.getVersion())
{
GetConfigResponse response = mogade.getConfig();
PersistentLocalDatastore.saveConfig(response);
}
String username = PersistentLocalDatastore.getUsername();
String unique = DeviceAPI.getDeviceSerialNumberOrSomethingUniqueAboutThisDeviceOrComputer();
GetUserGameDataResponse response = mogade.getUserGameData(username, unique);
if (!response.isOk())
{
//do something with response.getStatus();
return;
}
for(String earnedAchievementId : response.getAchievements())
{
//get achievement from config data by earnedAchievementId
//show user they have earned that achievement
}
SaveScoreResponse response = mogade.saveScore(leaderboardId, new Score("brian", 2000));
if (!response.isOk())
{
//do something with response.getStatus();
return;
}
//sometimes the ranks won't be defined, depending on the current server load
if (response.getDaily() > 0)
{
//do something with daily rank
}
if (response.getWeekly() > 0)
{
//do something with weekly rank
}
if (response.getOverall() > 0)
{
//do something with overall rank
}
//Maybe check the saved UserGameData and see if they have already earned this achievement and don't save again??
//Depends on game specifics.
String achievementId = "8cc425bf5346ed081f0000e1";
String username = PersistentLocalDatastore.getUsername();
String unique = DeviceAPI.getDeviceSerialNumberOrSomethingUniqueAboutThisDeviceOrComputer();
SaveAchievementResponse response = mogade.saveAchievement(achievementId, username, unique);
if (!response.isOk())
{
//do something with response.getStatus();
return;
}
long pointsAwarded = response.getPoints(); //do something with this
int page = 1;
GetLeaderboardResponse response = mogade.getLeaderboard(Leaderboard.create(leaderboardId, page, Leaderboard.Scope.DAILY));
if (!response.isOk())
{
//do something with response.getStatus();
return;
}
for(Score score : response.getScores())
{
//do something with score
//score.getUsername(), score.getPoints(), score.getData()
}
View the tests!
Mogade is based around a RESTish API, accepting and returning JSON messages.
A full API overview can be read here http://mogade.com/manage/api