| 
          define(function (require) { | 
        
        
           | 
              "use strict"; | 
        
        
           | 
          
 | 
        
        
           | 
              var Config = require('config'), | 
        
        
           | 
                  configHelper = require('helpers/config'); | 
        
        
           | 
          
 | 
        
        
           | 
              var hasCocoon = (typeof CocoonJS !== "undefined" && CocoonJS.nativeExtensionObjectAvailable !== false), | 
        
        
           | 
                  constants = {}; | 
        
        
           | 
          
 | 
        
        
           | 
              constants.ACH_REENACTMENT_WIN_21 = 'yourgoogleachievementidhere'; | 
        
        
           | 
              constants.ACH_PUNISHMENT = 'yourgoogleachievementidhere'; | 
        
        
           | 
              constants.ACH_FAILURE = 'yourgoogleachievementidhere'; | 
        
        
           | 
              constants.ACH_WHAT = 'yourgoogleachievementidhere'; | 
        
        
           | 
              constants.ACH_DRAW = 'yourgoogleachievementidhere'; | 
        
        
           | 
              constants.LEADERBOARD = 'yourgoogleleaderboardidhere'; | 
        
        
           | 
          
 | 
        
        
           | 
              if (hasCocoon) { | 
        
        
           | 
                  var gp = CocoonJS.Social.GooglePlayGames; | 
        
        
           | 
                  gp.init({defaultLeaderboard: constants.LEADERBOARD}); | 
        
        
           | 
                  var socialService = gp.getSocialInterface(); | 
        
        
           | 
              } | 
        
        
           | 
          
 | 
        
        
           | 
              return { | 
        
        
           | 
                  constants: constants, | 
        
        
           | 
                  hasCocoon: hasCocoon, | 
        
        
           | 
                  isLoggedIn: function () { | 
        
        
           | 
                      if (!hasCocoon) { | 
        
        
           | 
                          return false; | 
        
        
           | 
                      } | 
        
        
           | 
          
 | 
        
        
           | 
                      return socialService.isLoggedIn(); | 
        
        
           | 
                  }, | 
        
        
           | 
                  login: function (callback) { | 
        
        
           | 
                      if (!hasCocoon) { | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
          
 | 
        
        
           | 
                      try { | 
        
        
           | 
                          socialService.login(callback); | 
        
        
           | 
                      } catch (e) { | 
        
        
           | 
                          console.error("submitAchievement error: " + e.message); | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
                  }, | 
        
        
           | 
                  postScore: function (score) { | 
        
        
           | 
                      if (!hasCocoon || !this.isLoggedIn()) { | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
          
 | 
        
        
           | 
                      var params = new CocoonJS.Social.ScoreParams(null, constants.LEADERBOARD); | 
        
        
           | 
          
 | 
        
        
           | 
                      try { | 
        
        
           | 
                          socialService.submitScore(score, function (error) { | 
        
        
           | 
                              if (error) { | 
        
        
           | 
                                  console.error("submit Score error: " + error.message); | 
        
        
           | 
                              } | 
        
        
           | 
                          }, params); | 
        
        
           | 
                      } catch (e) { | 
        
        
           | 
                          console.error("submitAchievement error: " + e.message); | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
                  }, | 
        
        
           | 
                  showLeaderboard: function (opponent) { | 
        
        
           | 
                      if (!hasCocoon || !this.isLoggedIn()) { | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
          
 | 
        
        
           | 
                      var params = new CocoonJS.Social.ScoreParams(null, constants.LEADERBOARD); | 
        
        
           | 
          
 | 
        
        
           | 
                      try { | 
        
        
           | 
                          socialService.showLeaderboard(function (error) { | 
        
        
           | 
                              if (error) { | 
        
        
           | 
                                  console.error("showLeaderbord error: " + error.message); | 
        
        
           | 
                              } | 
        
        
           | 
                          }, params); | 
        
        
           | 
                      } catch (e) { | 
        
        
           | 
                          console.error("submitAchievement error: " + e.message); | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
                  }, | 
        
        
           | 
                  showAchievements: function () { | 
        
        
           | 
                      if (!hasCocoon || !this.isLoggedIn()) { | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
          
 | 
        
        
           | 
                      try { | 
        
        
           | 
                          socialService.showAchievements(); | 
        
        
           | 
                      } catch (e) { | 
        
        
           | 
                          console.error("submitAchievement error: " + e.message); | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
                  }, | 
        
        
           | 
                  winAchievement: function (achievement) { | 
        
        
           | 
                      if (!hasCocoon || !this.isLoggedIn()) { | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
          
 | 
        
        
           | 
                      try { | 
        
        
           | 
                          socialService.submitAchievement(achievement, function (error) { | 
        
        
           | 
                              if (error) { | 
        
        
           | 
                                  console.error("submitAchievement error: " + error.message); | 
        
        
           | 
                              } | 
        
        
           | 
                          }); | 
        
        
           | 
                      } catch (e) { | 
        
        
           | 
                          console.error("submitAchievement error: " + e.message); | 
        
        
           | 
                          return; | 
        
        
           | 
                      } | 
        
        
           | 
                  } | 
        
        
           | 
              }; | 
        
        
           | 
          }); |