add level difficulty enums for later

This commit is contained in:
Reid 2023-09-06 16:45:08 -07:00
parent 52e3083530
commit 1dd0f382d0
Signed by: reidlab
GPG key ID: 6C9EAA3364F962C8
4 changed files with 55 additions and 32 deletions

View file

@ -35,7 +35,8 @@ _these features are implemented_
## todo
- swap to chrono instead of `(TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS'))` (thats REALLY ugly!!)
- patch `upload_level` to use 2.2 unlisted (friends only stuff)
- patch `upload_level` and `download_level` to use 2.2 unlisted after we get social shit (friends only stuff)
- in our level parsing, check for dual portals rather than just starting dual
- <small>green name users...</small>
- add more logging
- add more old endpoints
- add events, weekly, daily

View file

@ -1,5 +1,6 @@
pub mod accounts;
pub mod clean;
pub mod difficulty;
pub mod encryption;
pub mod format;
pub mod levels;

23
src/helpers/difficulty.rs Normal file
View file

@ -0,0 +1,23 @@
pub enum LevelDifficulty {
Auto,
Easy,
Normal,
Hard,
Harder,
Insane,
Demon
}
impl LevelDifficulty {
pub fn to_star_difficulty(&self) -> i32 {
match self {
LevelDifficulty::Auto => 5,
LevelDifficulty::Easy => 1,
LevelDifficulty::Normal => 2,
LevelDifficulty::Hard => 3,
LevelDifficulty::Harder => 4,
LevelDifficulty::Insane => 5,
LevelDifficulty::Demon => 5,
}
}
}

View file

@ -46,40 +46,38 @@ impl ObjectData {
object_prop_bool!("13", checked);
}
pub mod portal_speed {
pub enum PortalSpeed {
Slow,
Normal,
Medium,
Fast,
VeryFast
}
pub enum PortalSpeed {
Slow,
Normal,
Medium,
Fast,
VeryFast
}
impl PortalSpeed {
pub fn portal_speed(&self) -> f64 {
match self {
PortalSpeed::Slow => 251.16,
PortalSpeed::Normal => 311.58,
PortalSpeed::Medium => 387.42,
PortalSpeed::Fast => 478.0,
PortalSpeed::VeryFast => 576.0
}
impl PortalSpeed {
pub fn portal_speed(&self) -> f64 {
match self {
PortalSpeed::Slow => 251.16,
PortalSpeed::Normal => 311.58,
PortalSpeed::Medium => 387.42,
PortalSpeed::Fast => 478.0,
PortalSpeed::VeryFast => 576.0
}
}
}
pub fn id_to_portal_speed(id: i32) -> Option<portal_speed::PortalSpeed> {
pub fn id_to_portal_speed(id: i32) -> Option<PortalSpeed> {
match id {
200 => Some(portal_speed::PortalSpeed::Slow),
201 => Some(portal_speed::PortalSpeed::Normal),
202 => Some(portal_speed::PortalSpeed::Medium),
203 => Some(portal_speed::PortalSpeed::Fast),
1334 => Some(portal_speed::PortalSpeed::VeryFast),
200 => Some(PortalSpeed::Slow),
201 => Some(PortalSpeed::Normal),
202 => Some(PortalSpeed::Medium),
203 => Some(PortalSpeed::Fast),
1334 => Some(PortalSpeed::VeryFast),
_ => None,
}
}
pub fn get_seconds_from_xpos(pos: f64, start_speed: portal_speed::PortalSpeed, portals: Vec<ObjectData>) -> f64 {
pub fn get_seconds_from_xpos(pos: f64, start_speed: PortalSpeed, portals: Vec<ObjectData>) -> f64 {
let mut speed;
let mut last_obj_pos = 0.0;
let mut last_segment = 0.0;
@ -110,12 +108,12 @@ pub fn get_seconds_from_xpos(pos: f64, start_speed: portal_speed::PortalSpeed, p
pub fn measure_length(objects: Vec<ObjectData>, ka4: i32) -> f64 {
let start_speed = match ka4 {
0 => portal_speed::PortalSpeed::Normal,
1 => portal_speed::PortalSpeed::Slow,
2 => portal_speed::PortalSpeed::Medium,
3 => portal_speed::PortalSpeed::Fast,
4 => portal_speed::PortalSpeed::VeryFast,
_ => portal_speed::PortalSpeed::Normal
0 => PortalSpeed::Normal,
1 => PortalSpeed::Slow,
2 => PortalSpeed::Medium,
3 => PortalSpeed::Fast,
4 => PortalSpeed::VeryFast,
_ => PortalSpeed::Normal
};
let max_x_pos = objects