seripap / vainglory

(*DEPRECATED*: The API no longer exists, so this will no longer work) A Javascript API Client wrapper for Vainglory
MIT License
29 stars 7 forks source link

Remove item mapping #38

Closed PierreAndreis closed 6 years ago

PierreAndreis commented 6 years ago

Recently, most if the item names are coming in same pattern: *Item_{Camel Case Item Name}*

What we are doing right now

For every new item, we need to update the item mapping with the correct name and server name. This add a need for a new minor release of this package on every vainglory update that introduces a new item to the game.

What we should do

Keep track of dirty mappings, and if there is no map we should check if we can get the name translated using a regex. That's the same way we have been handling heroes name.

This will reduce the maintenance need for every update that introduces new item

seripap commented 6 years ago

@PierreAndreis check out e491b60, let me know if this works. I haven't played with the API lately so I'm not sure if there are anymore bad item names. Shoot them here if so and i'll add another check before releasing a new version.

PierreAndreis commented 6 years ago

It can be on these format: *1000_Item_HalcyonPotion* *Item_Pulseweave* Item_RooksDecree

and sometimes it needs some mapping because they are wrong names:

{
    "serverName": "Crystal3",
    "name": "Shatterglass"
 }

What I think we should do instead: Keep the current mappings, and check for matches there first. If there is a match, we use the name and return it. If there are no matches, then we check if the format is compatible to /^(.*)_(.*)\**/gm and then extract the second group. We should then add the spaces between the two words.

Reason why the last * is a 0+ quantifier is because sometimes there are no asterisks as shown in Item_RooksDecree

What do you think?

seripap commented 6 years ago

In that case, we could probably just get away with something like this (.*)Item_(.*?), then clean up characters thereafter. See changes in 885369e