<script>
	import Callout from '$lib/components/Callout.svelte';
</script>

`config/shared.lua` is loaded on both the client and the server. It holds the economy.

## Framework

Which framework dd-cards talks to for player identity and money.

```lua
Framework = 'auto',
```

| Value        | Behaviour                                                       |
| ------------- | -------------------------------------------------------------------- |
| `'auto'`     | Whichever supported framework is started, preferring `qbx_core` |
| `'qbx_core'` | Qbox                                                            |
| `'qb-core'`  | QBCore                                                          |

Leave this on `'auto'` unless you run two frameworks side by side and need to force one.

## Inventory

Which inventory dd-cards uses for the material and card items.

```lua
Inventory = 'auto',
```

| Value            | Behaviour                                                           |
| ----------------- | ------------------------------------------------------------------------ |
| `'auto'`         | Whichever supported inventory is started, preferring `ox_inventory` |
| `'ox_inventory'` | ox_inventory                                                        |
| `'qb-inventory'` | qb-inventory                                                        |

This is independent of `Framework` — running QBCore with ox_inventory is a common and fully
supported combination.

## Items

Item names as they are registered in your inventory.

```lua
Items = {
    box = 'business_card_box',
    card = 'business_card',
},
```

| Key    | Default               | Role                                                         |
| ------ | ------------------------ | ---------------------------------------------------------------- |
| `box`  | `'business_card_box'` | The sealed box handed over at pickup; holds `quantity` cards |
| `card` | `'business_card'`     | A single business card, taken out of a box one at a time     |

Change these only if your item names differ. The names must match your inventory's item list exactly,
or nothing can be bought, consumed or handed out — see [Items & images](/docs/dd-cards/items).

## Materials

Materials a card order consumes, **one unit of each per card**.

```lua
Materials = {
    ink            = { label = 'Ink',            price = 15, item = 'ink' },
    paper_standard = { label = 'Standard Paper', price = 5,  item = 'paper_standard' },
    paper_glossy   = { label = 'Glossy Paper',   price = 12, item = 'paper_glossy' },
    gold_foil      = { label = 'Gold Foil',      price = 40, item = 'gold_foil' },
},
```

| Field   | Meaning                                                                                                                         |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `label` | Name shown in the shop menu and the order summary                                                                               |
| `price` | Base price of one unit. Also what the fabric charges when it has to supply the material itself, before `SuppliedMaterialMarkup` |
| `item`  | Item name in your inventory — must match your item list exactly                                                                 |

`ink` is always required. The two paper entries are the choices offered in the designer, and
`gold_foil` is the optional premium finish.

<Callout type="warning">
Adding entries to this table does **not** add new options to the designer. Prices and labels are
what this table controls.
</Callout>

## JobFee

The fabric's labour. Charged on every order, even when the player brings all their own materials —
this is what they pay for the printing itself.

```lua
JobFee = {
    setup = 25,
    perCard = 5,
},
```

| Key       | Default | Meaning                                     |
| --------- | ------- | ---------------------------------------------- |
| `setup`   | `25`    | Flat fee, once per order regardless of size |
| `perCard` | `5`     | Multiplied by the order quantity            |

A 10-card order costs `setup + perCard * 10` in labour.

## SuppliedMaterialMarkup

Players can order without holding any materials — the fabric supplies whatever they are short and
charges this multiple of the material's base price for it.

```lua
SuppliedMaterialMarkup = 1.5,
```

`1.0` sells materials at cost, `1.5` adds 50%, `2.0` doubles. Raise it to push players towards buying
materials at the shop (or from other players) before ordering. The result is rounded **up** to a
whole number per unit.

## Rush

Rush processing — the player pays extra to have the order ready sooner.

```lua
Rush = {
    enabled = true,
    surchargeMultiplier = 1.5,
},
```

| Key                   | Default | Meaning                                                            |
| ---------------------- | ------- | ------------------------------------------------------------------------ |
| `enabled`             | `true`  | Set `false` to remove the option from the designer entirely        |
| `surchargeMultiplier` | `1.5`   | Multiplies the **job fee**. `1.5` means rush costs 50% more labour |

It deliberately does not multiply material cost — printing faster does not consume more paper.

## Processing

How long an order takes to become collectable, in minutes. The timer starts when the order is
submitted, and the player is notified when it is ready.

```lua
Processing = {
    baseMinutes = 20,
    rushMinutes = 5,
},
```

## BoxQuantity

How many cards one box may contain. This is the range of the quantity slider in the designer, and
the number of times a box can be opened before it is used up.

```lua
BoxQuantity = {
    min = 5,
    max = 25,
},
```

## OrderStatus

Internal order states as stored in the database.

```lua
OrderStatus = {
    PROCESSING = 'processing',
    READY = 'ready',
    COMPLETED = 'completed',
    CANCELLED = 'cancelled',
},
```

<Callout type="danger">
Do not change these. They are written to and read from the `status` column of `dd_card_orders`, so
renaming one breaks every existing order.
</Callout>

## How a price is worked out

The order total is:

```
total = suppliedCost + jobFee   (+ rush surcharge, if selected)

  suppliedCost = for each material:  ceil(price × SuppliedMaterialMarkup) × units the player is short
  jobFee       = JobFee.setup + (JobFee.perCard × quantity)
  rush         = jobFee × (Rush.surchargeMultiplier − 1)
```

Materials the player already carries are **consumed from their inventory** rather than charged for.
Only the shortfall is sold to them.

### Worked example

**15 glossy cards, no foil.** The player is carrying 5 ink and no paper.

| Line              | Required | Owned | Supplied | Unit price            | Cost    |
| ------------------ | -------- | ----- | -------- | ------------------------ | ------- |
| Ink               | 15       | 5     | 10       | `ceil(15 × 1.5)` = 23 | 230     |
| Glossy Paper      | 15       | 0     | 15       | `ceil(12 × 1.5)` = 18 | 270     |
| **Materials**     |          |       |          |                        | **500** |
| Setup fee         |          |       |          |                        | 25      |
| Printing (15 × 5) |          |       |          |                        | 75      |
| **Labour**        |          |       |          |                        | **100** |
| **Total**         |          |       |          |                        | **600** |

The 5 ink they were carrying is taken from their inventory and not billed.

With **rush** selected, labour becomes `100 × 1.5 = 150` — a surcharge of 50 — for a total of
**650**, and the wait drops from 20 minutes to 5. Material cost is untouched.
