Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
796e254
Added Link to Information struct / Modified both Characters and Guild…
Kai-Animator Oct 15, 2024
7e10858
Tibia Guild Test Case with Link on information
Kai-Animator Oct 15, 2024
b6b7e2a
Added link to guilds/:world endpoint and tests for both guild/:guild …
Kai-Animator Oct 15, 2024
e58723e
Adjust test for existing guild
Kai-Animator Oct 15, 2024
be8a2ff
Link added to fansites
Kai-Animator Oct 15, 2024
0aab6ec
Added Link to Boostable bosses && Test
Kai-Animator Oct 15, 2024
0643725
Add Creature Link and Creature Test
Kai-Animator Oct 15, 2024
5efdbfa
CreaturesOverall test and Link implementation
Kai-Animator Oct 15, 2024
17304b9
Highscores link implementation & test
Kai-Animator Oct 15, 2024
4057c05
Fix Creature Links
Kai-Animator Oct 15, 2024
56afabe
Fix link on creature single | swap name for race
Kai-Animator Oct 15, 2024
9c6612b
Highscores adjust
Kai-Animator Oct 15, 2024
f99daa9
Houses link implementation & Test
Kai-Animator Oct 15, 2024
0049502
Implement Killstatistics, TibiaNews, Spells and SpellsOverview With T…
Kai-Animator Oct 15, 2024
51c8969
Tibia Worlds link with tests
Kai-Animator Oct 15, 2024
627ab13
Newslist and webserver Changes
Kai-Animator Oct 15, 2024
c43bd2f
Tests for newslist
Kai-Animator Oct 15, 2024
c9dcf71
Swap Creature tests
Kai-Animator Oct 15, 2024
7b9e931
Replace Link to TibiaURL
Kai-Animator Oct 16, 2024
cbeb45a
TibiaBossesOverview URL test/func and webserver Updates
Kai-Animator Oct 16, 2024
35fe562
TibiaCharactersCharacter test and func rewrite passing URL as argument
Kai-Animator Oct 16, 2024
f7ad7a1
TibiaCreatures & CreaturesOverview func/test/server changes (url as a…
Kai-Animator Oct 16, 2024
860a08e
TibiaFansites func/test/webserver updates (passing url argument)
Kai-Animator Oct 16, 2024
631ec36
Guilds & GuildsOverview func/test/server update (url as args)
Kai-Animator Oct 16, 2024
7ce818d
HousesHouse & Highscores func/webserver/test updates (passing url as …
Kai-Animator Oct 16, 2024
96dbbe6
HousesOverview update (urls)
Kai-Animator Oct 16, 2024
e3feaea
Update tests to read from slices instead of string
Kai-Animator Oct 16, 2024
478f9ed
Killstatistics update (url as param)
Kai-Animator Oct 16, 2024
12e6592
news and Newslist func/test/webserver updates (pass url as args)
Kai-Animator Oct 16, 2024
d2c1ebf
Spells and SpellsOverview func/webserver/test update (pass url as args)
Kai-Animator Oct 16, 2024
71b9f13
Worlds & WorldsOverview func/test/webserver updates (pass url as args)
Kai-Animator Oct 16, 2024
af47183
replace TibiaURL to TibiaURLs
Kai-Animator Oct 25, 2024
df41128
Fixed json:tibia_url reference to json:tibia_urls instead
Kai-Animator Oct 26, 2024
758f09c
Revert changes made accidentally in TibiaNews and Newslist (TibiaURLs…
Kai-Animator Oct 28, 2024
91be53d
fix: test case of TestFindPerson
tobiasehlert Nov 21, 2024
8071c58
chore: linting
tobiasehlert Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/TibiaBoostableBossesOverview.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type BoostableBossesOverviewResponse struct {
Information Information `json:"information"`
}

func TibiaBoostableBossesOverviewImpl(BoxContentHTML string) (BoostableBossesOverviewResponse, error) {
func TibiaBoostableBossesOverviewImpl(BoxContentHTML string, url string) (BoostableBossesOverviewResponse, error) {
const (
bodyIndexer = `<body`
endBodyIndexer = `</body>`
Expand Down Expand Up @@ -151,6 +151,7 @@ func TibiaBoostableBossesOverviewImpl(BoxContentHTML string) (BoostableBossesOve
Information{
APIDetails: TibiaDataAPIDetails,
Timestamp: TibiaDataDatetime(""),
TibiaURLs: []string{url},
Status: Status{
HTTPCode: http.StatusOK,
},
Expand Down
6 changes: 4 additions & 2 deletions src/TibiaBoostableBossesOverview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ func TestBoostableBossesOverview(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

boostableBossesJson, _ := TibiaBoostableBossesOverviewImpl(string(data))
boostableBossesJson, _ := TibiaBoostableBossesOverviewImpl(string(data), "https://www.tibia.com/library/?subtopic=boostablebosses")
assert := assert.New(t)
boosted := boostableBossesJson.BoostableBosses.Boosted
bosses := boostableBossesJson.BoostableBosses.BoostableBosses
information := boostableBossesJson.Information

assert.Equal("https://www.tibia.com/library/?subtopic=boostablebosses", information.TibiaURLs[0])
assert.Equal(95, len(bosses))
assert.Equal("Ragiaz", boosted.Name)
assert.Equal(
Expand Down Expand Up @@ -107,6 +109,6 @@ func BenchmarkTibiaBoostableBossesOverviewImpl(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
bossSink, _ = TibiaBoostableBossesOverviewImpl(data)
bossSink, _ = TibiaBoostableBossesOverviewImpl(data, "https://www.tibia.com/library/?subtopic=boostablebosses")
}
}
3 changes: 2 additions & 1 deletion src/TibiaCharactersCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ type CharacterResponse struct {
const Br = 0x202

// TibiaCharactersCharacter func
func TibiaCharactersCharacterImpl(BoxContentHTML string) (CharacterResponse, error) {
func TibiaCharactersCharacterImpl(BoxContentHTML string, url string) (CharacterResponse, error) {
var (
// local strings used in this function
localDivQueryString = ".TableContentContainer tr"
Expand Down Expand Up @@ -725,6 +725,7 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string) (CharacterResponse, err
Information{
APIDetails: TibiaDataAPIDetails,
Timestamp: TibiaDataDatetime(""),
TibiaURLs: []string{url},
Status: Status{
HTTPCode: http.StatusOK,
},
Expand Down
33 changes: 18 additions & 15 deletions src/TibiaCharactersCharacter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ func TestNumber1(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa")
if err != nil {
t.Fatal(err)
}

assert := assert.New(t)
character := characterJson.Character.CharacterInfo
information := characterJson.Information

assert.Equal("Darkside Rafa", character.Name)
assert.Nil(character.FormerNames)
Expand All @@ -54,6 +55,8 @@ func TestNumber1(t *testing.T) {
assert.Equal("2022-01-05T21:23:32Z", character.LastLogin)
assert.Equal("Premium Account", character.AccountStatus)
assert.Empty(character.Comment)

assert.Equal("https://www.tibia.com/community/?subtopic=characters&name=Darkside+Rafa", information.TibiaURLs[0])
}

func TestNumber2(t *testing.T) {
Expand All @@ -68,7 +71,7 @@ func TestNumber2(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -134,7 +137,7 @@ func TestNumber3(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -169,7 +172,7 @@ func TestNumber4(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -2784,7 +2787,7 @@ func TestNumber5(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -2838,7 +2841,7 @@ func TestNumber6(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -2888,7 +2891,7 @@ func TestNumber7(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand All @@ -2913,7 +2916,7 @@ func TestNumber8(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -3073,7 +3076,7 @@ func TestNumber9(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -3175,7 +3178,7 @@ func TestNumber10(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -3204,7 +3207,7 @@ func TestNumber11(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -3285,7 +3288,7 @@ func TestNumber12(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand All @@ -3310,7 +3313,7 @@ func TestNumber13(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -3401,7 +3404,7 @@ func BenchmarkNumber1(b *testing.B) {
b.ReportAllocs()

for i := 0; i < b.N; i++ {
characterJson, _ := TibiaCharactersCharacterImpl(string(data))
characterJson, _ := TibiaCharactersCharacterImpl(string(data), "")

assert.Equal(b, "Darkside Rafa", characterJson.Character.CharacterInfo.Name)
}
Expand All @@ -3422,7 +3425,7 @@ func BenchmarkNumber2(b *testing.B) {
b.ReportAllocs()

for i := 0; i < b.N; i++ {
characterJson, _ := TibiaCharactersCharacterImpl(string(data))
characterJson, _ := TibiaCharactersCharacterImpl(string(data), "")

assert.Equal(b, "Riley No Hands", characterJson.Character.CharacterInfo.Name)
}
Expand Down
7 changes: 4 additions & 3 deletions src/TibiaCreaturesCreature.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ var (
CreatureLootRegex = regexp.MustCompile(`.*yield (.*) experience.*carry (.*)with them.`)
)

func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureResponse, error) {
func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string, url string) (CreatureResponse, error) {
// local strings used in this function
var localDamageString = " damage"
localDamageString := " damage"

// Loading HTML data into ReaderHTML for goquery with NewReader
ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML))
Expand All @@ -79,7 +79,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureRes
CreatureBeParalysed, CreatureBeSummoned, CreatureBeConvinced, CreatureSeeInvisible, CreatureIsLootable, CreatureIsBoosted bool
)

//Find boosted creature
// Find boosted creature
boostedMonsterTitle, boostedCreatureFound := ReaderHTML.Find("#Monster").First().Attr("title")

if boostedCreatureFound {
Expand Down Expand Up @@ -192,6 +192,7 @@ func TibiaCreaturesCreatureImpl(race string, BoxContentHTML string) (CreatureRes
Information{
APIDetails: TibiaDataAPIDetails,
Timestamp: TibiaDataDatetime(""),
TibiaURLs: []string{url},
Status: Status{
HTTPCode: http.StatusOK,
},
Expand Down
14 changes: 8 additions & 6 deletions src/TibiaCreaturesCreature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ func TestDemon(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

demonJson, err := TibiaCreaturesCreatureImpl("Demon", string(data))
demonJson, err := TibiaCreaturesCreatureImpl("Demon", string(data), "https://www.tibia.com/library/?subtopic=creatures&race=demon")
if err != nil {
t.Fatal(err)
}

assert := assert.New(t)
information := demonJson.Information

assert.Equal("https://www.tibia.com/library/?subtopic=creatures&race=demon", information.TibiaURLs[0])
assert.Equal("Demons", demonJson.Creature.Name)
assert.Equal("Demon", demonJson.Creature.Race)
assert.Equal("https://static.tibia.com/images/library/demon.gif", demonJson.Creature.ImageURL)
Expand Down Expand Up @@ -76,7 +78,7 @@ func TestQuaraPredatorFeatured(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

quaraPredatorJson, err := TibiaCreaturesCreatureImpl("Quara Predator", string(data))
quaraPredatorJson, err := TibiaCreaturesCreatureImpl("Quara Predator", string(data), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -128,7 +130,7 @@ func TestCentipede(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

centipedeJson, _ := TibiaCreaturesCreatureImpl("Centipede", string(data))
centipedeJson, _ := TibiaCreaturesCreatureImpl("Centipede", string(data), "")
assert := assert.New(t)

assert.Equal("Centipedes", centipedeJson.Creature.Name)
Expand All @@ -152,7 +154,7 @@ func TestHunter(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

hunterJson, _ := TibiaCreaturesCreatureImpl("Hunter", string(data))
hunterJson, _ := TibiaCreaturesCreatureImpl("Hunter", string(data), "")
assert := assert.New(t)

assert.Equal("Hunters", hunterJson.Creature.Name)
Expand All @@ -176,7 +178,7 @@ func TestSkunk(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

skunkJson, _ := TibiaCreaturesCreatureImpl("Skunk", string(data))
skunkJson, _ := TibiaCreaturesCreatureImpl("Skunk", string(data), "")
assert := assert.New(t)

assert.Equal("Skunks", skunkJson.Creature.Name)
Expand All @@ -200,7 +202,7 @@ func TestLavaLurkers(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

lavalurkersJson, _ := TibiaCreaturesCreatureImpl("Lava Lurkers", string(data))
lavalurkersJson, _ := TibiaCreaturesCreatureImpl("Lava Lurkers", string(data), "")
assert := assert.New(t)

assert.Equal("Lava Lurkers", lavalurkersJson.Creature.Name)
Expand Down
7 changes: 3 additions & 4 deletions src/TibiaCreaturesOverview.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ var (
CreatureInformationRegex = regexp.MustCompile(`.*race=(.*)"><img src="(.*)" border.*div>(.*)<\/div>`)
)

func TibiaCreaturesOverviewImpl(BoxContentHTML string) (CreaturesOverviewResponse, error) {
var (
BoostedCreatureName, BoostedCreatureRace, BoostedCreatureImage string
)
func TibiaCreaturesOverviewImpl(BoxContentHTML string, url string) (CreaturesOverviewResponse, error) {
var BoostedCreatureName, BoostedCreatureRace, BoostedCreatureImage string

// Loading HTML data into ReaderHTML for goquery with NewReader
ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML))
Expand Down Expand Up @@ -127,6 +125,7 @@ func TibiaCreaturesOverviewImpl(BoxContentHTML string) (CreaturesOverviewRespons
Information{
APIDetails: TibiaDataAPIDetails,
Timestamp: TibiaDataDatetime(""),
TibiaURLs: []string{url},
Status: Status{
HTTPCode: http.StatusOK,
},
Expand Down
4 changes: 3 additions & 1 deletion src/TibiaCreaturesOverview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ func TestOverview(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

creaturesJson, err := TibiaCreaturesOverviewImpl(string(data))
creaturesJson, err := TibiaCreaturesOverviewImpl(string(data), "https://www.tibia.com/library/?subtopic=creatures")
if err != nil {
t.Fatal(err)
}

assert := assert.New(t)
information := creaturesJson.Information

assert.Equal("https://www.tibia.com/library/?subtopic=creatures", information.TibiaURLs[0])
assert.Equal("Minotaur Amazon", creaturesJson.Creatures.Boosted.Name)
assert.Equal("minotauramazon", creaturesJson.Creatures.Boosted.Race)
assert.Equal("https://static.tibia.com/images/global/header/monsters/minotauramazon.gif", creaturesJson.Creatures.Boosted.ImageURL)
Expand Down
3 changes: 2 additions & 1 deletion src/TibiaFansites.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var (
FansiteAnchorRegex = regexp.MustCompile(`.*src="(.*)" alt=".*`)
)

func TibiaFansitesImpl(BoxContentHTML string) (FansitesResponse, error) {
func TibiaFansitesImpl(BoxContentHTML string, url string) (FansitesResponse, error) {
// Loading HTML data into ReaderHTML for goquery with NewReader
ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML))
if err != nil {
Expand Down Expand Up @@ -97,6 +97,7 @@ func TibiaFansitesImpl(BoxContentHTML string) (FansitesResponse, error) {
Information{
APIDetails: TibiaDataAPIDetails,
Timestamp: TibiaDataDatetime(""),
TibiaURLs: []string{url},
Status: Status{
HTTPCode: http.StatusOK,
},
Expand Down
5 changes: 4 additions & 1 deletion src/TibiaFansites_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestFansites(t *testing.T) {
t.Fatalf("File reading error: %s", err)
}

fansitesJson, err := TibiaFansitesImpl(string(data))
fansitesJson, err := TibiaFansitesImpl(string(data), "https://www.tibia.com/community/?subtopic=fansites")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -86,4 +86,7 @@ func TestFansites(t *testing.T) {
assert.Equal("Upload, browse, like and share pictures.", tibiaGalleryFansite.Specials[0])
assert.True(tibiaGalleryFansite.FansiteItem)
assert.Equal("https://static.tibia.com/images/community/fansiteitems/TibiaGallery.com.gif", tibiaGalleryFansite.FansiteItemURL)

information := fansitesJson.Information
assert.Equal("https://www.tibia.com/community/?subtopic=fansites", information.TibiaURLs[0])
}
3 changes: 2 additions & 1 deletion src/TibiaGuildsGuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var (
GuildMemberInvitesInformationRegex = regexp.MustCompile(`<td><a.*">(.*)<\/a><\/td><td>(.*)<\/td>`)
)

func TibiaGuildsGuildImpl(guild string, BoxContentHTML string) (GuildResponse, error) {
func TibiaGuildsGuildImpl(guild string, BoxContentHTML string, url string) (GuildResponse, error) {
// Creating empty vars
var (
MembersData []GuildMember
Expand Down Expand Up @@ -282,6 +282,7 @@ func TibiaGuildsGuildImpl(guild string, BoxContentHTML string) (GuildResponse, e
Information{
APIDetails: TibiaDataAPIDetails,
Timestamp: TibiaDataDatetime(""),
TibiaURLs: []string{url},
Status: Status{
HTTPCode: http.StatusOK,
},
Expand Down
Loading
Loading