encounter
pokelance.ext.encounter
⚓︎
Encounter(client)
⚓︎
Bases: BaseExtension
Extension for encounter related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
cache |
Encounter
|
The cache for this extension. |
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_encounter_condition(name)
async
⚓︎
Fetches an encounter condition from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the encounter condition. |
required |
Returns:
Type | Description |
---|---|
EncounterCondition
|
The encounter condition if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the encounter condition is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... condition = await client.encounter.fetch_encounter_condition("swarm")
... print(condition.name)
... await client.close()
>>> asyncio.run(main())
swarm
Source code in pokelance/ext/encounter.py
fetch_encounter_condition_value(name)
async
⚓︎
Fetches an encounter condition value from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the encounter condition value. |
required |
Returns:
Type | Description |
---|---|
EncounterConditionValue
|
The encounter condition value if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the encounter condition value is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... condition = await client.encounter.fetch_encounter_condition_value("swarm-yes")
... print(condition.name)
... await client.close()
>>> asyncio.run(main())
swarm-yes
Source code in pokelance/ext/encounter.py
fetch_encounter_method(name)
async
⚓︎
Fetches an encounter method from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the encounter method. |
required |
Returns:
Type | Description |
---|---|
EncounterMethod
|
The encounter method if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the encounter method is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... method = await client.encounter.fetch_encounter_method("walk")
... print(method.name)
... await client.close()
>>> asyncio.run(main())
walk
Source code in pokelance/ext/encounter.py
get_encounter_condition(name)
⚓︎
Gets an encounter condition from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the encounter condition. |
required |
Returns:
Type | Description |
---|---|
Optional[EncounterCondition]
|
The encounter condition if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the encounter condition is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> condition = client.encounter.get_encounter_condition("swarm")
>>> condition.name
'swarm'
Source code in pokelance/ext/encounter.py
get_encounter_condition_value(name)
⚓︎
Gets an encounter condition value from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the encounter condition value. |
required |
Returns:
Type | Description |
---|---|
Optional[EncounterConditionValue]
|
The encounter condition value if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the encounter condition value is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> condition = client.encounter.get_encounter_condition_value("swarm-yes")
>>> condition.name
'swarm-yes'
Source code in pokelance/ext/encounter.py
get_encounter_method(name)
⚓︎
Gets an encounter method from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the encounter method. |
required |
Returns:
Type | Description |
---|---|
Optional[EncounterMethod]
|
The encounter method if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the encounter method is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> method = client.encounter.get_encounter_method("walk")
>>> method.name
'walk'
Source code in pokelance/ext/encounter.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
setup()
async
⚓︎
Sets up the extension.