Einharr / SeedshipRelaunchWeb

4 stars 2 forks source link

Unlock Achievement function? #5

Open alexjyong opened 2 years ago

alexjyong commented 2 years ago

I see a lot of code like this: https://github.com/Einharr/SeedshipRelaunchWeb/blob/4c3405af0f7f7878b7bef722eba3262f822e70ce/data/eventsFunc.js#L1873


damageApply(choDevice, curEvent.damageTaken, "damage");
                    if (options.platform == "Android") {
                      var data = {
                        achievementId: "CgkIya77kP0DEAIQGQ"
                        //GoodNews
                      };
                      cordova.plugins.playGamesServices.unlockAchievement(data, function () {
                        // On success
                      }, function () {
                        // On error
                      });
                    };

Could probably be combined into a function, the code that repeats over. I have an idea. Maybe something like


if (options.platfom=="Android") {
unlockAchievement(CgkIya77kP0DEAIQGQ");
}

function unlockAchievement(achievementID){

   cordova.plugins.playGamesServices.unlockAchievement(data, function () {
                        // On success
                      }, function () {
                        // On error
                      });

}

Much less code.

Einharr commented 2 years ago

Yep, it's definitely good idea. Not the most urgent one, since it's optimization and refactoring issue, not a bug. But it should be eventually done.