SL2 Analyzer
Read a FromSoftware .sl2 save and report what is in it
Loading...
Searching...
No Matches
sl2.itemdb Namespace Reference

Functions

 _ids (value)
 Ids for one table entry.
 
 load_item_db (db_dir, flat, files)
 Load item-name tables for a game family.
 
 merge_qty (items)
 Collapse duplicate stackable items into one line, summing counts, in first-seen order.
 
 load_scan_db (db_dir, files, refine=None)
 Load an id-scan database: per-category JSON of {name: id}, flattened to {id: (name, category)}.
 

Variables

dict DS2_DB_FILES
 DS2 tables: filename stem to category.
 
dict DS1_DB_FILES
 DS1 (DSR and PtDE) tables.
 

Detailed Description

Item-name databases. Three id schemes across the four games — see the db_*/
folders and CLAUDE.md for why DS2 is id-keyed and the others are not.

Function Documentation

◆ _ids()

sl2.itemdb._ids (   value)
protected

Ids for one table entry.

A name whose value is a LIST owns several ids.

The tables are name-keyed, so one name can normally hold one id — which silently dropped every duplicate the game really ships (DS3 has one "Cinders of a Lord" per lord, DS1 has a base and an alternate-path row under one name). A list value keeps them all; a bare value is the ordinary single-id case.

Definition at line 46 of file itemdb.py.

Referenced by sl2.itemdb.load_item_db(), and sl2.itemdb.load_scan_db().

Here is the caller graph for this function:

◆ load_item_db()

sl2.itemdb.load_item_db (   db_dir,
  flat,
  files 
)

Load item-name tables for a game family.

Parameters
db_dirFolder holding the JSON tables.
flatTrue for DS2 (one id-to-(name,category) dict); False for DS1 (a dict per category).
filesThe filename-stem to category mapping to load.
Returns
The lookup structure, or an empty container if the folder is missing.

Definition at line 57 of file itemdb.py.

References sl2.itemdb._ids().

Here is the call graph for this function:

◆ merge_qty()

sl2.itemdb.merge_qty (   items)

Collapse duplicate stackable items into one line, summing counts, in first-seen order.

Parameters
itemsA list of (name, qty) pairs.
Returns
A list of (name, total_qty).

Definition at line 89 of file itemdb.py.

◆ load_scan_db()

sl2.itemdb.load_scan_db (   db_dir,
  files,
  refine = None 
)

Load an id-scan database: per-category JSON of {name: id}, flattened to {id: (name, category)}.

Parameters
db_dirFolder of category JSON files.
filesFilename-stem to category mapping.
refineOptional (id, cat) -> cat hook, used to split DS3's one goods file into the finer categories the render prints.
Returns
The flat lookup, or {} if the folder is absent.

Definition at line 107 of file itemdb.py.

References sl2.itemdb._ids().

Here is the call graph for this function:

Variable Documentation

◆ DS2_DB_FILES

dict sl2.itemdb.DS2_DB_FILES
Initial value:
1= {
2 "weapons": "weapons",
3 "armors": "armors",
4 "rings": "rings",
5 "spells": "spells",
6 "key": "keys",
7 "bolts": "bolts",
8 "upgrade": "upgrade",
9 "consumables": "consumables",
10 "online": "online",
11 "emotes": "emotes",
12 "bosssouls": "bosssouls",
13}

DS2 tables: filename stem to category.

Ids are unique across categories. Categories are finer than the game's raw tabs so the output can mirror the in-game menu: consumables, trade goods, emotes and boss souls each stand alone.

Definition at line 11 of file itemdb.py.

◆ DS1_DB_FILES

dict sl2.itemdb.DS1_DB_FILES
Initial value:
1= {
2 "MeleeWeapons": "weapons",
3 "Armor": "armors",
4 "Rings": "rings",
5 "Consumables": "goods",
6 "Spells": "spells",
7}

DS1 (DSR and PtDE) tables.

Ids repeat across categories, so lookups stay category-scoped and the slot type decides which table to use. Spells are stored as ordinary goods by the game (Soul Arrow is good 3000), but they are kept in their own file so they render under their own heading like DS2/DS3 — the slot type cannot tell them apart, the id range can.

Definition at line 31 of file itemdb.py.