social_stream-presence 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/games/sfighter/abobo/abobo.png +0 -0
- data/app/assets/images/games/sfighter/abobo/abobo_block_81x130x1.png +0 -0
- data/app/assets/images/games/sfighter/abobo/abobo_die_156x119x1.png +0 -0
- data/app/assets/images/games/sfighter/abobo/abobo_hit_108x120x3.png +0 -0
- data/app/assets/images/games/sfighter/abobo/abobo_idle_100x121x3.png +0 -0
- data/app/assets/images/games/sfighter/abobo/abobo_kick_137x130x2.png +0 -0
- data/app/assets/images/games/sfighter/abobo/abobo_punch_131x170x4.png +0 -0
- data/app/assets/images/games/sfighter/abobo/abobo_walk_backward_94x126x6.png +0 -0
- data/app/assets/images/games/sfighter/abobo/abobo_walk_forward_94x126x6.png +0 -0
- data/app/assets/images/games/sfighter/cvs/cvs_block_69x99x2.png +0 -0
- data/app/assets/images/games/sfighter/cvs/cvs_die_150x110x1.png +0 -0
- data/app/assets/images/games/sfighter/cvs/cvs_hit_59x103x1.png +0 -0
- data/app/assets/images/games/sfighter/cvs/cvs_idle_59x106x6.png +0 -0
- data/app/assets/images/games/sfighter/cvs/cvs_kick_156x106x9.png +0 -0
- data/app/assets/images/games/sfighter/cvs/cvs_punch_120x104x6.png +0 -0
- data/app/assets/images/games/sfighter/cvs/cvs_walk_backward_58x106x5.png +0 -0
- data/app/assets/images/games/sfighter/cvs/cvs_walk_forward_58x106x5.png +0 -0
- data/app/assets/images/games/sfighter/stage/background1.png +0 -0
- data/app/assets/images/games/sfighter/stage/background2.png +0 -0
- data/app/assets/images/games/sfighter/stage/background3.png +0 -0
- data/app/assets/images/games/sfighter/stage/foreground.png +0 -0
- data/app/assets/images/games/sfighter/stage/ground.png +0 -0
- data/app/assets/images/games/sfighter/thumbnail.png +0 -0
- data/app/assets/images/games/ter/classic_circle.png +0 -0
- data/app/assets/images/games/ter/classic_thumbnail.png +0 -0
- data/app/assets/images/games/ter/modern_thumbnail.png +0 -0
- data/app/assets/images/webcam.png +0 -0
- data/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +2 -2
- data/app/assets/javascripts/presence_XmppClient.js.erb +3 -1
- data/app/assets/javascripts/presence_game.js.erb +13 -6
- data/app/assets/javascripts/presence_game_comunication.js.erb +83 -13
- data/app/assets/javascripts/presence_game_factory.js.erb +47 -0
- data/app/assets/javascripts/presence_game_interface.js.erb +143 -53
- data/app/assets/javascripts/presence_game_sfighter.js.erb +583 -0
- data/app/assets/javascripts/presence_game_ter.js.erb +20 -9
- data/app/assets/javascripts/presence_uiManager.js.erb +0 -2
- data/app/assets/javascripts/presence_utilities.js +1 -1
- data/app/assets/javascripts/presence_videochat.js.erb +5 -0
- data/app/assets/javascripts/social_stream-presence.js +1 -0
- data/app/assets/stylesheets/chat.css.scss +59 -6
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/lib/social_stream/presence/version.rb +1 -1
- metadata +119 -65
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -190,8 +190,8 @@
|
|
190
190
|
})
|
191
191
|
.appendTo(uiChatboxTitlebar),
|
192
192
|
uiChatboxTitlebarVideoText = $('<span></span>')
|
193
|
-
.addClass('ui-icon-circle-triangle-e ' +
|
194
|
-
.text('
|
193
|
+
.addClass('ui-icon-circle-triangle-e ' + 'chat-thick ' + ' chat-videothick' )
|
194
|
+
.text(' ')
|
195
195
|
.appendTo(uiChatboxTitlebarVideo),
|
196
196
|
|
197
197
|
|
@@ -263,7 +263,9 @@ function onConnect(status) {
|
|
263
263
|
disconnectionFlag = false;
|
264
264
|
afterNewConnectionFlag = true;
|
265
265
|
|
266
|
-
userStatus
|
266
|
+
if(! userStatus){
|
267
|
+
userStatus = getRestoreUserChatStatus();
|
268
|
+
}
|
267
269
|
if(userStatus=="offline"){
|
268
270
|
userStatus="chat";
|
269
271
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
////////////////////
|
2
2
|
//Multiplayer Games Core based on XMPP
|
3
|
+
//Version: 1.2
|
3
4
|
////////////////////
|
4
5
|
|
5
6
|
PRESENCE.GAME = (function(P,$,undefined){
|
@@ -45,6 +46,10 @@ PRESENCE.GAME = (function(P,$,undefined){
|
|
45
46
|
|
46
47
|
|
47
48
|
var requestUserToPlay = function (slug,game){
|
49
|
+
if(game==null){
|
50
|
+
return;
|
51
|
+
}
|
52
|
+
|
48
53
|
if (slug in contactsInfo) {
|
49
54
|
var gameStatus = contactsInfo[slug].gameStatus;
|
50
55
|
} else {
|
@@ -102,13 +107,13 @@ PRESENCE.GAME = (function(P,$,undefined){
|
|
102
107
|
}
|
103
108
|
}
|
104
109
|
|
105
|
-
var sendAction = function(
|
106
|
-
$.each(players, function(index, value) {
|
110
|
+
var sendAction = function(game,action){
|
111
|
+
$.each(game.players, function(index, value) {
|
107
112
|
var slug = value.id;
|
108
113
|
if(slug!=user_slug){
|
109
114
|
if(slug in contactsInfo){
|
110
115
|
var jid=slug+"@"+contactsInfo[slug].domain+"/"+contactsInfo[slug].resource;
|
111
|
-
P.GAME.COMUNICATION.sendIQStanzaWithAction(jid,
|
116
|
+
P.GAME.COMUNICATION.sendIQStanzaWithAction(jid,game.id,action);
|
112
117
|
}
|
113
118
|
}
|
114
119
|
});
|
@@ -126,7 +131,7 @@ PRESENCE.GAME = (function(P,$,undefined){
|
|
126
131
|
} else {
|
127
132
|
contactsInfo[slug].gameStatus="pending";
|
128
133
|
}
|
129
|
-
P.GAME.INTERFACE.updateInterfaceAfterGameRequestReceived(slug)
|
134
|
+
P.GAME.INTERFACE.updateInterfaceAfterGameRequestReceived(slug,contactsInfo[slug].game)
|
130
135
|
}
|
131
136
|
|
132
137
|
var updateLogicAfterReceivedGameRequestResponse = function(slug,response){
|
@@ -135,7 +140,7 @@ PRESENCE.GAME = (function(P,$,undefined){
|
|
135
140
|
}
|
136
141
|
if(response=="yes"){
|
137
142
|
contactsInfo[slug].gameStatus = "playing";
|
138
|
-
P.GAME.INTERFACE.updateInterfaceBeforeStartGame(slug)
|
143
|
+
P.GAME.INTERFACE.updateInterfaceBeforeStartGame(slug,contactsInfo[slug].game)
|
139
144
|
} else if (response=="no"){
|
140
145
|
P.GAME.INTERFACE.updateInterfaceOnInformationMessage(slug,I18n.t("chat.game.rejected", {name: getNameFromSlug(slug)}));
|
141
146
|
contactsInfo[slug].gameStatus="disconnected";
|
@@ -267,6 +272,7 @@ PRESENCE.GAME = (function(P,$,undefined){
|
|
267
272
|
}
|
268
273
|
|
269
274
|
var finishGame = function (slug){
|
275
|
+
var game = null;
|
270
276
|
if(slug in contactsInfo){
|
271
277
|
var gameStatus = contactsInfo[slug].gameStatus;
|
272
278
|
if(gameStatus=="playing"){
|
@@ -283,9 +289,10 @@ PRESENCE.GAME = (function(P,$,undefined){
|
|
283
289
|
P.GAME.COMUNICATION.sendIQStanzaToResponseGameRequest(slug,"no");
|
284
290
|
}
|
285
291
|
contactsInfo[slug].gameStatus="disconnected";
|
292
|
+
game = contactsInfo[slug].game
|
286
293
|
}
|
287
294
|
|
288
|
-
PRESENCE.GAME.INTERFACE.updateInterfaceAfterFinishGame(slug)
|
295
|
+
PRESENCE.GAME.INTERFACE.updateInterfaceAfterFinishGame(slug,game)
|
289
296
|
}
|
290
297
|
|
291
298
|
var userDisconnected = function(slug){
|
@@ -25,6 +25,7 @@ PRESENCE.GAME.COMUNICATION = (function(P,$,undefined){
|
|
25
25
|
connection.addHandler(handleRequestGameIQStanza,null, "iq", "get",iqStanzaID['gameRequest'], null);
|
26
26
|
connection.addHandler(handleIQResultFromGameRequest,null, "iq", "result",iqStanzaID['gameRequest'], null);
|
27
27
|
connection.addHandler(handleIQResultFromGameRequestFinish,null, "iq", "result", iqStanzaID['gameRequestFinish'], null);
|
28
|
+
connection.addHandler(handleActionIQStanza,null, "iq", "result", getIdForIqAction("gameId"), null);
|
28
29
|
};
|
29
30
|
|
30
31
|
|
@@ -196,29 +197,67 @@ PRESENCE.GAME.COMUNICATION = (function(P,$,undefined){
|
|
196
197
|
}
|
197
198
|
|
198
199
|
var genetareIQStanzaWithObject = function(iq,object){
|
200
|
+
|
199
201
|
if(typeof object != "object"){
|
200
202
|
return iq;
|
201
203
|
}
|
204
|
+
|
202
205
|
var childs=Object.keys(object).length;
|
203
206
|
var childsCounter = 0;
|
204
207
|
|
205
208
|
$.each(object, function(index, value) {
|
209
|
+
|
206
210
|
if(value==null){
|
207
211
|
return;
|
208
212
|
}
|
213
|
+
|
209
214
|
if((typeof value == "object")){
|
210
215
|
//Complex object
|
211
|
-
|
216
|
+
var object_type = "object"
|
217
|
+
|
218
|
+
if(value.constructor.toString().indexOf("Array")!=-1){
|
219
|
+
object_type = "array"
|
220
|
+
}
|
221
|
+
|
222
|
+
iq.c(index, {type: object_type})
|
212
223
|
iq = genetareIQStanzaWithObject(iq,value)
|
224
|
+
|
213
225
|
} else {
|
214
|
-
|
215
|
-
|
216
|
-
|
226
|
+
//Simple object
|
227
|
+
|
228
|
+
var data_type = (typeof value)
|
229
|
+
var index_type = (typeof index)
|
230
|
+
|
231
|
+
switch (data_type){
|
232
|
+
case "number":
|
233
|
+
value = value + "";
|
234
|
+
break;
|
235
|
+
case "boolean":
|
236
|
+
value = value.toString();
|
237
|
+
break;
|
238
|
+
case "string":
|
239
|
+
//do nothing
|
240
|
+
break;
|
241
|
+
default:
|
242
|
+
break;
|
243
|
+
}
|
244
|
+
|
245
|
+
switch (index_type){
|
246
|
+
case "number":
|
247
|
+
//case: Array
|
248
|
+
index = "item";
|
249
|
+
break;
|
250
|
+
case "string":
|
251
|
+
//do nothing
|
252
|
+
break;
|
253
|
+
default:
|
254
|
+
break;
|
217
255
|
}
|
256
|
+
|
218
257
|
if(childsCounter==childs-1){
|
219
|
-
iq.c(index, {}).t(value).up().up()
|
258
|
+
iq.c(index, {type: data_type}).t(value).up().up()
|
220
259
|
} else {
|
221
|
-
iq.c(index, {}).t(value).up()
|
260
|
+
iq.c(index, {type: data_type}).t(value).up()
|
222
261
|
}
|
223
262
|
}
|
224
263
|
childsCounter++;
|
@@ -263,19 +302,47 @@ PRESENCE.GAME.COMUNICATION = (function(P,$,undefined){
|
|
263
302
|
$.each($(childs).children(), function(index, value) {
|
264
303
|
if ($(value).children().length>0) {
|
265
304
|
//Complex object
|
266
|
-
|
305
|
+
if ($(value).attr("type")=="array"){
|
306
|
+
parent[value.tagName] = new Array()
|
307
|
+
} else {
|
308
|
+
parent[value.tagName] = new Object()
|
309
|
+
}
|
267
310
|
parent[value.tagName]= buildComplexObject(parent[value.tagName],$(value))
|
311
|
+
|
268
312
|
} else {
|
269
313
|
//Simple object
|
314
|
+
var myvalue = null
|
315
|
+
var stringValue = $(value).text()
|
270
316
|
|
271
317
|
//Check dataformat
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
318
|
+
var data_type = $(value).attr("type")
|
319
|
+
|
320
|
+
switch (data_type){
|
321
|
+
case "number":
|
322
|
+
if(! isNaN(+(stringValue))){
|
323
|
+
//$(value).text() is a string which contains a number
|
324
|
+
myvalue = +(stringValue)
|
325
|
+
}
|
326
|
+
break;
|
327
|
+
case "boolean":
|
328
|
+
if((stringValue=="true")||(stringValue=="false")){
|
329
|
+
myvalue = (stringValue === "true")
|
330
|
+
}
|
331
|
+
break;
|
332
|
+
case "string":
|
333
|
+
myvalue = stringValue
|
334
|
+
break;
|
335
|
+
default:
|
336
|
+
break;
|
277
337
|
}
|
278
|
-
|
338
|
+
|
339
|
+
//Is parent an array element and value an array item?
|
340
|
+
if((parent.constructor.toString().indexOf("Array")!=-1)&&(value.tagName == "item")){
|
341
|
+
parent.push(myvalue)
|
342
|
+
} else {
|
343
|
+
parent[value.tagName]=myvalue
|
344
|
+
}
|
345
|
+
|
279
346
|
}
|
280
347
|
});
|
281
348
|
return parent
|
@@ -311,3 +378,6 @@ PRESENCE.GAME.COMUNICATION = (function(P,$,undefined){
|
|
311
378
|
};
|
312
379
|
|
313
380
|
}) (PRESENCE, jQuery);
|
381
|
+
|
382
|
+
|
383
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
////////////////////
|
2
|
+
//Multiplayer Games Interface Manager
|
3
|
+
////////////////////
|
4
|
+
|
5
|
+
PRESENCE.GAME.FACTORY = (function(P,$,undefined){
|
6
|
+
|
7
|
+
//////////////////////////
|
8
|
+
// BUILDERS //
|
9
|
+
//////////////////////////
|
10
|
+
|
11
|
+
var getGame = function(slug,choice){
|
12
|
+
switch(choice){
|
13
|
+
case "Modern-TER":
|
14
|
+
var options = new Array();
|
15
|
+
options['theme']="Modern";
|
16
|
+
return generateGame(slug,"TER",options)
|
17
|
+
case "Classic-TER":
|
18
|
+
var options = new Array();
|
19
|
+
options['theme']="Classic";
|
20
|
+
return generateGame(slug,"TER",options)
|
21
|
+
default:
|
22
|
+
return null
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
var generateGame = function(guest_slug,gameId,options){
|
27
|
+
var player1 = new PRESENCE.GAME.player(user_slug,user_name)
|
28
|
+
var player2 = new PRESENCE.GAME.player(guest_slug,getNameFromSlug(guest_slug))
|
29
|
+
var players = [player1,player2]
|
30
|
+
var mygame = new PRESENCE.GAME.game(gameId,getGameName(gameId),players,options)
|
31
|
+
return mygame;
|
32
|
+
}
|
33
|
+
|
34
|
+
var getGameName = function(gameId){
|
35
|
+
if (typeof PRESENCE.GAME[gameId].getName == "function") {
|
36
|
+
return PRESENCE.GAME[gameId].getName();
|
37
|
+
} else {
|
38
|
+
return gameId;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
return {
|
44
|
+
getGame: getGame
|
45
|
+
};
|
46
|
+
|
47
|
+
}) (PRESENCE, jQuery);
|
@@ -3,31 +3,12 @@
|
|
3
3
|
////////////////////
|
4
4
|
|
5
5
|
PRESENCE.GAME.INTERFACE = (function(P,$,undefined){
|
6
|
-
|
7
|
-
//////////////////////////
|
8
|
-
// TRIGGERS //
|
9
|
-
//////////////////////////
|
10
|
-
|
11
|
-
var pickGamesButton = function (uiElement){
|
12
|
-
var slug = $(uiElement.element).attr("id");
|
13
|
-
var videoBoxVisibility = toggleVideoBoxForSlug(slug);
|
14
|
-
|
15
|
-
if (videoBoxVisibility) {
|
16
|
-
hideVideoChatButton(slug);
|
17
|
-
var mygame = generateDefaultGame(slug);
|
18
|
-
PRESENCE.GAME.requestUserToPlay(slug,mygame);
|
19
|
-
} else {
|
20
|
-
showVideoChatButton(slug);
|
21
|
-
PRESENCE.GAME.finishGame(slug);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
6
|
|
26
7
|
////////////////////////////
|
27
8
|
// CALLBACKS //
|
28
9
|
////////////////////////////
|
29
10
|
|
30
|
-
updateInterfaceAfterGameRequestReceived = function(slug){
|
11
|
+
updateInterfaceAfterGameRequestReceived = function(slug,game){
|
31
12
|
//gameStatus="pending";
|
32
13
|
|
33
14
|
//Show or create chatbox
|
@@ -35,7 +16,7 @@ PRESENCE.GAME.INTERFACE = (function(P,$,undefined){
|
|
35
16
|
var chatBox = getChatBoxForSlug(slug);
|
36
17
|
|
37
18
|
//Show invitation message
|
38
|
-
showGameInvitation(slug);
|
19
|
+
showGameInvitation(slug,game);
|
39
20
|
|
40
21
|
//Hide hideVideoChatButton
|
41
22
|
hideVideoChatButton(slug);
|
@@ -44,7 +25,7 @@ PRESENCE.GAME.INTERFACE = (function(P,$,undefined){
|
|
44
25
|
toggleVideoBoxForSlug(slug,true);
|
45
26
|
}
|
46
27
|
|
47
|
-
var updateInterfaceBeforeStartGame = function(slug){
|
28
|
+
var updateInterfaceBeforeStartGame = function(slug,game){
|
48
29
|
var parentDiv = document.createElement('div');
|
49
30
|
var divID = 'game_' + slug + contactsInfo[slug].game.id;
|
50
31
|
parentDiv.setAttribute('id', divID);
|
@@ -55,7 +36,7 @@ PRESENCE.GAME.INTERFACE = (function(P,$,undefined){
|
|
55
36
|
PRESENCE.GAME.startGame(slug,divID)
|
56
37
|
}
|
57
38
|
|
58
|
-
var updateInterfaceAfterFinishGame = function(slug){
|
39
|
+
var updateInterfaceAfterFinishGame = function(slug,game){
|
59
40
|
toggleVideoBoxForSlug(slug,false);
|
60
41
|
showVideoChatButton(slug);
|
61
42
|
}
|
@@ -66,12 +47,144 @@ PRESENCE.GAME.INTERFACE = (function(P,$,undefined){
|
|
66
47
|
|
67
48
|
|
68
49
|
|
50
|
+
//////////////////////////
|
51
|
+
// TRIGGERS //
|
52
|
+
//////////////////////////
|
53
|
+
|
54
|
+
var pickGamesButton = function (uiElement){
|
55
|
+
var slug = $(uiElement.element).attr("id");
|
56
|
+
var videoBoxVisibility = toggleVideoBoxForSlug(slug);
|
57
|
+
|
58
|
+
if (videoBoxVisibility) {
|
59
|
+
hideVideoChatButton(slug);
|
60
|
+
showGames(slug);
|
61
|
+
} else {
|
62
|
+
showVideoChatButton(slug);
|
63
|
+
PRESENCE.GAME.finishGame(slug);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
///////////////////////////
|
69
|
+
// GAME LIST //
|
70
|
+
///////////////////////////
|
71
|
+
|
72
|
+
function gameItem(name,choice,thumbnail) {
|
73
|
+
this.name = name;
|
74
|
+
this.choice = choice;
|
75
|
+
this.thumbnail = thumbnail;
|
76
|
+
}
|
77
|
+
|
78
|
+
var gameList = [];
|
79
|
+
gameList.push(new gameItem("Modern Tic Tac Toe","Modern-TER","/assets/games/ter/modern_thumbnail.png"))
|
80
|
+
gameList.push(new gameItem("Classic Tic Tac Toe","Classic-TER","/assets/games/ter/classic_thumbnail.png"))
|
81
|
+
//gameList.push(new gameItem("Street Fighter","SFIGTHER","/assets/games/sfighter/thumbnail.png"))
|
82
|
+
|
83
|
+
var showGames = function(slug,gameItem){
|
84
|
+
if((typeof gameItem == 'undefined')||(gameItem==null)){
|
85
|
+
if (gameList.length > 0) {
|
86
|
+
gameItem = gameList[0]
|
87
|
+
} else {
|
88
|
+
gameItem = new gameItem("No games available","None","")
|
89
|
+
}
|
90
|
+
}
|
91
|
+
var template = generateGameSelectionTemplate(slug,gameItem)
|
92
|
+
setVideoBoxContent(slug,template);
|
93
|
+
setShowGamesButtonsFunction();
|
94
|
+
}
|
95
|
+
|
96
|
+
var onGameSelected = function (slug,game){
|
97
|
+
PRESENCE.GAME.requestUserToPlay(slug, game);
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
|
69
102
|
///////////////////////////////
|
70
103
|
// INTERFACE HELP METHODS //
|
71
104
|
///////////////////////////////
|
72
105
|
|
73
|
-
var
|
74
|
-
|
106
|
+
var generateGameSelectionTemplate = function (slug,gameItem) {
|
107
|
+
var template =
|
108
|
+
"<div class=\"game-choices\">" +
|
109
|
+
|
110
|
+
"<div class=\"game-choice-buttonLeft\">" +
|
111
|
+
"<a class=\"game-choice-linkLeft\">" +
|
112
|
+
"<img class=\"game-button-img\" src=\"/assets/btn/group_left.png\" >" +
|
113
|
+
"</a>" +
|
114
|
+
"</div>" +
|
115
|
+
|
116
|
+
"<div class=\"game-choice\">" +
|
117
|
+
"<a class=\"game-choice-link\" slug=" + slug + " choice=\"" + gameItem.choice + "\" >" +
|
118
|
+
"<img class=\"game-choice-img\" src=\"" + gameItem.thumbnail + "\" >" +
|
119
|
+
"<p class=\"game-name\">" + gameItem.name + " </p>" +
|
120
|
+
"</a>" +
|
121
|
+
"</div>" +
|
122
|
+
|
123
|
+
"<div class=\"game-choice-buttonRight\">" +
|
124
|
+
"<a class=\"game-choice-linkRight\">" +
|
125
|
+
"<img class=\"game-button-img\" src=\"/assets/btn/group_right.png\" >" +
|
126
|
+
"</a>" +
|
127
|
+
"</div>" +
|
128
|
+
|
129
|
+
"</div>"
|
130
|
+
return template;
|
131
|
+
}
|
132
|
+
|
133
|
+
var setShowGamesButtonsFunction = function(){
|
134
|
+
$(".game-choice-link").click(function(event) {
|
135
|
+
var choice = $(this).attr("choice")
|
136
|
+
var slug = $(this).attr("slug")
|
137
|
+
var mygame = P.GAME.FACTORY.getGame(slug,choice);
|
138
|
+
onGameSelected(slug,mygame)
|
139
|
+
});
|
140
|
+
|
141
|
+
$(".game-choice-linkLeft").click(function(event) {
|
142
|
+
var gameChoice = $(event.target).parent().parent().parent().find(".game-choice-link")
|
143
|
+
var slug = gameChoice.attr("slug")
|
144
|
+
var choice = gameChoice.attr("choice")
|
145
|
+
var newGameItem = getPreviousGameItem(choice)
|
146
|
+
showGames(slug,newGameItem);
|
147
|
+
});
|
148
|
+
|
149
|
+
$(".game-choice-linkRight").click(function(event) {
|
150
|
+
var gameChoice = $(event.target).parent().parent().parent().find(".game-choice-link")
|
151
|
+
var slug = gameChoice.attr("slug")
|
152
|
+
var choice = gameChoice.attr("choice")
|
153
|
+
var newGameItem = getNextGameItem(choice)
|
154
|
+
showGames(slug,newGameItem);
|
155
|
+
});
|
156
|
+
}
|
157
|
+
|
158
|
+
var getNextGameItem = function(actualChoice){
|
159
|
+
var nextGameItem=null;
|
160
|
+
$.each(gameList, function(index, value) {
|
161
|
+
if(value.choice == actualChoice){
|
162
|
+
if(index==gameList.length-1){
|
163
|
+
nextGameItem = gameList[0]
|
164
|
+
} else {
|
165
|
+
nextGameItem = gameList[index+1];
|
166
|
+
}
|
167
|
+
}
|
168
|
+
});
|
169
|
+
return nextGameItem;
|
170
|
+
}
|
171
|
+
|
172
|
+
var getPreviousGameItem = function(actualChoice){
|
173
|
+
var nextGameItem=null;
|
174
|
+
$.each(gameList, function(index, value) {
|
175
|
+
if(value.choice == actualChoice){
|
176
|
+
if(index==0){
|
177
|
+
nextGameItem = gameList[gameList.length-1]
|
178
|
+
} else {
|
179
|
+
nextGameItem = gameList[index-1];
|
180
|
+
}
|
181
|
+
}
|
182
|
+
});
|
183
|
+
return nextGameItem;
|
184
|
+
}
|
185
|
+
|
186
|
+
var showGameInvitation = function(slug,game){
|
187
|
+
var title = "<p class=\"game-info\">" + I18n.t("chat.game.call", {name: getNameFromSlug(slug), game: game.name}) + " </p>";
|
75
188
|
var msg = title + "<p class=\"game-request\"> <a class=\"gameButton\" slug=\""+slug+"\" value=\"yes\">" + I18n.t("chat.game.accept") + "</a> -"
|
76
189
|
+ " <a class=\"gameButton\" slug=\""+slug+"\" value=\"no\">" + I18n.t("chat.game.deny") + "</a> </p>";
|
77
190
|
setVideoBoxContent(slug,msg);
|
@@ -95,40 +208,17 @@ PRESENCE.GAME.INTERFACE = (function(P,$,undefined){
|
|
95
208
|
$(getChatBoxButtonForSlug(slug,"video")).show();
|
96
209
|
}
|
97
210
|
|
98
|
-
|
99
|
-
|
100
|
-
//////////////////////
|
101
|
-
// DEBUG METHODS //
|
102
|
-
//////////////////////
|
103
|
-
|
104
|
-
var generateDefaultGame = function(guest_slug){
|
105
|
-
var player1 = new PRESENCE.GAME.player(user_slug,user_name)
|
106
|
-
var player2 = new PRESENCE.GAME.player(guest_slug,getNameFromSlug(guest_slug))
|
107
|
-
var localPlayers = [player1,player2]
|
108
|
-
var localOptions = new Array();
|
109
|
-
localOptions['theme']="Modern";
|
110
|
-
var mygame = new PRESENCE.GAME.game("TER","Tres en Raya",localPlayers,localOptions)
|
111
|
-
return mygame;
|
211
|
+
var play = function(){
|
212
|
+
$(".chat-gamesthick").css("display","block");
|
112
213
|
}
|
113
|
-
|
114
|
-
|
214
|
+
|
115
215
|
return {
|
116
216
|
pickGamesButton: pickGamesButton,
|
117
217
|
updateInterfaceAfterGameRequestReceived: updateInterfaceAfterGameRequestReceived,
|
118
218
|
updateInterfaceBeforeStartGame: updateInterfaceBeforeStartGame,
|
119
219
|
updateInterfaceAfterFinishGame: updateInterfaceAfterFinishGame,
|
120
220
|
updateInterfaceOnInformationMessage: updateInterfaceOnInformationMessage,
|
121
|
-
|
221
|
+
play: play
|
122
222
|
};
|
123
223
|
|
124
|
-
}) (PRESENCE, jQuery);
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
////////////////////
|
129
|
-
//Interface Events
|
130
|
-
////////////////////
|
131
|
-
|
132
|
-
function play(){
|
133
|
-
$(".chat-gamesthick").css("display","block");
|
134
|
-
}
|
224
|
+
}) (PRESENCE, jQuery);
|