> 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/files/untitled.md).

# Code snippets

Quick snippets to build paragraph and contents quickly.

## VSCode IDE code snippet prefix list

Currently, the IDE snippet function is only available for VSCode.

| VSCode prefix | Description                                                                                                                                      |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| paragraph     | Template for a basic paragraph object with `name`, `content` and a `choices` array.                                                              |
| choice        | Template for a `choice` object that should be put inside choices array. It contains the choice's `id`, `content` and `nextName`                  |
| item          | Template for an `item` object with `itemName, itemQty, description` and `itemCode` properties.                                                   |
| items         | Template for an array of `item` with one `item` object inside.                                                                                   |
| consequence   | Template for `consequence` object, which has 2 empty arrays `Arrau<item>` and `Array<stat>`. The `consequence` object should be inside a choice. |
| conStat       | Template for a stat object for consequence's stat                                                                                                |
| precondition  | Template for a choice or item's precondition. Has 2 optional property: `Array<item>` and `Array<stat>`                                           |

## Code snippets & mock data

In the section bellow, code snippets are divided into two main criteria:&#x20;

* Bare essentials: a blank template with only essential fields
* Full: a blank template with all possible property for the object.

### Paragraph

{% tabs %}
{% tab title="Bare essentials" %}

```typescript
{
  name: ``,
  content: ``,
  choices: [
    { id: 1, content: ``, nextName: `` },
  ],
},
```

{% endtab %}

{% tab title="with mock data" %}

```typescript
{
  name: `start`,
  content: `Hey that's ${player.playerName}, ${player.pronouns.is} here!`,
  choices: [
    { id: 1, content: `Next!`, nextName: `next-paragraph` },
  ],
},
//prequisite: player's Name and Pornouns must be 
//initialised before this paragraph appears
```

{% endtab %}

{% tab title="Full" %}

```typescript
{
  name: ``,
  content: ``,
  item: [
    { itemName: ``, description: ``, itemQty: -1, itemCode: ``, }
  ],
  choices: [
    { id: 1,
      content: ``,
      nextName: ``,
      precondition:
      {
        item: [
          { 
            itemName: ``, 
            description: ``, 
            itemQty: 1, 
            itemCode: ``, 
          },
        ],
        stat: [{ statName: ``, value: 1,}],
      },
      consequence: {
        item: [
        { itemName: ``, description: ``, itemQty: -1, itemCode: ``, }
        ],
        stat: [
          { statName: ``, value: 1, style: statStyle.show },
          { statName: `hiddenValue`, value: 1, style: statStyle.hide }
        ],
      },
    },
  ],
},
```

{% endtab %}

{% tab title="with mock data" %}

```
```

{% endtab %}
{% endtabs %}

### Choices

{% tabs %}
{% tab title="Bare essentials" %}

```typescript
choices: [
    { 
        id: 1, 
        content: ``, 
        nextName: ``
    },
    { 
        id: 2, 
        content: ``, 
        nextName: ``
    },
],
```

{% endtab %}

{% tab title="with mock data" %}

```typescript
choices: [
    { 
        id: 1, 
        choiceCont: `This choice lead to paragraph with name = 'pet-cat'`, 
        nextName: `pet-cat` 
    },
    { 
        id: 2, 
        choiceCont: `This choice lead to paragraph with name = 'pet-dog'`, 
        nextName: `pet-dog` 
    },
],
```

{% endtab %}

{% tab title="Full" %}

```typescript
choices: [
    { 
      id: 1,
      choiceCont: ``,
      nextid: 1,
      precondition:
      {
        item: [
          { itemName: ``, 
          description: ``, 
          itemQty: 1, 
          itemCode: ``, },
        ],
      },
      consequence: {
        item: [
        { itemName: ``, description: ``, itemQty: -1, itemCode: ``, }
        ],
        stat: [
          { statName: ``, value: 1, style: statStyle.show },
          { statName: `hiddenValue`, value: 1, style: statStyle.hide }
        ],
      },
    },
],
```

{% endtab %}

{% tab title="with mock data" %}

```typescript
choices: [
    { 
      id: 1,
      choiceCont: ``,
      nextid: 1,
      precondition:
      {
        item: [
          { itemName: "key", 
          description: "A small key. You wonder what it's for.", 
          itemQty: 1, 
          itemCode: "key1", },
        ],
      },
      consequence: {
        item: [
          { itemName: "key", 
          description: "A small key. You wonder what it's for.", 
          itemQty: -1, 
          itemCode: "key1", }
        ],
        stat: [
          { statName: 'Athletic', value: 1, style: statStyle.show },
          { statName: `hiddenValue`, value: 1, style: statStyle.hide }
        ],
      },
    }
],
```

{% endtab %}
{% endtabs %}
