Introduction
Welcome to Pocket Arena SDK documentation.
How to use
1 Insert script in the head tag of your game.
<head>
<script src="jquery-2.1.1.min.js"></script> <!-- jquery required-->
<script type="text/javascript" src="EmojiGamesPASDK.min.js"></script>
</head>
2 Create a new instance of SDK
var pasdk = new EmojiGamesPASDK({
gameId : 'xxxxxx' //game id
});
3 After below
onComplete
function is triggered, you can just call any API.
pasdk.ISREADY(function(){
//onComplete
console.log('sdk is ready. Now SDK API is available.')
}, function(err){
//onError
console.log(err, 'error occurred during initializing.')
});
- Insert script in the head tag of your game.
- Create a new instance of SDK
- After
onComplete
function ofISREADY
is triggered, you can just call any SDK API.
Implementation Example link ( Game Engine : Constructor 2 )
https://pa.emojigames.io/ext_SmashNGrab/
SDK API tool link
https://pa-dev1.emojigames.io/spike/api-tool/
Common API
new EmojigaGamesPASDK
new EmojigaGamesPASDK( options )
var options = {
gameId : 'xxxxx',
wrapperId : 'myGameCanvas',
useLeaderboard : false
}
var sdk = new EmojiGamesPASDK(options)
new EmojigaGamesPASDK( options )
Create a PA SDK instance.
Arguments
Argument | Type | Default | Description |
---|---|---|---|
options | Object | - | API call is success |
options
argument
Type | Key | Default | Description |
---|---|---|---|
String | gameId * | - | Game ID. You can get this id when you register your game. |
String | wrapperId | c2canvasdiv | Game canvas tag ID. |
Boolean | useLeaderboard | false | This option works only for the game that leaderboard is set to use. You can set leaderboard when you register your game.true Use leaderboard.false Not use. |
Return
Type | Description |
---|---|
EmojiGamesPASDK | SDK instance |
ISREADY
ISREADY( onComplete, onError )
pasdk.ISREADY(function() {
//onComplete arg
}, function(err){
//error arg
console.log('error object', err)
})
ISREADY(onComplete, onError)
SDK is ready to use. All functions of PA SDK should be called after this API is triggered.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
GETLEADERBOARDTYPE
GETLEADERBOARDTYPE()
var res = pasdk.GETLEADERBOARDTYPE()
console.log('res', res) // 'res win'
GETLEADERBOARDTYPE()
Get leaderboard type.
Return value
Type | Value | Description |
---|---|---|
String | win |
Rank is based on number of win |
score |
Rank is based on stage clear score or stage number. |
SIGNIN
SIGNIN( type, params, onComplete, onError )
pasdk.SIGNIN('email', {email : 'me@emojigames.io', password : '#12345678'},
function(player, poc){
//onComplete
//console.log('player', player) //see PLAYER.GETINFO
console.log('poc', poc) //'poc null' | 'poc 28342'
}, function(err){
//onError
console.log('err', err)
})
sns
type
pasdk.SIGNIN('sns', {snsName : 'facebook'},
function(player, poc){
//onComplete
//console.log('player', player) //see PLAYER.GETINFO
console.log('poc', poc) //'poc null' | 'poc 28342'
}, function(err){
//onError
console.log('err', err)
})
SIGNIN( type, params, onComplete, onError )
User sign in. You can either make your own UI or use UI.SIGNIN API.
type
argument
Sign in type
Type | Value | Description |
---|---|---|
String | email |
For email sign in |
sns |
For SNS account sign in (Google, Facebook) |
params
argument
Parameters to send to server. Key varies depending on the type
argument.
For email
type
Type | Key | Description |
---|---|---|
String | Email address | |
String | password | Password. Up to 8 characters |
For sns
type
Type | Key | Value | Description |
---|---|---|---|
String | snsName | facebook |
|
google |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. It returns below arguments. |
Type | Argument | Description |
---|---|---|
Object | player | Player data. See PLAYER.GETINFO |
Number/null | poc | POC balance |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
SIGNUP
SIGNUP( type, params, onComplete, onError )
pasdk.SIGNUP('email', {email : 'me@emojigames.io', password : '12341234', nickname: 'My Nickname'},
function(player, poc){
//onComplete
//console.log('player', player) //see PLAYER.GETINFO
console.log('poc', poc) //'poc null' | 'poc 28342'
}, function(err){
//onError
console.log('err', err)
})
sns
type
pasdk.SIGNUP('sns', {snsName : 'facebook'},
function(player, poc){
//onComplete
//console.log('player', player) //see PLAYER.GETINFO
console.log('poc', poc) //'poc null' | 'poc 28342'
}, function(err){
//onError
console.log('err', err)
})
SIGNUP(type, params, onComplete, onError)
User sign up. You can either make your own UI or use UI.SIGNUP API.
type
argument
Sign up type
Type | Value | Description |
---|---|---|
String | email |
For email sign in |
sns |
For SNS account sign in (Google, Facebook) |
params
argument
Parameters to send to server. Key varies depending on the type
argument.
For email
type
Type | Key | Description |
---|---|---|
String | Email address | |
String | password | Password. Up to 8 characters |
String | nickname | Player's nickname |
For sns
type
Type | Key | Value | Description |
---|---|---|---|
String | snsName | facebook |
|
google |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
Type | Argument | Description |
---|---|---|
Object | player | Player data. See PLAYER.GETINFO |
Number | poc | POC balance |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
RESETPASSWORD
RESETPASSWORD( email, onComplete, onError )
pasdk.RESETPASSWORD ( 'me@emojigames.io',
function(){
//onComplete
console.log('Verification email has been sent.');
}, function(err){
//onError
console.log('err', err)
})
RESETPASSWORD( email, onComplete, onError )
Send an email to reset password.
email
argument
Type | Description |
---|---|
String | User's email address |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
POCPURCHASE
POCPURCHASE( gameShopNo, onComplete, onError )
pasdk.POCPURCHASE(2,
function(){
//onComplete
}, function(err){
//onError
console.log(err)
});
POCPURCHASE( gameShopNo, onComplete, onError )
Request exchange POC for items or game currency such as Ruby. The item can be various depending on game.
gameShopNo
argument
Type | Description |
---|---|
Number | The shopNo value received from GETSHOPINFO |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
GETSHOPINFO
GETSHOPINFO( onComplete, onError )
pasdk.GETSHOPINFO(function(returncode, poc, gameshop){
//onComplete
console.log('success', returncode, poc, gameshop); //success 200, 4, see below about gameshop array
}, function(err){
//onError
console.log(err)
});
gameshop
object list
[{
"shopno":"2",
"title":"item 1",
"itemimage":"https://ipascf.pocketarena.com/pa/ruby01.png",
"itemamount":"1000",
"pocamount":"10"
},{
"shopno":"3",
"title":"item 2",
"itemimage":"https://ipascf.pocketarena.com/pa/ruby02.png",
"itemamount":"5500",
"pocamount":"50"
}]
GETSHOPINFO( onComplete, onError )
Get info that exchanges POC for items or game currency such as Ruby. The item can be various depending on game.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Number | returncode | 200 : User verified. 401 : User needs to verify the account |
Number | poc | User's POC balance |
Array | gameshop | gameshop list. See below |
gameshop
object
Type | Key | Description |
---|---|---|
String | shopno | Shop unique id |
String | title | Shop name |
String | itemimage | Shop iamge |
String | itemamount | Amount to buy |
String | pocamount | Required POC to buy |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
GETREWARDEXP
GETREWARDEXP( onComplete, onError )
pasdk.GETREWARDEXP(function(exp, poc){
//onComplete
console.log(exp, poc) //87 18
}, function(err){
//onEror
console.log('err', err)
});
GETREWARDEXP(onComplete, onError)
Get user’s POC reward exp and amount to get when the exp reaches 100.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Number | exp | User's level experiece. in percent |
Number | poc | Amount of POC that user will gain when current exp reaches next level. (ex : x18). /n Returns null , If user has not done verification. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
OPENLINK
OPENLINK( siteName, pageName )
wallet
//redirect to PA Wallet website
pasdk.OPENLINK('wallet')
pocketarena
//redirect to Emojigames website
pasdk.OPENLINK('pocketarena');
//redirect to Emojigames website's eSports result history page
pasdk.OPENLINK('pocketarena', 'esportsHistory');
//redirect to Emojigames website's eSports leaderboard page
pasdk.OPENLINK('pocketarena', 'esportsLeaderboard');
OPENLINK(siteName, pageName)
Open PA Wallet or Pocket Arena website page.
siteName
argument
Type | Value | Description |
---|---|---|
String | wallet |
Redirect to PA Wallet website in new tab. |
pocketarena |
Redirect to Pocket Arena website in new tab. |
pageName
argument for pocketarena
Type | Value | Description |
---|---|---|
String | esportsHistory |
Redirect to eSports result history page of Pocket Arena website in new tab. |
esportsLeaderboard |
Redirect to eSports leaderboard page of Pocket Arena website in new tab. |
Account API
PLAYER.GETINFO
PLAYER.GETINFO()
pasdk.PLAYER.GETINFO() //see below
player
object : for player signed in
{
"country":"Switzerland",
"countryCode":"CH",
"email":"me@emojigames.io",
"idType":"email",
"image":"https://pacoin.pocketarena.com/upload/player/image/NrPtCkznLubJ.jpg",
"isVerified":true,
"level":5,
"nickname":"Spike Kang",
"rewardExp":{
"POC":18,
"exp":87
}
}
player
object : for player who is not signed in
{
"rewardExp" : 87,
"isAnonymous": true
}
PLAYER.GETINFO()
Get player’s information such as email, name, and so on. isAnonymous
is returned only for player who is not signed in.
Return value
Type | Description |
---|---|
Object | if player is not signed in. isAnonymous is returned for non-signed player only. |
player
object : for player signed in
Type | Key | Key | Description |
---|---|---|---|
String | country | Player country | |
String | countryCode | Player country code | |
String | Player email | ||
String | idType | Determine if it's SNS account or email accountemail or sns |
|
String | image | Player profile image | |
Boolean | isVerified | true if player finished email verification |
|
String | languageCode | Player language code | |
Number | level | Player level | |
String | nickname | Player nickname | |
Object | rewardExp | Player's POC and level exp info | |
Number | POC | POC amount that player will get when his/her level is up. | |
Number | exp | Player's level exp in percent, max 99. |
player
object : for player who is not signed in
Type | Key | Description |
---|---|---|
Number | rewardExp | Player's level exp info, in percent, max 99. |
Boolean | isAnonymous | true always, since this key is for non-signed player |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.SETINFO
PLAYER.SETINFO( nickname, countryCode, languageCode, currentPassword, newPassword, onComplete, onError )
pasdk.PLAYER.SETINFO('Brandon Jeong', 'KR', 'KR', '12341234', '12341234',
function(){
//onComplete
console.log('success');
}, function (err) {
//onError
console.log('err', err);
});
PLAYER.SETINFO(nickname, countryCode, languageCode, currentPassword, newPassword, onComplete, onError)
Set player’s information such as email, name, birthday, and gender.
nickname
argument
Type | Description |
---|---|
String / Null | null if player is not signed in. |
countryCode
argument
Type | Description |
---|---|
String* | Required. Player's country code |
languageCode
argument
Type | Description |
---|---|
String* | Required. Player's language code. Supported languages EN , DE , and KR |
currentPassword
argument
Type | Description |
---|---|
String | Player's current password. At least 8, and up to 50 characters |
newPassword
argument
Type | Description |
---|---|
String | New password that player set to change. At least 8, and up to 50 characters |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.GETACTIVITY
PLAYER.GETACTIVITY( onComplete, onError )
pasdk.PLAYER.GETACTIVITY(function(activity){
//onComplete
console.log('res', activity) //see below 'activity' object
}, function(err) {
//onError
console.log(err)
});
activity
object
{
"draw":7,
"highscore":36,
"lastAccess":"2018-10-17T02:50:08-07:00",
"lose":8,
"win":39
}
PLAYER.GETACTIVITY(onComplete, onError)
Get player’s PA activity statistic such as number of wins, loses, and last access time.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.GETMYPOC
PLAYER.GETMYPOC( onComplete, onError )
pasdk.PLAYER.GETMYPOC(function(balance){
//onComplete
console.log('res', balance) //4
}, function(err) {
//onError
console.log(err)
});
PLAYER.GETMYPOC(onComplete, onError)
Get current POC balance
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Number / null | balance | POC balance player currently has. Returns null , if player has not done verification. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.COUNTNEWMESSAGES
PLAYER.COUNTNEWMESSAGES( onComplete, onError )
pasdk.PLAYER.COUNTNEWMESSAGES(function(amount){
//onComplete
console.log('res', amount); //4
}, function(err) {
//onError
console.log(err);
});
PLAYER.COUNTNEWMESSAGES(onComplete, onError)
Check if user has new messages or not. It returns amount of new(unread) messages.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Number | amount | Total number of new/unread messages. 0, if none. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.GETMESSAGE
PLAYER.GETMESSAGE( limit, page, onComplete, onError )`
pasdk.PLAYER.GETMESSAGE(null, null, function(list, hasNext){
//onComplete
console.log('success', list, hasNext); // success (see below for list), true
}, function (err) {
//onError
console.log('err', err);
});
notification
object
{
"notificationno":"1",
"notificationtype":"1",
"title":"Notice Title",
"description":"Notice Description",
"pocamount":null,
"isread":false,
"registdate":1523976927
}
messages
object
{
"messageboxno":"1",
"messageboxtype":"1",
"winnertype":"2",
"title":"Message Title",
"description":"Message Description",
"isread":false,
"registdate":1523976927
}
prizes
object
{
"prizeno":"1",
"prizetype":"1",
"title":"Prize Title",
"description":"Prize Description",
"isread":false,
"registdate":1523976927,
"expiredate":1523976927
}
PLAYER.GETMESSAGE( limit, page, onComplete, onError )
Get player's messages
limit
argument
Type | Description |
---|---|
Number / null | Amount of messages to display in a page. default 10 |
page
argument
Type | Description |
---|---|
Number / null | Page number to load. default 1 |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Object | list | List of messages. See list object below. |
Boolean | hasNext | true there are more pages. false there is no more pages. |
list
object
Type | Key | Description |
---|---|---|
Array | notices | List of notice object |
Array | messages | List of message object |
Array | prizes | List of prize object |
notification
object
Type | Key | Description |
---|---|---|
String | notificationno | Notification number. Unique. |
String | notificationtype | Notification type. 1 : system notice, 2 : reward via eSports |
String | title | Title |
String | description | Description |
String\Null | pocamount | POC amount |
Boolean | isread | Status whether the message is read or not. true if it's read, otherwise false |
Timestamp | registdate | Registered date |
messages
object
Type | Key | Description |
---|---|---|
String | messageboxno | Message number. Unique. |
String | messageboxtype | Message type. 1 : system notice, 2 : reward via eSports |
String | winnertype | Winner type. 1 : Team winner, 2 : Final winner eSportsThis is for eSports games. |
String | title | Title |
String | description | Description |
Boolean | isread | Status whether the message is read or not. true if it's read, otherwise false |
Timestamp | registdate | Registered date |
prizes
object
Type | Key | Description |
---|---|---|
String | prizeno | Prize number. Unique. |
String | prizetype | Prize type. 1 : system notice, 2 : reward via eSports |
String | title | Title |
String | description | Description |
Boolean | isread | Status whether the message is read or not. true if it's read, otherwise false |
Timestamp | registdate | Registered date |
Timestamp | expiredate | Expire date |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.UPDATEMESSAGE
PLAYER.UPDATEMESSAGE( action, mode, messageNo, options, onComplete, onError )
pasdk.PLAYER.UPDATEMESSAGE('read', 'msg', 1, {}, function(){
//onComplete
console.log('success');
}, function(err) {
//onError
console.log(err);
});
PLAYER.UPDATEMESSAGE( action, mode, messageNo, options, onComplete, onError )
Check if user has new messages or not. It returns amount of new(unread) messages.
action
argument
Type | Description |
---|---|
String | read to set a message as read. delete to delete a message. |
mode
argument
Type | Description |
---|---|
String | noti for notification msg for message prize for prize |
messageNo
argument
Type | Description |
---|---|
Number | Notification, message, or prize unique number. |
options
argument
Type | Description |
---|---|
Object | Not used yet. |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.GETITEM
PLAYER.GETITEM( onComplete, onError )
pasdk.PLAYER.GETITEM(function(list){
//onComplete
console.log('success', list); //see below
}, function (err) {
//onError
console.log('err', err);
});
item
object
{
"useritemno":"928",
"title":"Iron Ball",
"subtitle":"Destroy all kind of bircks",
"itemimage":"https://ipascf.pocketarena.com/pa/iron-ball.png",
"price":"100",
"itemtype":"2",
"itemstatus":"1",
"itemlevel":"1",
"itemexp":"0",
"marketyn":"1",
"productid":"bfLGiKLxJdwjwQ"
}
PLAYER.GETITEM(onComplete, onError)
Get player’s item list
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Array | list | List of item object. See below |
item
object
Type | Key | Description |
---|---|---|
String | itemshopno | Item shop number |
String | title | Item title |
String | subtitle | Item subtitle |
String | itemimage | Item image url |
String | price | Item price |
String | itemtype | 1 : All mode (single and multi play) |
2 : Single play |
||
3 : Multi play |
||
String | itemstatus | 1 : Not yet on market |
2 : On market |
||
String | itemlevel | Item level |
String | itemexp | Item experience |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.UPDATEITEM
PLAYER.UPDATEITEM( items, onComplete, onError )
//'items' array should contains all 'item' objects from ITEM.GETGAMEITEM
var items = [{
useritemno:"928",
title:"Iron Ball",
subtitle:"Destroy all kind of bircks",
itemimage:"https://ipascf.pocketarena.com/pa/iron-ball.png",
price:"100",
itemtype:"2",
itemstatus:"1",
itemlevel:"1",
itemexp:"0",
marketyn:"1",
productid:"bfLGiKLxJdwjwQ"
}]
pasdk.PLAYER.UPDATEITEM( items, function(){
//onComplete
console.log('success');
}, function (err) {
console.log('err', err);
});
PLAYER.UPDATEITEM( items, onComplete, onError )
Update player’s item list
items
argument
Type | Description |
---|---|
Array | Array of containing item object.It should include not only items to update, but also the other items those player have. Item object is from ITEM.GETGAMEITEM |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.SENDVERIFICATIONEMAIL
PLAYER.SENDVERIFICATIONEMAIL( onComplete, onError )
pasdk.PLAYER.SENDVERIFICATIONEMAIL( function(){
//onComplete
console.log('success');
}, function (err) {
console.log('err', err);
});
PLAYER.SENDVERIFICATIONEMAIL( onComplete, onError )
Send an email that contains verification link.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
PLAYER.SIGNOUT
PLAYER.SIGNOUT( onComplete, onError )
pasdk.PLAYER.SIGNOUT( function( onComplete, onError ){
//onComplete
console.log('success');
}, function (err) {
console.log('err', err);
});
PLAYER.SIGNOUT( onComplete, onError )
Remove user’s session data
Game API
GAME.START
GAME.START( onComplete, onError )
pasdk.GAME.START(function(){
//onComplete
console.log('success')
}, function (err) {
//onError
console.log('err', err)
})
GAME.START( onComplete, onError )
Call when a game start. This API must be called for every single play.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
GAME.REPORTSCORE
GAME.REPORTSCORE( score, type, code, onComplete, onError )
var score = 22,
type = 0, //single play
code = 1; //win
pasdk.GAME.REPORTSCORE(score, type, code, function(rewardpoc){
//onComplete
console.log('rewardpoc', rewardpoc) //rewardpoc null | 14
}, function(err){
//onError
console.log('err', err)
})
GAME.REPORTSCORE(score, type, code, onComplete, onError)
Call when a game has finished to record the score to leaderboard. User’s sign in status can change after API call.
score
argument
Type | Description |
---|---|
Number | Score to send |
type
argument
Type | Value | Description |
---|---|---|
Number | 0 |
Single play |
1 |
Multi play |
code
argument
Type | Value | Description |
---|---|---|
Number | 0 |
Single |
1 |
Win | |
2 |
Lose | |
3 |
Draw |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Number / Null | rewardPOC | Amount of POC as a reward. If this argument’s value is not null , either you can use UI.REWARD API or build your own UI using GETREWARDPOC |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
GAME.SETSAVEDATA
GAME.SETSAVEDATA( data1, data2, data3, data4, data5, onComplete, onError )
var data1 = '980;',
data2 = '295;263;||263;262;',
data3 = '',
data4 = '4000',
data5 = '3;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;'
pasdk.GAME.SETSAVEDATA(data1, data2, data3, data4, data5, function(){
//onComplete
console.log('success')
}, function(err){
//onError
console.log('err', err)
})
GAME.SETSAVEDATA( data1, data2, data3, data4, data5, onComplete, onError )
Set user game data
data1
~ data5
arguments
Type | Argument | Description |
---|---|---|
String / Null | data1 | Any data. Send null if there is nothing to save. |
String / Null | data2 | Any data. Send null if there is nothing to save. |
String / Null | data3 | Any data. Send null if there is nothing to save. |
String / Null | data4 | Any data. Send null if there is nothing to save. |
String / Null | data5 | Any data. Send null if there is nothing to save. |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
GAME.GETSAVEDATA
GAME.GETSAVEDATA( onComplete, onError )
pasdk.GAME.GETSAVEDATA(function(data1, data2, data3, data4, data5){
//onComplete
console.log('data', data1, data2, data3, data4, data5) //data '980;' '' '295;263;||263;262;' '4000' '3;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;'
}, function(err){
//onError
console.log('err', err)
})
GAME.GETSAVEDATA(onComplete, onError)
Get user game data
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
String | data1 | Any data. When it's empty, Empty string('' ) will be returned. |
String | data2 | Any data. When it's empty, Empty string('' ) will be returned. |
String | data3 | Any data. When it's empty, Empty string('' ) will be returned. |
String | data4 | Any data. When it's empty, Empty string('' ) will be returned. |
String | data5 | Any data. When it's empty, Empty string('' ) will be returned. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
GAME.LEADERBOARD
GAME.LEADERBOARD( refresh, onComplete, onError )
var refresh = true;
pasdk.GAME.LEADERBOARD(refresh, function(leaderboard){
//onComplete
console.log('leaderboard', leaderboard) //see below 'leaderboard' object
}, function(err){
//onError
console.log('err', err)
});
Value of
leaderboard
for normal mode
{
"eventtile":"",
"startdate":1533254400,
"enddate":1564790400,
"myscore":"3",
"myranking":"12",
"leadertype":"0",
"totalcount":21,
"leader":{
"rowcount":21,
"leaderdata":[
//see below 'entry' object
]
}
}
Value of
leaderboard
for eSports mode
{
"eventtile":"",
"startdate":1533254400,
"enddate":1564790400,
"gameid":"yVvIYCpw",
"gameesportsno":"25",
"gametitle":"Cricket Championship",
"durationno": 2,
"remaintime": 234550,
"bgimage": "https:\/\/..com\/upload\/game\/pic\/1.png",
"stageno": "20",
"myleaderno": 24,
"groupno": 1,
"leadercount": 2,
"leader":{
"leaderdata":[
//see below 'entry' object
]
},
"rewards": [{
"reward_en": {
"title_1": "Final 10 users : $60 50 POC",
"title_2": "TOP 3 of each Group :50 POC ",
"description": "Final 10 users will be selected …...."
},
"reward_de": {
"title_1": "Final 10 users : $60 50 POC",
"title_2": "TOP 3 of each Group :50 POC ",
"description": "Final 10 users will be selected …...."
},
"reward_zh": {
"title_1": "Final 10 users : $60 50 POC",
"title_2": "TOP 3 of each Group :50 POC ",
"description": "Final 10 users will be selected …...."
},
"reward_ko": {
"title_1": "Final 10 users : $60 50 POC",
"title_2": "TOP 3 of each Group :50 POC ",
"description": "Final 10 users will be selected …...."
}
}]
}
entry
object. Values are the same in both mode.
[{
"ranking":"12",
"isme":"1",
"locale":"EN",
"picture":"NrPtCkznLubJ.jpg",
"nickname":"Spike Kang12",
"gamescore":"3"
}, {
"ranking":"14",
"isme":"0",
"locale":"VN",
"picture":"",
"nickname":"simon",
"gamescore":"1"
}]
GAME.LEADERBOARD(refresh, onComplete, onError)
Get leaderboard data. Ordered by rank ascending
refresh
argument
Type | Description |
---|---|
Boolean | true , get leaderboard data from server. |
false , get leaderboard data from SDK local data. |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows. There are two ways the value returned.
Normal mode and eSports mode
leaderboard
argument
- normal mode
Type | Key | Key | Description |
---|---|---|---|
String | myranking | User's rank | |
Object | leader | Leaderboard data | |
Number | rowcount | Total number of entries | |
Array | leaderdata | Leaderboard list data. See entry object below |
|
String | type | Leaderboard type. 0 : Win, 1 : Score |
|
Number | totalcount | Total number of entries |
- eSports mode
Type | Key | Key | Description |
---|---|---|---|
String | eventtitle | Its value will be returned if event exists. Otherwise, empty string("") | |
String | gameid | Game id of current game | |
String | gameesportsno | eSports number | |
String | gametitle | Title of current eSports game | |
Number | durationno | ||
Number | remaintime | Remaining time of this duration. in seconds. | |
String | bgimage | Background image to decorate current eSports' status. Developers can use their own image. | |
String | stageno | Stage number for this duration. | |
Number | myleaderno | Number of my leaderboard. | |
Number | groupno | Group number of my leaderboard. | |
Number | leadercount | Total number of leaderboard entries. | |
Object | leader | This one has below properties. | |
Number | rowcount | Total number of leaderboard entries. | |
Array | leaderdata | Leaderboard list data. See entry object below |
|
Array | rewards | list of reward object. See below reward object. |
reward
object
Type | Key | Key | Description |
---|---|---|---|
Object | reward_(language code, ex) en ) |
This one has below properties. | |
String | title_1 | Title | |
String | title_2 | Title | |
String | description | Description |
entry
object
Both normal and eSports mode are the same.
Type | Key | Description |
---|---|---|
String | ranking | Entry user's ranking |
String | nickname | Entry user's nickname |
String | gamescore | Entry user's gamescore |
String | isme | 0 : Not user, 1 : User |
String | locale | Entry user's locale |
String | picture | Entry user's profile image. '' for user who doesn't have profile image |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
GAME.GETESPORTSSTATUS()
GAME.GETESPORTSSTATUS()
var eSportsStat = pasdk.GAME.GETESPORTSSTATUS();
// eSportsStat, when eSports is goin on
// { bgimage: "https://pacoin-dev1.pocketarena.com/upload/game/pic/170c4f795229b9f9d66d8b8ccdcc5732.png"
// durationno: 14
// enddate: 1560729600
// enddates: "2019-06-17 00:00:00"
// gametitle: "Cricket"
// ischampion: "0"
// remaintime: 71367
// startdate: 1560643200
// startdates: "2019-06-16 00:00:00"
// totaluser: "0" }
// eSportsStat, when eSports is NOT goin on
// null
GAME.GETESPORTSSTATUS()
Get eSports status information
Return value
Type | Value | Description |
---|---|---|
String | bgimage |
Rank is based on number of win |
Number | duration |
Duration no |
timestamp | startdate |
Datetime of eSports start. ex) 1560643200 |
timestamp | enddate |
Datetime of eSports end. ex) 1560729600 |
String | startdates |
Formatted of startdate . ex) "2019-06-16 00:00:00" |
String | enddates |
Formatted of enddate . ex) "2019-06-16 00:00:00" |
String | gametitle |
Game title. |
String | ischampion |
0 , when it's Casual eSports.1 , when it's PA Championship. |
timestamp | remaintime |
Time indicating how long current eSports is going to be. |
Item API
ITEM.GETGAMEITEM
ITEM.GETGAMEITEM( onComplete, onError )
pasdk.ITEM.GETGAMEITEM(function(list){
//onComplete
console.log('list', list); //see below
}, function (err) {
//onError
console.log('err', err);
});
item
object
[{
"itemshopno":"1",
"title":"Super Ball",
"subtitle":"Destroy all kind of bircks",
"itemimage":"https://ipascf.pocketarena.com/pa/superball.png",
"price":"150",
"itemtype":"2",
"marketyn":"1",
"productid":"OZUUEFKKjGHu"
}]
ITEM.GETGAMEITEM( onComplete, onError )
Get items that game offers to users
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
list
argument
Type | Description |
---|---|
Array | List of item object |
item
object
Type | Argument | Description |
---|---|---|
String | itemshopno | Item shop number |
String | title | Item title |
String | subtitle | Item subtitle |
String | itemimage | Item image url |
String | price | Item price |
String | itemtype | 1 : All mode |
2 : single play |
||
3 : multi play |
||
String | marketyn | 1 : Using item in blockchain |
2 : Not using item in blockchain |
||
String | productid | Product ID from EmojiGames itemshop. Empty string('' ) when marketyn is 0 |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
ITEM.CHECKDEFAULTITEMS
ITEM.CHECKDEFAULTITEMS( onComplete, onError )
pasdk.ITEM.CHECKDEFAULTITEMS(function(list){
//onComplete
console.log('list', list) //see below
}, function(err){
//onError
console.log('err', err)
})
item
object
[{
"useritemno":"928",
"title":"Iron Ball",
"subtitle":"Destroy all kind of bircks",
"itemimage":"https://ipascf.pocketarena.com/pa/iron-ball.png",
"price":"100",
"itemtype":"2",
"itemstatus":"1",
"itemlevel":"1",
"itemexp":"0",
"marketyn":"1",
"productid":"bfLGiKLxJdwjwQ"
}]
ITEM.CHECKDEFAULTITEMS( onComplete, onError )
Check if user is given default items. It not, it will be given.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Array | list | List of item object. Same from PLAYER.GETITEM |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
ITEM.PURCHASE
ITEM.PURCHASE( items, onComplete, onError )
//list of 'item' object
var items = [{
itemshopno:"1",
title:"Super Ball",
subtitle:"Destroy all kind of bircks",
itemimage:"https://ipascf.pocketarena.com/pa/superball.png",
price:"150",
itemtype:"2",
marketyn:"1",
productid:"OZUUEFKKjGHu"
}];
pasdk.ITEM.PURCHASE(items, function(){
//onComplete
console.log('success');
}, function (err) {
//onError
console.log('err', err);
});
ITEM.PURCHASE( items, onComplete, onError )
Call when user purchases an item from ITEM.GETGAMEITEM API
items
argument
Type | Description |
---|---|
Array | List of item object to send to server. Same item from ITEM.GETGAMEITEM API |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI API
Display UI on screen such as leaderboard, login/sign up and tokenshop. Please note that …
1. animation duration of modal open and closing is 400ms. This may close a modal that is called during the animation phase.
2. User’s login status can be changed after UI API call. For example, user who is not logged in can login or signup when the modal is open, because some contents are required login/sign up and the UI will prompt the user to login/sign up modal.
3. .modal-overlay
is the wrapper element of the modal UI, and its z-index
is 100.
UI.SIGNUP
UI.SIGNUP( onComplete, onError )
pasdk.UI.SIGNUP(function(player, poc){
//onComplete
console.log('success', player, poc) //success {...} 87568
}, function (err) {
//onError
//ex) User clicked 'X'(close) button
console.log('err', err)
})
UI.SIGNUP( onComplete, onError )
Display sign up modal
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Object | player | Player info. See PLAYER.GETINFO |
Number / Null | poc | null if user has not done verification. Otherwise POC balance. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI.SIGNIN
UI.SIGNIN( onComplete, onError )
pasdk.UI.SIGNIN(function(player, poc){
//onComplete
console.log('success', player, poc) //success {...} 87568
}, function (err) {
//onError
//ex) User clicked 'X'(close) button
console.log('err', err)
})
UI.SIGNIN( onComplete, onError )
Display login modal
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onComplete
returns belows.
Type | Argument | Description |
---|---|---|
Object | player | Player info. See PLAYER.GETINFO |
Number / Null | poc | null if user has not done verification. Otherwise POC balance. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI.MYPROFILE
UI.MYPROFILE( onComplete, onError )
pasdk.UI.MYPROFILE(function(isSignedIn){
//onSignout
console.log('success')
}, function (err) {
//onError
//ex) User clicked 'X'(close) button
console.log('err', err)
})
UI.MYPROFILE( onComplete, onError )
Display my profile modal. Please note that user can sign out and change profile info while using this UI.
onComplete
argument
Type | Description |
---|---|
Function | Triggered when user clicks sign out button, and edit profile and closes it.It returns below argument. |
isSignedIn
argument
Type | Description |
---|---|
Boolean | true if user kept the session. Otherwise, false |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI.EDITPROFILE
UI.EDITPROFILE( onComplete, onError )
pasdk.UI.EDITPROFILE(function(){
//onComplete
console.log('success')
}, function (err) {
//onError
//ex) User clicked 'X'(close) button
console.log('err', err)
})
UI.EDITPROFILE( onComplete, onError )
Display my profile edit form modal
onComplete
argument
Type | Description |
---|---|
Function | Triggered when call is success. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI.MESSAGEBOX
UI.MESSAGEBOX( onError )
pasdk.UI.MESSAGEBOX(function (err) {
//onError
//ex) User clicked 'X'(close) button
console.log('err', err)
})
UI.MESSAGEBOX( onError )
Display my message box modal
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI.LEADERBOARD
UI.LEADERBOARD( onLogin, onError )
pasdk.UI.LEADERBOARD(function(player, poc){
// onLogin
// same as `UI.SIGNIN` or `UI.SIGNUP`'s `onComplete` argument
console.log('success', player, poc) //success {...} 87568
}, function (err) {
//onError
//ex) User clicked 'X'(close) button
console.log('err', err)
})
UI.LEADERBOARD( onLogin, onError )
Display leaderboard modal. Note that there are two types of leaderboards, normal and eSports. These leaderboards have different layout and slightly different functions. User can login or sign up from eSports leaderboard.
onLogin
argument
Type | Description |
---|---|
Function | Triggered when user sign up or login by clicking eSports leaderboard. |
onLogin
returns belows.
Type | Argument | Description |
---|---|---|
Object | player | Player info. See PLAYER.GETINFO |
Number / Null | poc | null if user has not done verification. Otherwise POC balance. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI.TOGGLELEADERBOARD
UI.TOGGLELEADERBOARD( show )
// Force to show the leaderboard
pasdk.UI.TOGGLELEADERBOARD(true);
// Force to hide the leaderboard
pasdk.UI.TOGGLELEADERBOARD(false);
// Show the leaderboard if the leaderboard is hidden
// Hide the leaderboard if the leaderboard is shown
pasdk.UI.TOGGLELEADERBOARD();
UI.TOGGLELEADERBOARD( show )
Show/hide eSports leaderboard. This API works for only eSports leaderboard. So please make sure if the leaderboard type is eSports leaderboard and UI.LEADERBOARD
is displayed. Note that the data is not refreshed.
show
argument
Type | Description |
---|---|
Boolean | true , force to show the leaderboardfalse , force to hide the leaderboard |
undefined | Toggle the leaderboard |
UI.PATOKENSHOP
UI.PATOKENSHOP( onClose, onError )
pasdk.UI.PATOKENSHOP( function(POC, purchasedItem){
//onClose
//User clicked 'X'(close) button after purchase
console.log('success', POC, purchasedItem) //success 19 3
}, function (err) {
//onError
//ex) User clicked 'X'(close) button without purchase
console.log('err', err)
})
UI.PATOKENSHOP(onClose, onError)
Display token shop modal. When purchase is made, SDK will calculate and return POC balance and the total amount of item to onClose
argument.
onClose
argument
Type | Description |
---|---|
Function | Triggered when user click ‘x’(close) button after purchasing item(s). |
onClose
returns belows.
Type | Argument | Description |
---|---|---|
String | POC | POC balance after purchase |
Number | purchsedItem | Amount of items purchased in the modal |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI.MESSAGE
UI.MESSAGE( message, onComplete, onError )
var message = {title : 'Hi there',
message: 'Welcome to Pocket Arena!<br>Want to join?',
buttons: [
{ text : "Sure" },
{ text : "No, thanks" } //up to two buttons
]};
pasdk.UI.MESSAGE( message, function(idx){
//onComplete
if ( idx == 0 ) {
console.log('\'Sure\' button clicked ')
}else if ( idx == 1 ) {
console.log('\'No, thanks\' button clicked ')
}
}, function (err) {
//onError
//ex) User clicked 'X'(close) button
console.log('err', err)
})
UI.MESSAGE( message, onComplete, onError )
Display a dialog that contains messages.
message
argument
Type | Description |
---|---|
object | Setting for message dialog |
Type | Key | Description |
---|---|---|
String | title | Modal title |
String | message | Modal message |
Array | buttons | Text for buttons. Up to two buttons. Contains button object |
button
object
Type | Key | Description |
---|---|---|
String | text | Button text |
onComplete
argument
Type | Description |
---|---|
Function | Triggered when user click OK button. |
onError
argument
Type | Description |
---|---|
Function | Triggered when error occurrs. |
See Errors menu
UI.SHARE
UI.SHARE( onComplete, onError )
pasdk.UI.SHARE( function(){
//onComplete; nothing happens here
}, function (err) {
//onError
//User clicked 'X'(close) button
console.log('err', err)
})
UI.SHARE( onComplete, onError )
Display a SNS share dialog. Currently, below platforms are supported.
- Whats app
- FB Messenger
- Kakao Talk
- Line
- VK
SDK create share links using below info. So please make sure if these are set up to the index.html
file.
- url : The game's url
- image : Using
meta[property='og:image']
value - title : Using
title
tag's value. - description : Using
meta[property='og:description']
value
onComplete
argument
Type | Description |
---|---|
Function | This is currently not used. |
onError
argument
Type | Description |
---|---|
Function | Triggered when the modal is closed. |
UI.ESPORTSINFO
UI.ESPORTSINFO( onError )
pasdk.UI.ESPORTSINFO( function(){
// modal is closed
})
UI.ESPORTSINFO()
Display eSports information image.
UI.CLOSE
UI.CLOSE()
pasdk.UI.CLOSE()
UI.CLOSE()
Close modal that is open currently
UI.CLEAR
UI.CLEAR()
pasdk.UI.CLEAR()
UI.CLEAR()
Remove all elements that is created by SDK from DOM.
Errors
error
object
{
"returncode" : 400,
"detail":"LACK_OF_POC",
"message":"BAD REQUEST",
"userMessage":"Insufficient amount of POC."
}
returncode | message | detail | userMessage |
---|---|---|---|
200 | Modal closed | MODAL_CLOSED | Modal closed. |
400 | Bad request ex) When clients send like below - wrong parameters and/or its value, - missing required parameters |
MISSING_PARAMETER | |
WRONG_PARAMS_VALUE | Please check your request and try it again. | ||
LACK_OF_POC | Insufficient amount of POC. | ||
EMAIL_IS_ALREADY_IN_USE | An account with this email is already in use. | ||
WRONG_SHOP_ITEM | The item could not be found in the shop. | ||
WRONG_ID_OR_PASSWORD | Invalid ID or password. | ||
WRONG_CURRENT_PASSWORD | Current password is incorrect. | ||
WRONG_FILE_EXTENSION | Wrong file extension. | ||
WRONG_USER_INFO_OR_OTP | Could not login because of wrong user info. | ||
NEED_AGREEMENT_PACOIN | Verification is required to use POC. | ||
UNKNOWN_USER_ITEM | It's an unknown user item. | ||
UNAVAILABLE_USER_ITEM | The item is unavailable. | ||
WRONG_PASSWORD | Invalid ID or password. | ||
401 | Unauthorized Player needs to login. ex) - Valid session time is over. - Player signed out. - Player is not signed in. - disabled account |
UNKNOWN_USER | Unknown user. |
DISABLED_ACCOUNT | This account has been disabled. | ||
SESSION_EXPIRED | Session has expired. | ||
429 | Too many request | TOO_MANY_SIGN_UP_WITH_SAME_IP | You can not create a PA Account on your current IP address. |
500 | Server error ex) server is not available, unknown error, etc |
SYSTEM_ERROR | Server error has occurred. |
CAN_NOT_GET_USER_POC | Server error has occurred. | ||
POC_SERVER_DID_NOT_RESPONSE | Server error has occurred. | ||
CAN_NOT_REGISTER_TO_BLOCKCHAIN | Server error has occurred. | ||
502 | Bad gateway | BAD_GATEWAY | Server error has occurred. |
503 | Service unavailable : ex) timeout, connection lost | SERVICE_UNAVAILABLE | Service unavailable. |
505 | Unknown Unknown error |
UNKNOWN | Unknown error has occurred. Please try it later. |
FAILED_TO_UPDATE_USER_DATA | Save failed. Please try it again. | ||
ETC When message is delivered from another server. The message varies. Format : “ETC : (a message from another server)” ex) “ETC : error on loadAccount“ |