1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-24 01:11:46 +00:00
The-Modding-Tree/docs/upgrades.md

66 lines
3.5 KiB
Markdown
Raw Normal View History

2020-10-01 05:30:59 +00:00
# Upgrades
Useful functions for dealing with Upgrades and implementing their effects:
- hasUpgrade(layer, id): determine if the player has the upgrade
- upgradeEffect(layer, id): Returns the current effects of the upgrade, if any
2020-10-19 23:52:52 +00:00
- buyUpgrade(layer, id): Buys an upgrade directly (if affordable)
2020-10-26 20:45:22 +00:00
Hint: Basic point gain is calculated in [mod.js](/js/mod.js)'s "getPointGen" function.
2020-10-15 01:43:16 +00:00
Upgrades are stored in the following format:
```js
2020-10-26 20:45:22 +00:00
upgrades: {
rows: # of rows,
cols: # of columns,
11: {
description: "Blah",
cost: new Decimal(100),
2020-10-01 05:41:25 +00:00
etc
2020-10-26 20:45:22 +00:00
},
etc
}
```
Each upgrade should have an id where the first digit is the row and the second digit is the column.
2020-10-26 20:45:22 +00:00
Individual upgrades can have these features:
2020-10-26 20:45:22 +00:00
- title: **optional**. Displayed at the top in a larger font. It can also be a function that returns updating text. Can use basic HTML.
2020-10-03 19:45:47 +00:00
2020-10-26 20:45:22 +00:00
- description: A description of the upgrade's effect. *You will also have to implement the effect where it is applied.* It can also be a function that returns updating text. Can use basic HTML.
2020-10-26 20:45:22 +00:00
- effect(): **optional**. A function that calculates and returns the current values of any bonuses from the upgrade. Can return a value or an object containing multiple values.
- effectDisplay(): **optional**. A function that returns a display of the current effects of the upgrade with formatting. Default displays nothing. Can use basic HTML.
2020-11-29 21:28:24 +00:00
- fullDisplay(): **OVERRIDE**. Overrides the other displays and descriptions, and lets you set the full text for the upgrade. Can use basic HTML.
- cost: A Decimal for the cost of the upgrade. By default, upgrades cost the main prestige currency for the layer.
2020-10-26 20:45:22 +00:00
- unlocked(): **optional**. A function returning a bool to determine if the upgrade is visible or not. Default is unlocked.
2020-11-29 21:28:24 +00:00
- onPurchase(): **optional**. This function will be called when the upgrade is purchased. Good for upgrades like "makes this layer act like it was unlocked first".
2020-10-26 20:45:22 +00:00
- style: **optional**. Applies CSS to this upgrade, in the form of an object where the keys are CSS attributes, and the values are the values for those attributes (both as strings).
2020-10-26 20:45:22 +00:00
- layer: **assigned automagically**. It's the same value as the name of this layer, so you can do `player[this.layer].points` or similar.
- id: **assigned automagically**. It's the "key" which the upgrade was stored under, for convenient access. The upgrade in the example's id is 11.
2020-10-16 15:39:39 +00:00
By default, upgrades use the main prestige currency for the layer. You can include these to change them (but it needs to be a Decimal):
2020-10-26 20:45:22 +00:00
- currencyDisplayName: **optional**. The name to display for the currency for the upgrade.
- currencyInternalName: **optional**. The internal name for that currency.
2020-10-07 20:41:45 +00:00
2020-10-26 20:45:22 +00:00
- currencyLayer: **optional**. The internal name of the layer that currency is stored in. If it's not in a layer (like Points), omit. If it's not stored directly in a layer, instead use the next feature.
2020-10-26 20:45:22 +00:00
- currencyLocation: **optional**. If your currency is stored in something inside a layer (e.g. a buyable's amount), you can access it this way. This is a function returning the object in "player" that contains the value (like `player[this.layer].buyables`)
2020-11-29 21:28:24 +00:00
If you want to do something more complicated like upgrades that cost two currencies, you can override the purchase system with these (and you need to use fullDisplay as well)
2020-11-30 20:03:26 +00:00
- canAfford(): **OVERRIDE**, a function determining if you are able to buy the upgrade
2020-11-29 21:28:24 +00:00
2020-11-30 20:03:26 +00:00
- pay(): **OVERRIDE**, a function that reduces your currencies when you buy the upgrade