flag
This commit is contained in:
parent
8a1d50c027
commit
3ef8ddb66a
37
src/run.rs
37
src/run.rs
@ -1,8 +1,31 @@
|
|||||||
use crate::timer::{TimerFixed,Realtime,Paused,Unpaused};
|
use crate::timer::{TimerFixed,Realtime,Paused,Unpaused};
|
||||||
use crate::integer::Time;
|
use crate::integer::Time;
|
||||||
|
|
||||||
pub enum InvalidationReason{
|
pub enum FlagReason{
|
||||||
|
Anticheat,
|
||||||
|
StyleChange,
|
||||||
|
Clock,
|
||||||
|
Pause,
|
||||||
|
Flying,
|
||||||
|
Gravity,
|
||||||
|
Timescale,
|
||||||
|
TimeTravel,
|
||||||
|
Teleport,
|
||||||
|
}
|
||||||
|
impl ToString for FlagReason{
|
||||||
|
fn to_string(&self)->String{
|
||||||
|
match self{
|
||||||
|
FlagReason::Anticheat=>"Passed through anticheat zone.",
|
||||||
|
FlagReason::StyleChange=>"Changed style.",
|
||||||
|
FlagReason::Clock=>"Incorrect clock. (This can be caused by internet hiccups)",
|
||||||
|
FlagReason::Pause=>"Pausing is not allowed in this style.",
|
||||||
|
FlagReason::Flying=>"Flying is not allowed in this style.",
|
||||||
|
FlagReason::Gravity=>"Gravity modification is not allowed in this style.",
|
||||||
|
FlagReason::Timescale=>"Timescale is not allowed in this style.",
|
||||||
|
FlagReason::TimeTravel=>"Time travel is not allowed in this style.",
|
||||||
|
FlagReason::Teleport=>"Illegal teleport.",
|
||||||
|
}.to_owned()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -25,15 +48,15 @@ enum RunState{
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Run{
|
pub struct Run{
|
||||||
invalidated:Option<InvalidationReason>,
|
|
||||||
state:RunState,
|
state:RunState,
|
||||||
|
flagged:Option<FlagReason>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Run{
|
impl Run{
|
||||||
pub fn new()->Self{
|
pub fn new()->Self{
|
||||||
Self{
|
Self{
|
||||||
invalidated:None,
|
|
||||||
state:RunState::Created,
|
state:RunState::Created,
|
||||||
|
flagged:None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn time(&self,time:Time)->Time{
|
pub fn time(&self,time:Time)->Time{
|
||||||
@ -67,4 +90,10 @@ impl Run{
|
|||||||
RunState::Finished{..}=>Err(Error::AlreadyFinished),
|
RunState::Finished{..}=>Err(Error::AlreadyFinished),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn flag(&mut self,flag_reason:FlagReason){
|
||||||
|
//don't replace the first reason the run was flagged
|
||||||
|
if self.flagged.is_none(){
|
||||||
|
self.flagged=Some(flag_reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user