Two teams try and fill in any horizontal, vertical, or diagonal line on a bingo board by playing maps on osu! osu.bingo
osu
at microservice 78 lines 1.7 kB view raw
1use juniper::{FieldError, FieldResult, graphql_object}; 2use serde::{Deserialize, Serialize}; 3 4use crate::{database::DataContext, schema::Map}; 5 6#[derive(sqlx::FromRow, Serialize, Deserialize)] 7pub struct MapStats { 8 map_id: i32, 9 mod_string: String, 10 11 #[sqlx(try_from = "f32")] 12 star_rating: f64, 13 #[sqlx(try_from = "f32")] 14 bpm: f64, 15 length: i32, 16 17 #[sqlx(try_from = "f32")] 18 cs: f64, 19 #[sqlx(try_from = "f32")] 20 ar: f64, 21 #[sqlx(try_from = "f32")] 22 od: f64, 23 #[sqlx(try_from = "f32")] 24 hp: f64, 25} 26 27#[graphql_object(description = "The stats of some map with a certain mod combination", Context = DataContext)] 28impl MapStats { 29 /// The mods this selected combination applies to 30 pub fn mod_string(&self) -> &str { 31 &self.mod_string 32 } 33 34 /// Star Rating (how difficult) 35 pub fn star_rating(&self) -> f64 { 36 self.star_rating 37 } 38 39 /// Average BPM of map 40 pub fn bpm(&self) -> f64 { 41 self.bpm 42 } 43 44 /// Length (in seconds) of drain time 45 pub fn length(&self) -> i32 { 46 self.length 47 } 48 49 /// Circle Size 50 pub fn cs(&self) -> f64 { 51 self.cs 52 } 53 54 /// Approach Rate 55 pub fn ar(&self) -> f64 { 56 self.ar 57 } 58 59 /// Overall Difficulty 60 pub fn od(&self) -> f64 { 61 self.od 62 } 63 64 /// HP Drain 65 pub fn hp(&self) -> f64 { 66 self.hp 67 } 68 69 /// The map these stats represent 70 pub async fn map(&self, context: &DataContext) -> FieldResult<Map> { 71 context 72 .acquire() 73 .await 74 .get_map_by_id(self.map_id) 75 .await 76 .map_err(FieldError::from) 77 } 78}