added the gigachad detector

This commit is contained in:
FantasyPvP
2023-09-27 22:50:28 +01:00
parent 067d780fdf
commit 49bc77e44a
9 changed files with 176 additions and 72 deletions
+16 -1
View File
@@ -412,10 +412,24 @@ fn calculate_inner(mut equation: String) -> Result<f64, Error> {
fn tokenise(equation: &str) -> Result<Vec<Token>, Error> {
let mut tokens = Vec::new();
let mut current_num = "".to_string();
let current_string: String = "".to_string();
let mut current_string: String = "".to_string();
let mut is_var = false;
'mainloop: for (x, character) in equation.chars().enumerate() {
match character {
'a'..='z' => {
is_var = true;
current_string.push(character);
}
_ => {
if is_var {
tokens.push(Token::Func(current_string.clone()));
}
is_var = false;
}
}
match character {
'0'..='9' => current_num.push(character),
@@ -478,6 +492,7 @@ enum Token {
Operator(Operator),
Bracket(char),
Null,
Func(String),
}
+51
View File
@@ -0,0 +1,51 @@
use async_trait::async_trait;
use alloc::{boxed::Box, string::String, vec::Vec};
use crate::{
std::os::OS,
std::io::{Color, write},
println,
std::application::{
Application,
Error,
},
};
const GIGACHAD: &'static str = "fantasypvp";
pub struct GigachadDetector {}
#[async_trait]
impl Application for GigachadDetector {
fn new() -> Self {
Self {}
}
async fn run(&mut self, args: Vec<String>) -> Result<(), Error> {
for arg in args {
self.detect_gigachad_by_username(&arg)
}
Ok(())
}
}
impl GigachadDetector {
pub fn detect_gigachad_by_username(&self, username: &str) {
if username == GIGACHAD {
println!("{} is a gigachad B'YES", username);
println!("
/$$$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$
|_____ $$ | $$ / $$ /$$__ $$| $$____/
/$$/ | $$/ $$/| $$ \\ $$| $$
/$$/ \\ $$$$/ | $$ | $$| $$$$$$$
/$$/ >$$ $$ | $$ | $$|_____ $$
/$$/ /$$/\\ $$| $$/$$ $$ /$$ \\ $$
/$$$$$$$$| $$ \\ $$| $$$$$$/| $$$$$$/
|________/|__/ |__/ \\____ $$$ \\______/
\\__/
")
} else {
println!("{} is not a gigachad", username);
}
}
}
+1
View File
@@ -5,3 +5,4 @@ pub mod rickroll;
pub mod shell;
//pub mod shellrewrite;
pub mod tasks;
mod gigachad_detector;
+4 -7
View File
@@ -14,6 +14,7 @@ use crate::{
std::application::{Application, Error},
user::bin::*,
};
use crate::user::bin::gigachad_detector::GigachadDetector;
lazy_static! {
pub static ref CMD: Mutex<CommandHandler> = Mutex::new(CommandHandler::new());
@@ -121,13 +122,9 @@ async fn exec() -> Result<(), Error> {
"switch" => {
crate::std::io::switch_mode();
}
"random" => {
use crate::std::random::Random;
let vec = Vec::from(["is", "is not", "is absolutely"]);
let vec2 = Vec::from(["simp", "gigachad", "genius", "bozo", "Non simp"]);
let sel = *Random::selection(&vec);
let sel2 = *Random::selection(&vec2);
println!("panic attack {} a {}", sel, sel2);
"gigachad?" => {
let mut gigachad_detector = GigachadDetector::new();
gigachad_detector.run(args).await?;
}
"filesystem" => {
use crate::std::io;