Npc
tibiawikisql.models.npc
¶
Classes:
| Name | Description |
|---|---|
NpcOffer |
Represents an NPC buy or sell offer. |
TaughtSpell |
A spell taught by an NPC. |
NpcSpell |
Represents a spell that a NPC can teach. |
NpcDestination |
Represents a NPC's travel destination. |
RashidPosition |
Represents a Rashid position. |
Npc |
Represents a non-playable character. |
NpcOffer
pydantic-model
¶
Bases: BaseModel
Represents an NPC buy or sell offer.
Show JSON schema:
{
"description": "Represents an NPC buy or sell offer.",
"properties": {
"item_id": {
"title": "Item Id",
"type": "integer"
},
"item_title": {
"title": "Item Title",
"type": "string"
},
"currency_id": {
"title": "Currency Id",
"type": "integer"
},
"currency_title": {
"title": "Currency Title",
"type": "string"
},
"value": {
"title": "Value",
"type": "integer"
}
},
"required": [
"item_id",
"item_title",
"currency_id",
"currency_title",
"value"
],
"title": "NpcOffer",
"type": "object"
}
Fields:
-
item_id(int) -
item_title(str) -
currency_id(int) -
currency_title(str) -
value(int)
TaughtSpell
pydantic-model
¶
Bases: BaseModel
A spell taught by an NPC.
Show JSON schema:
{
"description": "A spell taught by an NPC.",
"properties": {
"spell_title": {
"title": "Spell Title",
"type": "string"
},
"spell_id": {
"title": "Spell Id",
"type": "integer"
},
"knight": {
"title": "Knight",
"type": "boolean"
},
"paladin": {
"title": "Paladin",
"type": "boolean"
},
"druid": {
"title": "Druid",
"type": "boolean"
},
"sorcerer": {
"title": "Sorcerer",
"type": "boolean"
},
"monk": {
"title": "Monk",
"type": "boolean"
},
"price": {
"title": "Price",
"type": "integer"
}
},
"required": [
"spell_title",
"spell_id",
"knight",
"paladin",
"druid",
"sorcerer",
"monk",
"price"
],
"title": "TaughtSpell",
"type": "object"
}
Fields:
NpcSpell
pydantic-model
¶
Bases: RowModel
Represents a spell that a NPC can teach.
Show JSON schema:
{
"description": "Represents a spell that a NPC can teach.",
"properties": {
"npc_id": {
"title": "Npc Id",
"type": "integer"
},
"spell_id": {
"title": "Spell Id",
"type": "integer"
},
"knight": {
"title": "Knight",
"type": "boolean"
},
"paladin": {
"title": "Paladin",
"type": "boolean"
},
"druid": {
"title": "Druid",
"type": "boolean"
},
"sorcerer": {
"title": "Sorcerer",
"type": "boolean"
},
"monk": {
"title": "Monk",
"type": "boolean"
}
},
"required": [
"npc_id",
"spell_id",
"knight",
"paladin",
"druid",
"sorcerer",
"monk"
],
"title": "NpcSpell",
"type": "object"
}
Fields:
insert
¶
insert(conn: Connection | Cursor) -> None
Insert the model into its respective database table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
Connection | Cursor
|
A cursor or connection to the database. |
required |
Source code in tibiawikisql/models/npc.py
NpcDestination
pydantic-model
¶
Bases: BaseModel
Represents a NPC's travel destination.
Show JSON schema:
{
"description": "Represents a NPC's travel destination.",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"price": {
"title": "Price",
"type": "integer"
},
"notes": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Notes"
}
},
"required": [
"name",
"price",
"notes"
],
"title": "NpcDestination",
"type": "object"
}
Fields:
RashidPosition
pydantic-model
¶
Bases: BaseModel
Represents a Rashid position.
Show JSON schema:
{
"description": "Represents a Rashid position.",
"properties": {
"day": {
"title": "Day",
"type": "integer"
},
"x": {
"title": "X",
"type": "integer"
},
"y": {
"title": "Y",
"type": "integer"
},
"z": {
"title": "Z",
"type": "integer"
},
"city": {
"title": "City",
"type": "string"
},
"location": {
"title": "Location",
"type": "string"
}
},
"required": [
"day",
"x",
"y",
"z",
"city",
"location"
],
"title": "RashidPosition",
"type": "object"
}
Fields:
Npc
pydantic-model
¶
Bases: WikiEntry, WithVersion, WithStatus, WithImage, RowModel
Represents a non-playable character.
Show JSON schema:
{
"$defs": {
"NpcDestination": {
"description": "Represents a NPC's travel destination.",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"price": {
"title": "Price",
"type": "integer"
},
"notes": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Notes"
}
},
"required": [
"name",
"price",
"notes"
],
"title": "NpcDestination",
"type": "object"
},
"NpcOffer": {
"description": "Represents an NPC buy or sell offer.",
"properties": {
"item_id": {
"title": "Item Id",
"type": "integer"
},
"item_title": {
"title": "Item Title",
"type": "string"
},
"currency_id": {
"title": "Currency Id",
"type": "integer"
},
"currency_title": {
"title": "Currency Title",
"type": "string"
},
"value": {
"title": "Value",
"type": "integer"
}
},
"required": [
"item_id",
"item_title",
"currency_id",
"currency_title",
"value"
],
"title": "NpcOffer",
"type": "object"
},
"TaughtSpell": {
"description": "A spell taught by an NPC.",
"properties": {
"spell_title": {
"title": "Spell Title",
"type": "string"
},
"spell_id": {
"title": "Spell Id",
"type": "integer"
},
"knight": {
"title": "Knight",
"type": "boolean"
},
"paladin": {
"title": "Paladin",
"type": "boolean"
},
"druid": {
"title": "Druid",
"type": "boolean"
},
"sorcerer": {
"title": "Sorcerer",
"type": "boolean"
},
"monk": {
"title": "Monk",
"type": "boolean"
},
"price": {
"title": "Price",
"type": "integer"
}
},
"required": [
"spell_title",
"spell_id",
"knight",
"paladin",
"druid",
"sorcerer",
"monk",
"price"
],
"title": "TaughtSpell",
"type": "object"
}
},
"description": "Represents a non-playable character.",
"properties": {
"image": {
"anyOf": [
{
"format": "binary",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Image"
},
"status": {
"title": "Status",
"type": "string"
},
"version": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Version"
},
"article_id": {
"title": "Article Id",
"type": "integer"
},
"title": {
"title": "Title",
"type": "string"
},
"timestamp": {
"format": "date-time",
"title": "Timestamp",
"type": "string"
},
"name": {
"title": "Name",
"type": "string"
},
"gender": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Gender"
},
"races": {
"items": {
"type": "string"
},
"title": "Races",
"type": "array"
},
"jobs": {
"items": {
"type": "string"
},
"title": "Jobs",
"type": "array"
},
"location": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Location"
},
"subarea": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Subarea"
},
"city": {
"title": "City",
"type": "string"
},
"x": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "X"
},
"y": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Y"
},
"z": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Z"
},
"sell_offers": {
"items": {
"$ref": "#/$defs/NpcOffer"
},
"title": "Sell Offers",
"type": "array"
},
"buy_offers": {
"items": {
"$ref": "#/$defs/NpcOffer"
},
"title": "Buy Offers",
"type": "array"
},
"destinations": {
"items": {
"$ref": "#/$defs/NpcDestination"
},
"title": "Destinations",
"type": "array"
},
"teaches": {
"items": {
"$ref": "#/$defs/TaughtSpell"
},
"title": "Teaches",
"type": "array"
}
},
"required": [
"status",
"version",
"article_id",
"title",
"timestamp",
"name",
"gender",
"location",
"subarea",
"city",
"x",
"y",
"z"
],
"title": "Npc",
"type": "object"
}
Fields:
-
image(bytes | None) -
status(str) -
version(str | None) -
article_id(int) -
title(str) -
timestamp(datetime) -
name(str) -
gender(str | None) -
races(list[str]) -
jobs(list[str]) -
location(str | None) -
subarea(str | None) -
city(str) -
x(int | None) -
y(int | None) -
z(int | None) -
sell_offers(list[NpcOffer]) -
buy_offers(list[NpcOffer]) -
destinations(list[NpcDestination]) -
teaches(list[TaughtSpell])
destinations
pydantic-field
¶
destinations: list[NpcDestination]
Places where the NPC can travel to.
insert
¶
insert(conn: Connection | Cursor)
Insert the model into its respective database table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
Connection | Cursor
|
A cursor or connection to the database. |
required |
Source code in tibiawikisql/models/npc.py
get_one_by_field
classmethod
¶
get_one_by_field(
conn: Connection | Cursor,
field: str,
value: Any,
use_like: bool = False,
) -> Self | None
Get a single element matching the field's value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
Connection | Cursor
|
A connection or cursor of the database. |
required |
field
|
str
|
The field to filter with. |
required |
value
|
Any
|
The value to look for. |
required |
use_like
|
bool
|
Whether to use |
False
|
Returns:
| Type | Description |
|---|---|
Self | None
|
The object found, or |
Raises:
| Type | Description |
|---|---|
ValueError
|
The specified field doesn't exist in the table. |