> For the complete documentation index, see [llms.txt](https://uyen18827.gitbook.io/veinif/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://uyen18827.gitbook.io/veinif/components/choice.md).

# Choice

Choices are an integral part of a paragraph. Quite important in a Choice-based game too!

Upon clicking on a choice, the player is lead to a the next predefined paragraph.

## Interface

Bellow is the interface - the structure that all choices conform to.

```typescript
interface Choices {
    id: number;
    choiceCont: string,
    nextid: number;
    precondition?: Precondition;
    style?: string; //next paragraph's appearance's style
    consequence?: Consequence;
}
```

### Required fields

All choices must have:

* an `id` that's unique within the scope of the array contain the choice,&#x20;
* `content` that describes the choice&#x20;
* and specify the paragraph id - `nextid` that the choice will lead to.

### Optional fields

Choices can have:

* `style` - determine update style of the next paragraph lead by the choice.
* `precondition` -  [an array of conditions](/veinif/optional/precondition.md) that must be met prior to the appearance of the choice.
* `consequence` - players loose or gain items, increase or decrease a stat to proceed with a choice.

Optional fields are marked with an exclamation mark `?` on the interface.

Gaining item through a Choice's Consequence vs picking items up on a Paragraph:

Consequence will lead the player to another paragraph, while picking up an item on a paragraph will not.

## Behaviour

### Default:

By default, clicking on a choice updates the paragraph to the one with id specifies in `nextid` field.

### With [precondition](/veinif/optional/precondition.md):

Precondition will be checked before the choice appears.&#x20;

If precondition check fails, the choice will...

* be greyed out,&#x20;
* prevented from performing its default behaviour&#x20;
* and reason as to why the check failed will be shown to the player.

If precondition check pass, the choice will perform its default behaviour.

### With [consequence](/veinif/optional/consequence.md):

Depends on the author's code, a choice with consequence will do one or all of the following:

* player loose a specified number of item(s).
* player gain a specified number of item(s).
* player loose a specified number of stat points.
* player gain a specified number of stat points.
* player gain an entirely new stat and its points.

Consequence does not prevent a choice from performing its [default behaviour](/veinif/components/choice.md#default).
