Skip to content

Commit

Permalink
fix character title that contains grade
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasehlert committed Oct 8, 2023
1 parent 3a9683a commit 97a6784
Show file tree
Hide file tree
Showing 3 changed files with 811 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/TibiaCharactersCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string) (*CharacterResponse, er
case "Sex:":
CharacterInfoData.Sex = RowData
case "Title:":
leftParenIdx := strings.Index(RowData, "(")
leftParenIdx := strings.LastIndex(RowData, "(")
if leftParenIdx == -1 {
return
}
Expand Down
29 changes: 29 additions & 0 deletions src/TibiaCharactersCharacter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3005,6 +3005,35 @@ func TestNumber9(t *testing.T) {
assert.Equal(character.OtherCharacters[9].World, "Ferobra")
}

func TestNumber10(t *testing.T) {
file, err := static.TestFiles.Open("testdata/characters/Nocna Furia.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)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data))
if err != nil {
t.Fatal(err)
}

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

assert.Equal("Nocna Furia", character.Name)
assert.Nil(character.FormerNames)
assert.False(character.Traded)
assert.Empty(character.DeletionDate)
assert.Equal("male", character.Sex)
assert.Equal("Tibia's Topmodel (Grade 1)", character.Title)
assert.Equal(6, character.UnlockedTitles)
}

func BenchmarkNumber1(b *testing.B) {
file, err := static.TestFiles.Open("testdata/characters/Darkside Rafa.html")
if err != nil {
Expand Down
Loading

0 comments on commit 97a6784

Please sign in to comment.