mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-26 19:06:32 +00:00
add ValQueue enum
This commit is contained in:
parent
9bcb8ed5bf
commit
b4f6c67994
3 changed files with 88 additions and 2 deletions
36
riven/src/consts/val_queue.rs
Normal file
36
riven/src/consts/val_queue.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
// //
|
||||||
|
// ! //
|
||||||
|
// This file is automatically generated! //
|
||||||
|
// Do not directly edit! //
|
||||||
|
// //
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
|
||||||
|
use strum_macros::{ EnumString, EnumVariantNames, IntoStaticStr };
|
||||||
|
|
||||||
|
/// Valorant queue string IDs.
|
||||||
|
#[non_exhaustive]
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
#[derive(Eq, PartialEq, Hash)]
|
||||||
|
#[derive(EnumString, EnumVariantNames, IntoStaticStr)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum ValQueue {
|
||||||
|
/// Catch-all variant for new, unknown queue IDs.
|
||||||
|
#[strum(default)]
|
||||||
|
UNKNOWN(String),
|
||||||
|
|
||||||
|
COMPETITIVE = "competitive",
|
||||||
|
UNRATED = "unrated",
|
||||||
|
SPIKE_RUSH = "spikerush",
|
||||||
|
TOURNAMENT_MODE = "tournamentmode",
|
||||||
|
DEATHMATCH = "deathmatch",
|
||||||
|
/// One-for-all
|
||||||
|
REPLICATION = "onefa",
|
||||||
|
ESCALATION = "ggteam",
|
||||||
|
TEAM_DEATHMATCH = "hurm",
|
||||||
|
PEARL = "newmap",
|
||||||
|
SWIFTPLAY = "swiftplay",
|
||||||
|
}
|
||||||
|
|
||||||
|
serde_strum_unknown!(ValQueue);
|
32
riven/srcgen/consts/val_queue.rs.dt
Normal file
32
riven/srcgen/consts/val_queue.rs.dt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{{
|
||||||
|
const dotUtils = require('./dotUtils.js');
|
||||||
|
const valQueues = require('./.valQueues.json');
|
||||||
|
}}{{= dotUtils.preamble() }}
|
||||||
|
|
||||||
|
use strum_macros::{ EnumString, EnumVariantNames, IntoStaticStr };
|
||||||
|
|
||||||
|
/// Valorant queue string IDs.
|
||||||
|
#[non_exhaustive]
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
#[derive(Eq, PartialEq, Hash)]
|
||||||
|
#[derive(EnumString, EnumVariantNames, IntoStaticStr)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum ValQueue {
|
||||||
|
/// Catch-all variant for new, unknown queue IDs.
|
||||||
|
#[strum(default)]
|
||||||
|
UNKNOWN(String),
|
||||||
|
|
||||||
|
{{
|
||||||
|
for (const e of valQueues) {
|
||||||
|
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
|
||||||
|
}}
|
||||||
|
{{~ desc :line }}
|
||||||
|
/// {{= line }}
|
||||||
|
{{~}}
|
||||||
|
{{= e['x-name'] }} = {{= JSON.stringify(e['x-value']) }},
|
||||||
|
{{
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
serde_strum_unknown!(ValQueue);
|
|
@ -1,6 +1,6 @@
|
||||||
mod testutils;
|
mod testutils;
|
||||||
use riven::consts::*;
|
use riven::{consts::*, models::val_match_v1::MatchlistEntry};
|
||||||
use testutils::{riven_test, val_content_ranked, val_match_v1_get, val_match_v1_latest};
|
use testutils::{riot_api, riven_test, val_content_ranked, val_match_v1_get, val_match_v1_latest};
|
||||||
|
|
||||||
const ROUTE: ValPlatformRoute = ValPlatformRoute::NA;
|
const ROUTE: ValPlatformRoute = ValPlatformRoute::NA;
|
||||||
|
|
||||||
|
@ -23,3 +23,21 @@ async fn val_content_ranked_test() -> Result<(), String> {
|
||||||
async fn val_match_v1_latest_test() -> Result<(), String> {
|
async fn val_match_v1_latest_test() -> Result<(), String> {
|
||||||
val_match_v1_latest(ROUTE).await
|
val_match_v1_latest(ROUTE).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[riven_test]
|
||||||
|
async fn val_match_v1_get_matchlist_theuscon() -> Result<(), String> {
|
||||||
|
let account = riot_api()
|
||||||
|
.account_v1()
|
||||||
|
.get_by_riot_id(RegionalRoute::AMERICAS, "Theusçon", "8119")
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to get account: {}", e))?
|
||||||
|
.ok_or_else(|| "Account not found!".to_owned())?;
|
||||||
|
|
||||||
|
let matchlist = riot_api()
|
||||||
|
.val_match_v1()
|
||||||
|
.get_matchlist(ROUTE, &account.puuid)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to get matchlist: {}", e))?;
|
||||||
|
|
||||||
|
val_match_v1_get(ROUTE, matchlist.history.into_iter().map(|entry| entry.match_id)).await
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue