2020-10-01 05:30:59 +00:00
|
|
|
# Challenges
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-05 21:11:15 +00:00
|
|
|
Useful functions for dealing with Challenges and implementing their effects:
|
|
|
|
|
|
|
|
- inChall(layer, id): determine if the player is in a given challenge (or another challenge on the same layer that counts as this one)
|
|
|
|
- hasChall(layer, id): determine if the player has completed the challenge
|
2020-10-11 20:42:32 +00:00
|
|
|
- challCompletions(layer, id): determine if the player has completed the challenge
|
2020-10-05 21:11:15 +00:00
|
|
|
- challEffect(layer, id): Returns the current effects of the challenge, if any
|
|
|
|
|
|
|
|
|
2020-10-01 04:08:01 +00:00
|
|
|
Challenges are stored in the following format:
|
|
|
|
|
2020-10-01 19:57:47 +00:00
|
|
|
```js
|
2020-10-01 05:45:05 +00:00
|
|
|
challs: {
|
|
|
|
rows: # of rows
|
|
|
|
cols: # of columns
|
|
|
|
11: {
|
2020-10-03 19:45:47 +00:00
|
|
|
name:() => "Ouch",
|
2020-10-01 05:45:05 +00:00
|
|
|
etc
|
|
|
|
}
|
2020-10-01 05:41:25 +00:00
|
|
|
etc
|
|
|
|
}
|
2020-10-01 19:57:47 +00:00
|
|
|
```
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-01 04:51:07 +00:00
|
|
|
Each challenge should have an id where the first digit is the row and the second digit is the column.
|
2020-10-05 21:11:15 +00:00
|
|
|
Individual Challenges can have these features:
|
2020-10-01 04:08:01 +00:00
|
|
|
|
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-01 04:08:01 +00:00
|
|
|
|
2020-10-01 04:51:07 +00:00
|
|
|
- desc: A description of what makes the challenge a challenge. *You will need to implement these elsewhere*
|
2020-10-07 20:41:45 +00:00
|
|
|
It can also be a function that returns updating text. Can use basic HTML.
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-01 04:51:07 +00:00
|
|
|
- reward: A description of the reward's effect. *You will also have to implement the effect where it is applied.*
|
2020-10-07 20:41:45 +00:00
|
|
|
It can also be a function that returns updating text. Can use basic HTML.
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-01 04:51:07 +00:00
|
|
|
- effect(): **optional**, A function that calculates and returns the current values of any bonuses from the reward.
|
2020-10-07 20:41:45 +00:00
|
|
|
Can return a value or an object containing multiple values. Can use basic HTML.
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-10 03:16:29 +00:00
|
|
|
- effectDisplay(): **optional**, A function that returns a display of the current effects of the reward with
|
2020-10-01 04:51:07 +00:00
|
|
|
formatting. Default behavior is to just display the a number appropriately formatted.
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-01 04:51:07 +00:00
|
|
|
- goal: A Decimal for the cost of the upgrade. By default, the goal is in basic Points.
|
2020-10-03 19:45:47 +00:00
|
|
|
The goal can also be a function if its value changes.
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-01 05:30:59 +00:00
|
|
|
- unl(): A function returning a bool to determine if the challenge is visible or not.
|
2020-10-01 04:51:07 +00:00
|
|
|
|
|
|
|
- onComplete() - **optional**, this function will be called when the challenge is completed when previously incomplete.
|
|
|
|
|
|
|
|
- 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.
|
|
|
|
|
|
|
|
By default, challenges use basic Points for the goal. You can change that using these features.
|
|
|
|
- currencyDisplayName: **optional**, the name to display for the currency for the goal
|
|
|
|
- currencyInternalName: **optional**, the internal name for that currency
|
|
|
|
- currencyLayer: **optional**, the internal name of the layer that currency is stored in.
|
|
|
|
If it's part of a layer, omit.
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-11 20:42:32 +00:00
|
|
|
- completionLimit: **optional**, the amount of times you can complete this challenge. Default is 1 completion.
|
|
|
|
|
2020-10-10 03:26:27 +00:00
|
|
|
- style: **Optional**, A CSS object, which affects this challenge.
|
2020-10-01 04:08:01 +00:00
|
|
|
|
2020-10-03 19:45:47 +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 id for this challenge.
|