generated from templates/go-generic
Dan Anglin
80d1b5b6c0
Added an internal package for the Pokemon trainer (the user of the application). The new Trainer type keeps track of the Pokemon in the trainer's Pokedex and the location where the trainer is visiting. Added the visit command to allow the Pokemon trainer to visit and explore an area within the Pokemon world. The explore command no longer reads any arguments and uses the trainer's current location to get a list of Pokemon encounters. Updated the catch command to ensure that the Pokemon the trainer attempts to catch is in the same location area that the trainer is visiting.
52 lines
1.8 KiB
Go
52 lines
1.8 KiB
Go
package pokeapi
|
|
|
|
// LocationArea is a section of areas such as floors in a building or a cave.
|
|
type LocationArea struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
GameIndex int `json:"game_index"`
|
|
EncounterMethodRates []EncounterMethodRate `json:"encounter_method_rates"`
|
|
Location NamedAPIResource `json:"location"`
|
|
Names []Name `json:"names"`
|
|
PokemonEncounters []PokemonEncounter `json:"pokemon_encounters"`
|
|
}
|
|
|
|
type LocationAreaEncounter struct {
|
|
LocationArea NamedAPIResource `json:"location_area"`
|
|
VersionDetails []VersionEncounterDetails `json:"version_details"`
|
|
}
|
|
|
|
type EncounterMethodRate struct {
|
|
EncounterMethod NamedAPIResource `json:"encounter_method"`
|
|
VersionDetails []EncounterVersionDetails `json:"version_details"`
|
|
}
|
|
|
|
type EncounterVersionDetails struct {
|
|
Rate int `json:"rate"`
|
|
Version NamedAPIResource `json:"version"`
|
|
}
|
|
|
|
type Name struct {
|
|
Name string `json:"name"`
|
|
Language NamedAPIResource `json:"language"`
|
|
}
|
|
|
|
// PokemonEncounter is details of a possible Pokemon encounter.
|
|
type PokemonEncounter struct {
|
|
Pokemon NamedAPIResource `json:"pokemon"`
|
|
VersionDetails []VersionEncounterDetails `json:"version_details"`
|
|
}
|
|
|
|
type VersionEncounterDetails struct {
|
|
Version NamedAPIResource `json:"version"`
|
|
MaxChance int `json:"max_chance"`
|
|
EncounterDetails []Encounter `json:"encounter_details"`
|
|
}
|
|
|
|
type Encounter struct {
|
|
MinLevel int `json:"min_level"`
|
|
MaxLevel int `json:"max_level"`
|
|
ConditionValues []NamedAPIResource `json:"condition_values"`
|
|
Chance int `json:"chance"`
|
|
Method NamedAPIResource `json:"method"`
|
|
}
|