view_inventory
Display all items in your inventory to manage equipment and track collected resources for dungeon exploration.
Instructions
インベントリ内のすべてのアイテムを表示します。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| save_key | Yes | セーブキー |
Implementation Reference
- src/tools/player.ts:134-180 (handler)The core logic for `view_inventory` which reads the player data and formats the inventory content string.
export async function viewInventory(saveKey: string): Promise<string> { const data = await storage.load(saveKey); if (!data.player.name) { return "プレイヤーが見つかりません。先に'create_player'を実行してください。"; } const hasEquipment = data.player.inventory.length > 0; const hasItems = (data.player.itemInventory?.length || 0) > 0; if (!hasEquipment && !hasItems) { return "インベントリは空です。"; } let output = `=== インベントリ ===\n\n`; // 装備インベントリ if (hasEquipment) { output += `【装備】 (${data.player.inventory.length}個)\n\n`; const groupedByType: { [key: string]: Equipment[] } = {}; for (const item of data.player.inventory) { if (!groupedByType[item.type]) { groupedByType[item.type] = []; } groupedByType[item.type].push(item); } const typeNames: { [key: string]: string } = { weapon: '武器', shield: '盾', armor: '防具', accessory: 'アクセサリ' }; for (const [type, items] of Object.entries(groupedByType)) { output += `${typeNames[type] || type}:\n`; for (const item of items) { output += ` [${item.id}] ${item.name} [${item.rarity}]\n`; output += ` 攻撃+${item.stats.attack} 防御+${item.stats.defense} 速度+${item.stats.speed} 運+${item.stats.luck}\n`; } output += '\n'; } } // 持ち物インベントリ - src/index.ts:77-88 (registration)Tool registration for `view_inventory` with its schema definition in `src/index.ts`.
name: 'view_inventory', description: 'インベントリ内のすべてのアイテムを表示します。', inputSchema: { type: 'object', properties: { save_key: { type: 'string', description: 'セーブキー', }, }, required: ['save_key'], }, - src/index.ts:326-334 (handler)The switch-case handler in `src/index.ts` that dispatches the `view_inventory` request to the implementation in `playerTools`.
case 'view_inventory': return { content: [ { type: 'text', text: await playerTools.viewInventory(args.save_key as string), }, ], };