core.components.db module

class core.components.db.JSONDatabase[source]

Bases: object

Handles connecting to the game database for resources such as monsters, stats, etc.

load(directory='all')[source]

Loads all data from JSON files located under our data path.

Parameters:directory (String) – The directory under resources/db/ to load. Defaults to “all”.
Returns:None
load_json(directory)[source]

Loads all JSON items under a specified path.

Parameters:directory (String) – The directory under resources/db/ to look in.
Returns:None
lookup(name, table='monster')[source]

Looks up a monster, technique, item, or npc based on name or id.

Parameters:
  • name (String) – The name of the monster, technique, item, or npc.
  • table (String) – Which index to do the search in. Can be: “monster”, “item”, “npc”, or “technique”.
Return type:

Dict

Returns:

A dictionary from the resulting lookup.

lookup_by_id(id, table='monster')[source]

This is a legacy method from using the sqlite database. You should do this instead by calling JSONDatabase.database[“monster”][id]

Parameters:id (Integer) – The monster ID or technique ID to look up.
Return type:List
Returns:A list of monsters or techniques
lookup_sprite(monster_id, table='sprite')[source]

Looks up a monster’s sprite image paths based on monster ID. NOTE: This method has been deprecated. Use the following instead: JSONDatabase.database[‘monster’][id][‘sprites’]

Parameters:monster_id (Integer) – The monster ID to look up.
Return type:List
Returns:A list of sprites