FYP Feeds

Achievements and rewards

Programming Production
As mentioned in the previous post, one important step was to implement achievements and rewards. This gives players more reasons to keep playing, as the game focuses on short daily play sessions. Achievements are ideal for keeping players engaged and encouraging them to return to the game.
As the game also focuses on forging bonds with the critter, allowing players to unlock and dress the creature as they like would act as an amplifier to strengthen that bond. For this vertical slice, it was decided not to overdo it with achievements and rewards, but instead keep it simple as a proof of concept.
The achievements in particular turned out to be challenging, as it was decided during development to store them in a separate database, similarly with the rewards. This was done to simplify testing, since if it became necessary to reset the achievements or rewards earned, it would be easier to delete either database rather than add extra code to handle resets or risk deleting the entire main database, which could have resulted in the loss of other critter data.
Knowing this, it was necessary to handle the creation of achievements in a smart way, without adding the logic to every scene where it wasn’t needed. Since achievements were usually created in the achievements scene, the game still needed to ensure that players could earn them even if they only visited the achievements page after unlocking a specific achievement.
public void setAchievementCompleted(string achievementId)
    {
        if(achievementId== "")
        {
            return;
        }

        ids = achievementsDatabase.getAchievementsIDs() ?? new List<string>();

        if(achievementsDatabase==null)
        {
            initialiseDb();
        }
        if (ids.Count==0)
        {
            achievementsDatabase.setAchievementCompletedId(achievementId);
            if(allAchievements!=null&& allAchievements.Count>0)
            {
                foreach (AchievementProgress progress in allAchievements)
                {

                    if (achievementId.Equals(progress.getIsAchivementId()))
                    {
                        progress.setIsUnlocked(true);
                    }
                }
            }

        }
        else
        {
            bool alreadyAchieved = false;
            foreach(string id in ids)
            {
                if(id==achievementId)
                {
                    alreadyAchieved = true;
                    break;
                }
            }
            if(!alreadyAchieved)
            {
                
                achievementsDatabase.setAchievementCompletedId(achievementId);
                if(allAchievements!=null && allAchievements.Count>0)
                {
                    foreach (AchievementProgress progress in allAchievements)
                    {
                        if (achievementId.Equals(progress.getIsAchivementId()))
                        {
                            progress.setIsUnlocked(true);
                        }
                    }
                }

            }

        }
        saveData();
    }