Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Guevara-chan committed Jul 12, 2019
1 parent e470036 commit 02af826
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main.coffee
Expand Up @@ -29,8 +29,9 @@ class SiralimData
txt[0].toUpperCase() + txt[1..]

get_field: (feed, field) ->
idx = feed?.findIndex((elem) -> elem.startsWith field + ": ")
feed.splice(idx, 1)[0].split(field + ": ")[1] if idx != -1
matcher = new RegExp field + ": (.*)"
idx = feed?.findIndex((elem) -> matcher.test elem)
feed.splice(idx, 1)[0].match(matcher)[-1..][0] if idx != -1

get_list: (feed, matcher) ->
feed.filter((x) -> matcher.test x).map((x) -> x.match(matcher)[1])
Expand Down Expand Up @@ -69,8 +70,9 @@ class SiralimData
aura: @get_field(fragment, "Nether Aura: Nether Aura") ? ""
nethtraits: @get_list(fragment, /Nether Trait: (.*)/)
gems: @get_list(fragment, /Gem of (.*) \(Mana/)
stats: (Object.assign stats,{[stat]: BigInt @get_field fragment, SiralimData.capitalize stat} for stat in [
'health', 'mana', 'attack', 'intelligence', 'defense', 'speed'])[0]
stats: (Object.assign stats,
{[stat]: BigInt @get_field fragment, SiralimData.capitalize(stat) + '( \\(.*\\))?'} for stat in [
'health', 'mana', 'attack', 'intelligence', 'defense', 'speed'])[0]
art:
name: @get_field(art_data, "Artifact") ? ""
trait: @get_field(art_data, "Trait") ? ""
Expand Down

0 comments on commit 02af826

Please sign in to comment.