tallgrass/item
Types
pub type Item {
Item(
id: Int,
name: String,
cost: Int,
fling_power: Option(Int),
fling_effect: Option(Resource),
attributes: List(Resource),
category: Resource,
effect_entries: List(VerboseEffect),
flavor_text_entries: List(VersionGroupFlavorText),
game_indices: List(GenerationGameIndex),
names: List(Name),
held_by_pokemon: List(ItemHolderPokemon),
baby_trigger_for: Option(Resource),
)
}
Constructors
-
Item( id: Int, name: String, cost: Int, fling_power: Option(Int), fling_effect: Option(Resource), attributes: List(Resource), category: Resource, effect_entries: List(VerboseEffect), flavor_text_entries: List(VersionGroupFlavorText), game_indices: List(GenerationGameIndex), names: List(Name), held_by_pokemon: List(ItemHolderPokemon), baby_trigger_for: Option(Resource), )
pub type ItemHolderPokemon {
ItemHolderPokemon(
pokemon: Resource,
version_details: List(ItemHolderPokemonVersionDetail),
)
}
Constructors
-
ItemHolderPokemon( pokemon: Resource, version_details: List(ItemHolderPokemonVersionDetail), )
pub type ItemHolderPokemonVersionDetail {
ItemHolderPokemonVersionDetail(rarity: Int, version: Resource)
}
Constructors
-
ItemHolderPokemonVersionDetail(rarity: Int, version: Resource)
pub type VersionGroupFlavorText {
VersionGroupFlavorText(
text: String,
language: Resource,
version_group: Resource,
)
}
Constructors
-
VersionGroupFlavorText( text: String, language: Resource, version_group: Resource, )
Functions
pub fn fetch(client: Client) -> Result(PaginatedResource, Error)
Fetches a paginated list of item resources.
Example
let result = item.new() |> item.fetch()
pub fn fetch_by_id(
client: Client,
id: Int,
) -> Result(Item, Error)
Fetches an item given the item ID.
Example
let result = item.new() |> item.fetch_by_id(1)
pub fn fetch_by_name(
client: Client,
name: String,
) -> Result(Item, Error)
Fetches an item given the item name.
Example
let result = item.new() |> item.fetch_by_name("master-ball")
pub fn fetch_resource(
client: Client,
resource: Resource,
) -> Result(Item, Error)
Fetches an item given an item resource.
Example
let client = client.new()
use res <- result.try(client |> item.fetch())
let assert Ok(first) = res.results |> list.first
client |> item.fetch_resource(first)