-
Notifications
You must be signed in to change notification settings - Fork 1
/
my.jslib
67 lines (54 loc) · 1.68 KB
/
my.jslib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
mergeInto(LibraryManager.library, {
GiveMePlayerData: function () {
myGameInstance.SendMessage('Yandex', 'SetName', player.getName());
myGameInstance.SendMessage('Yandex', 'SetPhoto', player.getPhoto("medium"));
},
RateGame: function () {
ysdk.feedback.canReview()
.then(({ value, reason }) => {
if (value) {
ysdk.feedback.requestReview()
.then(({ feedbackSent }) => {
console.log(feedbackSent);
})
} else {
}
})
},
SaveExtern: function(date) {
var dateString = UTF8ToString(date);
var myobj = JSON.parse(dateString);
player.setData(myobj);
},
LoadExtern: function(){
player.getData().then(_date => {
const myJSON = JSON.stringify(_date);
myGameInstance.SendMessage('Progress', 'SetPlayerInfo', myJSON);
});
},
SetToLeaderboard : function(value){
ysdk.getLeaderboards()
.then(lb => {
lb.setLeaderboardScore('bestScore', value);
});
},
GetLang: function () {
var lang = ysdk.environment.i18n.lang;
var bufferSize = lengthBytesUTF8(lang) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(lang, buffer, bufferSize);
return buffer;
},
ShowAdv : function(){
ysdk.adv.showFullscreenAdv({
callbacks: {
onClose: function(wasShown) {
// some action after close
},
onError: function(error) {
// some action on error
}
}
})
},
});