Base structs

This commit is contained in:
Natsu Kagami 2019-12-12 16:38:42 -05:00
parent 2a0398b2a0
commit 27a2ebe459
4 changed files with 208 additions and 3 deletions

1
Cargo.lock generated
View file

@ -1666,6 +1666,7 @@ dependencies = [
name = "youmubot-osu" name = "youmubot-osu"
version = "0.1.0" version = "0.1.0"
dependencies = [ 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)", "serenity 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View file

@ -8,3 +8,4 @@ edition = "2018"
[dependencies] [dependencies]
serenity = "0.7" serenity = "0.7"
chrono = "0.4.10"

206
youmubot-osu/src/lib.rs Normal file
View file

@ -0,0 +1,206 @@
extern crate chrono;
pub mod models {
use chrono::{DateTime, Duration, Utc};
pub enum ApprovalStatus {
Loved,
Qualified,
Approved,
Ranked(DateTime<Utc>),
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<Utc>,
pub last_update: DateTime<Utc>,
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<String>,
pub genre: Genre,
pub language: Language,
pub tags: Vec<String>,
// 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<Utc>,
pub epic_factor: u8,
}
pub struct User {
pub id: u64,
pub username: String,
pub joined: DateTime<Utc>,
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<UserEvent>,
// Rankings
pub rank: u64,
pub level: f64,
pub pp: Option<u64>,
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<Utc>,
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<Utc>,
pub kind: BeatmapRequestKind,
pub mode: Option<Mode>,
pub converted: bool,
}
pub struct UserRequest {
pub user: UserID,
pub mode: Option<Mode>,
pub event_days: Option<u8>,
}
pub struct ScoreRequest {
pub beatmap_id: u64,
pub user: Option<UserID>,
pub mode: Option<Mode>,
pub mods: u64, // Later
}
pub struct UserBestRequest {
pub user: UserID,
pub mode: Option<Mode>,
}
pub struct UserRecentRequest {
pub user: UserID,
pub mode: Option<Mode>,
}
}
}
#[cfg(test)]
mod test {
#[test]
fn test() {}
}

View file

@ -1,3 +0,0 @@
fn main() {
println!("Hello, world!");
}