Skip to content

Module: Achievements

Table of contents

Functions

Functions

getAchievementsAsync

getAchievementsAsync(): Promise<Achievement[]>

Gets a player's achievements. This method returns all achievements, regardless of whether they are unlocked or not.

Example

Wortal.achievements.getAchievementsAsync()
  .then((achievements) => {
     foreach (const achievement of achievements) {
         if (achievement.isUnlocked) {
             console.log(achievement.name + " is unlocked");
         }
     }
  });

Returns

Promise<Achievement[]>

Promise that resolves to an array of achievements.

Throws

  • NOT_SUPPORTED

unlockAchievementAsync

unlockAchievementAsync(achievementName): Promise<boolean>

Unlocks an achievement for the player. This method will only unlock the achievement if it has not already been unlocked.

Example

Wortal.achievements.unlockAchievementAsync("first_win")
 .then((unlocked) => {
   if (unlocked) {
     console.log("Achievement unlocked");
   } else {
     console.log("Achievement already unlocked");
   }
 });

Parameters

Name Type Description
achievementName string The name of the achievement to unlock.

Returns

Promise<boolean>

Promise that resolves to true if the achievement was unlocked, false if it was already unlocked.

Throws

  • NOT_SUPPORTED
  • INVALID_PARAMS
  • ACHIEVEMENT_NOT_FOUND