Achievements

Achievements are in-game rewards for performing certain actions. Some are easier to collect than others. Achievements have specific requirements for completion.

**Notice:** Achievements are yet to be added into the game. Details regarding it are subject to change.

## List

### Difficulties

* Easy
	+ This achievement is trivially easy to achieve and does not rely on RNG.
	+ This achievement is usually earned without attempting it, by chance.
* Medium
	+ This achievement could require some RNG, and if so, it should not take too much effort.
	+ Most people should be able to earn it if they try.
* Hard
	+ This achievement is difficult to obtain because it relies on RNG or a very specific event to occur.
* Insanely Difficult
	+ This achievement relies on RNG that is incredibly rare (<0.1%), and most people will not achieve it.
* Impossible
	+ This achievement is unobtainable without cheats.
	+ Achieving this achievement suggests that you cheated.

## Detailed Technial Overview

**Note:** This overview is not finalised as no build of openLife contains achievements yet.

### Achievements object

An object called "achievements", which is global, contains every achievement's completion status as a boolean (True or False). It is in a dict format.

#### Example table of dictionary values and their meaning (abridged)

 freshMeat
 cheated
 swift

### ACHIEVEMENTS object

This is identical to the "achivements" object, but is static and does not change, meaning it can be used for comparison purposes.

### grantAchievement(player, achievement\_id)

This is a function that takes an achievement's ID and checks the following things:

* The player's "cheater" value is set to 1
	+ If so, it returns the string "cheaterDetected"
* If the ID is valid
	+ If it is not, it returns False
* If the achievement has been earned yet
	+ If not, an "Achievment Earned" screen is shown and the achievement is calling saveAchievements()
	+ If yes, it returns the string "achievementAlreadyGranted"

### saveAchivements(achievements)

This function takes the achievements value as a parameter and pickles it to "achievements.dat".

### loadAchievements()

This returnsone of two values:

* None if no valid achievment file exists
* A dict containing the achivements value loaded from "achivements.dat"

### upgradeAchivements(achievments)

If an achivement file's version is too old, this function adds key:value pairs that exist in the current format by comparing the passed achievements to ACHIEVEMENTS. It adds items from ACHIEVMENTS until it both match.

#### Example code (not finalised or tested)

```
def subtractLists(a, b):
    return [elem for elem in a if elem not in b]
        diff = subtractLists(achievements, ACHIEVEMENTS)
        l[fileVersion] = ACHIEVEMENTS[fileVersion]
        for item in diff:
            l[item] = False
        return l
    except:
        return None

```

## History

* Beta 1
	+ During Beta 1's development, it was announced that achievements would come to OpenLife.
	+ They were initially meant to be a Beta 1 feature.
	+ On the 29th April 2023, achievements were postponed due to indecisiveness with regards to when achievements should be added.
		- On this day, a detailed overview of how achievements worked was also added to the **WIki**.