dolejska-daniel / riot-api

Riot League of Legends & DataDragon API wrappers for PHP7 and PHP8.
GNU General Public License v3.0
113 stars 25 forks source link

How do you display reforged runes icons? #74

Closed elreco closed 4 years ago

elreco commented 4 years ago

Hello :)

thank you for your wrapper!

I have an issue, how do you display the image path of the new runes ?

When I retrieve a match, I get 6 perks variables (perk0, 1, 2 [...]) but I don't know how to display the icons from DataDragon API.

Can you help me please ?

Thank you!

dolejska-daniel commented 4 years ago

Hello, thank you for the interest!

Currently there is no easy easy way to do this, but there is easy way:

Source

// ...

$runes = $api->getStaticReforgedRunes()->runes;
$rune_paths = $api->getStaticReforgedRunePaths()->paths;

$match = $api->getMatch(...);
$player_stats = $match->participants[0]->stats;

// selected primary runes
DataDragonAPI::getReforgedRunePathIconO($rune_paths[$player_stats->perkPrimaryStyle]);
DataDragonAPI::getReforgedRuneIconO($runes[$player_stats->perk0]);
DataDragonAPI::getReforgedRuneIconO($runes[$player_stats->perk1]);
DataDragonAPI::getReforgedRuneIconO($runes[$player_stats->perk2]);
DataDragonAPI::getReforgedRuneIconO($runes[$player_stats->perk3]);

// selected secondary runes
DataDragonAPI::getReforgedRunePathIconO($rune_paths[$player_stats->perkSubStyle]);
DataDragonAPI::getReforgedRuneIconO($runes[$player_stats->perk4]);
DataDragonAPI::getReforgedRuneIconO($runes[$player_stats->perk5]);

Render Displayed Reforged Runes

NOTE: To be able to use StaticData endpoints you have to initialize DataDragon API - more about that here.

elreco commented 4 years ago

Nice! Thank you so much.

dolejska-daniel commented 4 years ago

Happy I could help! 😊 Feel free to ask in case you have any further questions :)