mirror of https://github.com/MingweiSamuel/Riven
40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
#![cfg_attr(feature = "nightly", feature(custom_test_frameworks))]
|
|
#![cfg_attr(feature = "nightly", test_runner(my_runner))]
|
|
fn my_runner(_: &[()]) { main() }
|
|
|
|
use riven::RiotApi;
|
|
use riven::consts::Region;
|
|
|
|
use tokio::runtime::Runtime;
|
|
|
|
fn main() {
|
|
let rt = Runtime::new().unwrap();
|
|
|
|
rt.block_on(async {
|
|
// Create RiotApi instance from key.
|
|
let riot_api = RiotApi::with_key(include_str!("../apikey.txt"));
|
|
|
|
// Get summoner data.
|
|
let summoner = riot_api.summoner_v4()
|
|
.get_by_summoner_name(Region::NA, "잘못").await
|
|
.expect("Get summoner failed.")
|
|
.expect("Summoner not found.");
|
|
|
|
// Print summoner name.
|
|
println!("{} Champion Masteries:", summoner.name);
|
|
|
|
// Get champion mastery data.
|
|
let masteries = riot_api.champion_mastery_v4()
|
|
.get_all_champion_masteries(Region::NA, &summoner.id).await
|
|
.expect("Get champion masteries failed.")
|
|
.unwrap();
|
|
|
|
// Print champioon masteries.
|
|
for (i, mastery) in masteries[..10].iter().enumerate() {
|
|
println!("{: >2}) {: <9} {: >7} ({})", i + 1,
|
|
mastery.champion_id.to_string(),
|
|
mastery.champion_points, mastery.champion_level);
|
|
}
|
|
});
|
|
}
|