pokecli/internal/trainer/trainer.go

52 lines
1.2 KiB
Go

package trainer
import "codeflow.dananglin.me.uk/apollo/pokedex/internal/api/pokeapi"
type Trainer struct {
previousLocationArea *string
nextLocationArea *string
currentLocationAreaID int
pokedex map[string]pokeapi.Pokemon
}
func NewTrainer() *Trainer {
trainer := Trainer{
previousLocationArea: nil,
nextLocationArea: nil,
currentLocationAreaID: 0,
pokedex: make(map[string]pokeapi.Pokemon),
}
return &trainer
}
func (t *Trainer) UpdateLocationAreas(previous, next *string) {
t.previousLocationArea = previous
t.nextLocationArea = next
}
func (t *Trainer) PreviousLocationArea() *string {
return t.previousLocationArea
}
func (t *Trainer) NextLocationArea() *string {
return t.nextLocationArea
}
func (t *Trainer) AddPokemonToPokedex(name string, details pokeapi.Pokemon) {
t.pokedex[name] = details
}
func (t *Trainer) GetPokemonFromPokedex(name string) (pokeapi.Pokemon, bool) {
details, ok := t.pokedex[name]
return details, ok
}
func (t *Trainer) CurrentLocationAreaID() int {
return t.currentLocationAreaID
}
func (t *Trainer) UpdateCurrentLocationAreaID(locationAreaID int) {
t.currentLocationAreaID = locationAreaID
}