clickercookie / clickercookie.github.io

A totally original game about clicking a cookie
GNU General Public License v3.0
3 stars 0 forks source link

New data system for upgrades #22

Open FifthTundraG opened 4 months ago

FifthTundraG commented 4 months ago

Instead of the very array-oriented version of our current upgrade system, this new one aims to be more easily extensible and more simple to understand.

Now, upgrades will be stored as an array of objects, with each object containing the data for its upgrade. Below is an example of the implementation.

// the description of almost every upgrade is the same, but just in case we want to add more upgrades in the future
// a "desc" field has been added to the upgrades array. Most upgrade will just reference a string in this array
// that correlates to the upgrade it's associated with, though.
upgrades.defaultUpgradeDescriptions = [
    `Multiplys Keyboard and clicking ${personalization.currentClicked.toLowerCase()} production by 2`,
    "Multiplys Grandpa production by 2"
    // so on, so forth
]

upgrades.data = [
    { // the "id" would be 0 because that's the index in the array
        name: "Reinforced Keys",
        quote: "press harder",
        price: 100,
        img: "reinforced-keys.png",
        desc: defaultUpgradeDescriptions[0],
        building: keyboard, // not sure exactly how buffing the building will work, maybe passing the instance into this will work?
        unlocked: false,
        bought: false
    }
]