From 27a2ebe459aa6ff8ca06caf08b781336f11e2f56 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 12 Dec 2019 16:38:42 -0500 Subject: [PATCH] Base structs --- Cargo.lock | 1 + youmubot-osu/Cargo.toml | 1 + youmubot-osu/src/lib.rs | 206 +++++++++++++++++++++++++++++++++++++++ youmubot-osu/src/main.rs | 3 - 4 files changed, 208 insertions(+), 3 deletions(-) create mode 100644 youmubot-osu/src/lib.rs delete mode 100644 youmubot-osu/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 73f11ef..dba3942 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1666,6 +1666,7 @@ dependencies = [ name = "youmubot-osu" version = "0.1.0" dependencies = [ + "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "serenity 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/youmubot-osu/Cargo.toml b/youmubot-osu/Cargo.toml index 1739b62..48194f5 100644 --- a/youmubot-osu/Cargo.toml +++ b/youmubot-osu/Cargo.toml @@ -8,3 +8,4 @@ edition = "2018" [dependencies] serenity = "0.7" +chrono = "0.4.10" diff --git a/youmubot-osu/src/lib.rs b/youmubot-osu/src/lib.rs new file mode 100644 index 0000000..96b8b32 --- /dev/null +++ b/youmubot-osu/src/lib.rs @@ -0,0 +1,206 @@ +extern crate chrono; + +pub mod models { + use chrono::{DateTime, Duration, Utc}; + pub enum ApprovalStatus { + Loved, + Qualified, + Approved, + Ranked(DateTime), + Pending, + WIP, + Graveyarded, + } + pub struct Difficulty { + pub stars: f64, + pub aim: f64, + pub speed: f64, + + pub cs: f64, + pub od: f64, + pub ar: f64, + pub hp: f64, + + pub count_normal: u64, + pub count_slider: u64, + pub count_spinner: u64, + pub max_combo: u64, + } + pub enum Genre { + Any, + Unspecified, + VideoGame, + Anime, + Rock, + Pop, + Other, + Novelty, + HipHop, + Electronic, + } + pub enum Language { + Any, + Other, + English, + Japanese, + Chinese, + Instrumental, + Korean, + French, + German, + Swedish, + Italian, + } + pub enum Mode { + Std, + Taiko, + Mania, + Catch, + } + pub struct Beatmap { + // Beatmapset info + pub approval: ApprovalStatus, + pub submit_date: DateTime, + pub last_update: DateTime, + pub download_available: bool, + pub audio_available: bool, + // Media metadata + pub artist: String, + pub title: String, + pub beatmapset_id: u64, + pub bpm: f64, + pub creator: String, + pub creator_id: u64, + pub source: Option, + pub genre: Genre, + pub language: Language, + pub tags: Vec, + // Beatmap information + pub beatmap_id: u64, + pub difficulty_name: String, + pub difficulty: Difficulty, + pub drain_length: Duration, + pub total_length: Duration, + pub file_hash: String, + pub mode: Mode, + pub favourite_count: u64, + pub rating: f64, + pub play_count: u64, + pub pass_count: u64, + } + + pub struct UserEvent { + pub display_html: String, + pub beatmap_id: u64, + pub beatmapset_id: u64, + pub date: DateTime, + pub epic_factor: u8, + } + + pub struct User { + pub id: u64, + pub username: String, + pub joined: DateTime, + pub country: String, + // History + pub count_300: u64, + pub count_100: u64, + pub count_50: u64, + pub play_count: u64, + pub played_time: Duration, + pub ranked_score: u64, + pub total_score: u64, + pub count_ss: u64, + pub count_ssh: u64, + pub count_s: u64, + pub count_sh: u64, + pub count_a: u64, + pub events: Vec, + // Rankings + pub rank: u64, + pub level: f64, + pub pp: Option, + pub accuracy: f64, + } + + pub enum Rank { + SS, + SSH, + S, + SH, + A, + B, + C, + D, + F, + } + + pub struct Score { + pub id: u64, + pub username: String, + pub user_id: u64, + pub date: DateTime, + pub replay_available: bool, + + pub score: u64, + pub pp: f64, + pub rank: Rank, + pub mods: u64, // Later + + pub count_300: u64, + pub count_100: u64, + pub count_50: u64, + pub count_miss: u64, + pub count_katu: u64, + pub count_geki: u64, + pub max_combo: u64, + pub perfect: bool, + } + + pub mod request { + use super::Mode; + use chrono::{DateTime, Utc}; + pub enum UserID { + Username(String), + ID(u64), + Auto(String), + } + pub enum BeatmapRequestKind { + User(UserID), + Beatmap(u64), + Beatmapset(u64), + BeatmapHash(String), + } + pub struct BeatmapRequest { + pub since: DateTime, + pub kind: BeatmapRequestKind, + pub mode: Option, + pub converted: bool, + } + pub struct UserRequest { + pub user: UserID, + pub mode: Option, + pub event_days: Option, + } + pub struct ScoreRequest { + pub beatmap_id: u64, + pub user: Option, + pub mode: Option, + pub mods: u64, // Later + } + pub struct UserBestRequest { + pub user: UserID, + pub mode: Option, + } + pub struct UserRecentRequest { + pub user: UserID, + pub mode: Option, + } + } +} + +#[cfg(test)] +mod test { + #[test] + fn test() {} +} diff --git a/youmubot-osu/src/main.rs b/youmubot-osu/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/youmubot-osu/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -}