game
pokelance.ext.game
⚓︎
Game(client)
⚓︎
Bases: BaseExtension
Extension for game related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
cache |
Game
|
The cache to use for caching resources. |
Initializes the extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
HttpClient
|
The client to use for requests. |
required |
Source code in pokelance/ext/_base.py
Python | |
---|---|
fetch_generation(name)
async
⚓︎
Fetches a generation from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the generation. |
required |
Returns:
Type | Description |
---|---|
Generation
|
The generation if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the generation is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... generation = await client.game.fetch_generation(1)
... print(generation.id)
... await client.close()
>>> asyncio.run(main())
1
Source code in pokelance/ext/game.py
fetch_pokedex(name)
async
⚓︎
Fetches a pokedex from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokedex. |
required |
Returns:
Type | Description |
---|---|
Pokedex
|
The pokedex if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the pokedex is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pokedex = await client.game.fetch_pokedex(1)
... print(pokedex.region)
... await client.close()
>>> asyncio.run(main())
None
Source code in pokelance/ext/game.py
fetch_version(name)
async
⚓︎
Fetches a version from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the version. |
required |
Returns:
Type | Description |
---|---|
Version
|
The version if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the version is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... version = await client.game.fetch_version(1)
... print(version.name)
... await client.close()
>>> asyncio.run(main())
red
Source code in pokelance/ext/game.py
fetch_version_group(name)
async
⚓︎
Fetches a version group from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the version group. |
required |
Returns:
Type | Description |
---|---|
VersionGroup
|
The version group if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the version group is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... version_group = await client.game.fetch_version_group(1)
... print(version_group.id)
... await client.close()
>>> asyncio.run(main())
1
Source code in pokelance/ext/game.py
get_generation(name)
⚓︎
Gets a generation from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the generation. |
required |
Returns:
Type | Description |
---|---|
Optional[Generation]
|
The generation if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the generation is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> generation = client.game.get_generation(1)
>>> generation.id
1
Source code in pokelance/ext/game.py
get_message(case, data)
staticmethod
⚓︎
Gets the error message for a resource not found error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
case |
str
|
The case to use for the error message. |
required |
data |
Set[str]
|
The data to use for the error message. |
required |
Returns:
Type | Description |
---|---|
str
|
The error message. |
Source code in pokelance/ext/_base.py
get_pokedex(name)
⚓︎
Gets a pokedex from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokedex. |
required |
Returns:
Type | Description |
---|---|
Optional[Pokedex]
|
The pokedex if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the pokedex is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pokedex = client.game.get_pokedex(1)
>>> pokedex.region
None
Source code in pokelance/ext/game.py
get_version(name)
⚓︎
Gets a version from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the version. |
required |
Returns:
Type | Description |
---|---|
Optional[Version]
|
The version if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the version is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> version = client.game.get_version(1)
>>> version.name
'red'
Source code in pokelance/ext/game.py
get_version_group(name)
⚓︎
Gets a version group from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the version group. |
required |
Returns:
Type | Description |
---|---|
Optional[VersionGroup]
|
The version group if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the version group is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> version_group = client.game.get_version_group(1)
>>> version_group.id
1
Source code in pokelance/ext/game.py
setup()
async
⚓︎
Sets up the extension.