# Choice

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](https://uyen18827.gitbook.io/veinif/optional/precondition) 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](https://uyen18827.gitbook.io/veinif/optional/precondition):

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](https://uyen18827.gitbook.io/veinif/optional/consequence):

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](#default).
