aboutsummaryrefslogtreecommitdiff
path: root/building_guide/bank.md
blob: acf9954cd0f52e36b8540f695f3928eb9386a930 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Bank System

The bank system allows players to store items permanently, freeing up inventory space.

## Objects

### bank_booth

A bank terminal that players can interact with. Has no special behavior — the `bank` command checks for any `bank_booth` object in the room. (**The filename is the ID** — `bank_booth.yaml` → `bank_booth`; no `id:` field.)

```yaml
name: bank booth
color: "E2"
description: "..."
inroom_description: "A bank booth is set into the wall."
```

To place a bank booth in a room, add it to the room's `objects:` list:

```yaml
objects:
  - id: bank_booth
```

## Commands

| Command | Description |
|---------|-------------|
| `bank` | Opens bank interface (requires bank booth in room) |
| `use bank` | Same as `bank` |

### Bank Interface Commands

| Command | Description |
|---------|-------------|
| `deposit <item>` | Move item from inventory to bank |
| `deposit all` | Deposit entire inventory |
| `withdraw <item>` | Move item from bank to inventory |
| `browse` / `list` | Show bank contents |
| `leave` | Exit bank interface |

## Implementation

### Session State

`StateBank` (defined in `internal/net/server.go`) is the session state for the bank interface. Input is routed through `handleBankInput` in `internal/game/cmd_bank.go`.

### Player Storage

Bank items are stored in the `Player.Bank` field (`map[int]*InventorySlot`), saved in character YAML. Bank slots are sequential and reuse freed slots. There is no slot limit.

### Command Dispatch

- `bank` is classified as `ClassActive` in `classifyCommand()`
- `bank` case in `executeCommand()` calls `doBank(sess)`
- `doUse()` checks for `"bank"` or `"bank booth"` targets and routes to `doBank()`
- `doBank()` checks for a `bank_booth` object in the current room
- `handleBankInput()` dispatches deposit/withdraw/browse/leave commands

### Data Files

| File | Purpose |
|------|---------|
| `data/objects/bank_booth.yaml` | Bank booth object definition |
| `data/help/bank.yaml` | Help topic for the bank system |

Default bank booth locations: Town Square (room 1), Forge (room 12).