diff --git a/src/workers.go b/src/workers.go index 0e6fb66..93635f0 100644 --- a/src/workers.go +++ b/src/workers.go @@ -73,10 +73,20 @@ func (b *Builder) housesWorker(client *resty.Client) error { }) + // Find the index of Antica in b.Worlds[] or fallback to first index + worldsIndex := func() int { + for i, world := range b.Worlds { + if world == "Antica" { + return i + } + } + return 0 + }() + for _, town := range b.Towns { log.Printf("[info] Retrieving data about houses and guildhalls in %s.", town) - ApiUrl := "https://" + TibiaDataAPIhost + "/v4/houses/" + b.Worlds[0] + "/" + url.QueryEscape(town) + ApiUrl := "https://" + TibiaDataAPIhost + "/v4/houses/" + b.Worlds[worldsIndex] + "/" + url.QueryEscape(town) res, err := client.R().Get(ApiUrl) if err != nil { return fmt.Errorf("issue getting %s endpoint. Error: %s", ApiUrl, err)