diff --git a/src/TibiaCreaturesCreature.go b/src/TibiaCreaturesCreature.go index 79d5bd85..dc41eedd 100644 --- a/src/TibiaCreaturesCreature.go +++ b/src/TibiaCreaturesCreature.go @@ -42,7 +42,7 @@ type CreatureResponse struct { } var ( - CreatureDataRegex = regexp.MustCompile(`.*;">(.*)<\/h2> .*

(.*)<\/p>

(.*)<\/p>

(.*)<\/p>.*`) + CreatureDataRegex = regexp.MustCompile(`.*;">(.*)<\/h2> .*

(.*)<\/p>

(.*)<\/p>

(.*)<\/p>.*`) CreatureHitpointsRegex = regexp.MustCompile(`.*have (.*) hitpoints. (.*)`) CreatureImmuneRegex = regexp.MustCompile(`.*are immune to (.*)`) CreatureStrongRegex = regexp.MustCompile(`.*are strong against (.*)`) diff --git a/src/TibiaCreaturesCreature_test.go b/src/TibiaCreaturesCreature_test.go index 91cdffeb..c680caf9 100644 --- a/src/TibiaCreaturesCreature_test.go +++ b/src/TibiaCreaturesCreature_test.go @@ -66,7 +66,7 @@ func TestDemon(t *testing.T) { assert.False(demonJson.Creature.Featured) } -func TestQuaraPredatorFeatured(t *testing.T) { +func TestQuaraPredator(t *testing.T) { file, err := static.TestFiles.Open("testdata/creatures/creature/quara predator.html") if err != nil { t.Fatalf("file opening error: %s", err) @@ -108,14 +108,14 @@ func TestQuaraPredatorFeatured(t *testing.T) { assert.False(quaraPredatorJson.Creature.BeConvinced) assert.Equal(0, quaraPredatorJson.Creature.ConvincedMana) assert.True(quaraPredatorJson.Creature.SeeInvisible) - assert.Equal(1600, quaraPredatorJson.Creature.ExperiencePoints) + assert.Equal(1850, quaraPredatorJson.Creature.ExperiencePoints) assert.True(quaraPredatorJson.Creature.IsLootable) assert.Equal(2, len(quaraPredatorJson.Creature.LootList)) assert.Equal("gold coins", quaraPredatorJson.Creature.LootList[0]) assert.Equal("quara bones", quaraPredatorJson.Creature.LootList[1]) - assert.True(quaraPredatorJson.Creature.Featured) + assert.False(quaraPredatorJson.Creature.Featured) } func TestCentipede(t *testing.T) { @@ -211,3 +211,24 @@ func TestLavaLurkers(t *testing.T) { assert.Equal(1, len(lavalurkersJson.Creature.HealedBy)) assert.Equal("fire", lavalurkersJson.Creature.HealedBy[0]) } + +func TestFeralWerecrocodilesFeatured(t *testing.T) { + file, err := static.TestFiles.Open("testdata/creatures/creature/feral werecrocodile.html") + if err != nil { + t.Fatalf("file opening error: %s", err) + } + defer file.Close() + + data, err := io.ReadAll(file) + if err != nil { + t.Fatalf("File reading error: %s", err) + } + + feralwerecrocodileJson, _ := TibiaCreaturesCreatureImpl("Feral Werecrocodiles", string(data), "") + assert := assert.New(t) + + assert.Equal("Feral Werecrocodiles", feralwerecrocodileJson.Creature.Name) + assert.Equal("Feral Werecrocodiles", feralwerecrocodileJson.Creature.Race) + + assert.False(feralwerecrocodileJson.Creature.Featured) +} diff --git a/src/TibiaCreaturesOverview.go b/src/TibiaCreaturesOverview.go index f98fbc8d..0c0b5289 100644 --- a/src/TibiaCreaturesOverview.go +++ b/src/TibiaCreaturesOverview.go @@ -76,7 +76,7 @@ func TibiaCreaturesOverviewImpl(BoxContentHTML string, url string) (CreaturesOve ) // Running query over each div - ReaderHTML.Find(".BoxContent div div").EachWithBreak(func(index int, s *goquery.Selection) bool { + ReaderHTML.Find(".Creatures div").EachWithBreak(func(index int, s *goquery.Selection) bool { // Storing HTML into CreatureDivHTML CreatureDivHTML, err := s.Html() if err != nil { diff --git a/src/TibiaCreaturesOverview_test.go b/src/TibiaCreaturesOverview_test.go index 6c3e0a1b..4e01351b 100644 --- a/src/TibiaCreaturesOverview_test.go +++ b/src/TibiaCreaturesOverview_test.go @@ -29,9 +29,9 @@ func TestOverview(t *testing.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) + assert.Equal("Feral Werecrocodile", creaturesJson.Creatures.Boosted.Name) + assert.Equal("feralwerecrocodile", creaturesJson.Creatures.Boosted.Race) + assert.Equal("https://static.tibia.com/images/global/header/monsters/feralwerecrocodile.gif", creaturesJson.Creatures.Boosted.ImageURL) assert.Equal(638, len(creaturesJson.Creatures.Creatures)) @@ -41,11 +41,17 @@ func TestOverview(t *testing.T) { assert.Equal("https://static.tibia.com/images/library/acidblob.gif", acidblob.ImageURL) assert.False(acidblob.Featured) + feralwerecrocodile := creaturesJson.Creatures.Creatures[204] + assert.Equal("Feral Werecrocodiles", feralwerecrocodile.Name) + assert.Equal("feralwerecrocodile", feralwerecrocodile.Race) + assert.Equal("https://static.tibia.com/images/library/feralwerecrocodile.gif", feralwerecrocodile.ImageURL) + assert.True(feralwerecrocodile.Featured) + minotauramazon := creaturesJson.Creatures.Creatures[360] assert.Equal("Minotaur Amazons", minotauramazon.Name) assert.Equal("minotauramazon", minotauramazon.Race) assert.Equal("https://static.tibia.com/images/library/minotauramazon.gif", minotauramazon.ImageURL) - assert.True(minotauramazon.Featured) + assert.False(minotauramazon.Featured) quarapredator := creaturesJson.Creatures.Creatures[465] assert.Equal("Quara Predators", quarapredator.Name) diff --git a/src/static/testdata/creatures/creature/centipede.html b/src/static/testdata/creatures/creature/centipede.html index dc512348..494b7b7c 100644 --- a/src/static/testdata/creatures/creature/centipede.html +++ b/src/static/testdata/creatures/creature/centipede.html @@ -2,16 +2,16 @@ -Tibia - Free Multiplayer Online Role Playing Game - Library - - - - - - - - - + Tibia - Free Multiplayer Online Role Playing Game - Library + + + + + + + + + @@ -19,35 +19,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - -

-
- -
-
NO - internet explorer
-
NEW - internet explorer
-
OLD - internet explorer
-
-
-
-
-