1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-30 11:51:50 +00:00
The-Modding-Tree/docs/challenges.md

81 lines
4.7 KiB
Markdown
Raw Normal View History

2020-10-01 05:30:59 +00:00
# Challenges
2020-11-30 20:03:26 +00:00
Challenges can have fully customizable win conditions. Useful functions for dealing with Challenges and implementing their effects:
2020-10-26 20:45:22 +00:00
- inChallenge(layer, id): determine if the player is in a given challenge (or another challenge on the same layer that counts as this one).
- hasChallenge(layer, id): determine if the player has completed the challenge.
- challengeCompletions(layer, id): determine how many times the player completed the challenge.
- maxedChallenge(layer, id): determines if the player has reached the maximum completions.
2020-10-26 20:45:22 +00:00
- challengeEffect(layer, id): Returns the current effects of the challenge, if any.
Challenges are stored in the following format:
```js
2020-10-26 20:45:22 +00:00
challenges: {
11: {
name: "Ouch",
challengeDescription: "description of ouchie",
2021-05-10 21:37:29 +00:00
canComplete: function() {return player.points.gte(100)},
2020-10-01 05:41:25 +00:00
etc
2020-10-26 20:45:22 +00:00
},
etc
}
```
2021-05-13 05:44:40 +00:00
Usually, each challenge 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 Challenges can have these features:
2020-10-07 20:41:45 +00:00
- name: Name of the challenge, can be a string or a function. Can use basic HTML.
2020-10-26 20:45:22 +00:00
- challengeDescription: A description of what makes the challenge a challenge. *You will need to implement these elsewhere.* It can also be a function that returns updating text. Can use basic HTML.
2020-11-30 20:03:26 +00:00
- goalDescription: A description of the win condition for the challenge. It can also be a function that returns updating text.
Can use basic HTML. (Optional if using the old goal system)
- canComplete(): A function that returns true if you meet the win condition for the challenge. Returning a number will allow bulk completing the challenge.
(Optional if using the old goal system)
2020-11-30 20:03:26 +00:00
2020-10-26 20:45:22 +00:00
- rewardDescription: A description of the reward'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.
- rewardEffect(): **optional**. A function that calculates and returns the current values of any bonuses from the reward. Can return a value or an object containing multiple values. Can use basic HTML.
- rewardDisplay(): **optional**. A function that returns a display of the current effects of the reward with formatting. Default behavior is to just display the a number appropriately formatted.
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 challenge. Can use basic HTML.
2020-10-26 20:45:22 +00:00
- unlocked(): **optional**. A function returning a bool to determine if the challenge is visible or not. Default is unlocked.
2020-10-26 20:45:22 +00:00
- onComplete() - **optional**. this function will be called when the challenge is completed when previously incomplete.
- onEnter() - **optional**. this function will be called when entering the challenge
- onExit() - **optional**. this function will be called when exiting the challenge in any way
2020-10-26 20:45:22 +00:00
- countsAs: **optional**. If a challenge combines the effects of other challenges in this layer, you can use this. An array of challenge ids. The player is effectively in all of those challenges when in the current one.
2020-10-26 20:45:22 +00:00
- completionLimit: **optional**. the amount of times you can complete this challenge. Default is 1 completion.
2020-10-26 20:45:22 +00:00
- style: **optional**. Applies CSS to this challenge, in the form of an object where the keys are CSS attributes, and the values are the values for those attributes (both as strings).
2021-05-14 19:32:20 +00:00
- marked: **optional** Adds a mark to the corner of the challenge. If it's "true" it will be a star, but it can also be an image URL. By default, if the challenge has multiple completions, it will be starred at max completions.
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
2020-10-26 20:45:22 +00:00
- id: **assigned automagically**. It's the "key" which the challenge was stored under, for convenient access. The challenge in the example's id is 11.
2020-10-11 20:42:32 +00:00
2020-11-30 20:03:26 +00:00
The old goal system uses these features:
- goal: **deprecated**, A Decimal for the amount of currency required to beat the challenge. By default, the goal is in basic Points. The goal can also be a function if its value changes.
- currencyDisplayName: **deprecated**. the name to display for the currency for the goal
2020-11-30 20:03:26 +00:00
- currencyInternalName: **deprecated**. the internal name for that currency
2020-10-03 19:45:47 +00:00
2020-11-30 20:03:26 +00:00
- currencyLayer: **deprecated**. the internal name of the layer that currency is stored in. If it's not in a layer, omit. If it's not stored directly in a layer, instead use the next feature.
2020-11-29 21:28:24 +00:00
2020-11-30 20:03:26 +00:00
- currencyLocation(): **deprecated**. 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