Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

java library for mogade.com

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 src
Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 build.xml
Octocat-spinner-32 license.txt
Octocat-spinner-32 mogade-java.xml
Octocat-spinner-32 readme.textile
readme.textile

Mogade For Java

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.

Other Libraries

For a list of other libraries, please visit http://mogade.com/manage/libraries

Support

The http://groups.google.com/group/mogadedev google group is the best place for developers, either of games or libraries, to visit.

Usage

I have also tried to put these in order of typical session usage as well.

Mogade Creation

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);

GetConfigVersion / GetConfig

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);
}

GetUserGameData

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
}

SaveScore

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
}

SaveAchievement

//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

GetLeaderboard

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()
}

More Usage Samples

View the tests!

API Overview

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

Something went wrong with that request. Please try again.