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;
+63 -63
View File
@@ -50,7 +50,7 @@ pub struct Container<'a> {
dimensions: Pos, // x,y
}
impl Container<'a> {
impl<'a> Container<'a> {
fn new(position: Pos, dimensions: Pos, outlined: bool) -> Container<'a> {
Self {
frame: vec![vec![' '; dimensions.x as usize]; dimensions.y as usize],
@@ -212,68 +212,68 @@ pub fn gen_outline(dimensions: Pos) -> Vec<Vec<char>> {
return charmap;
}
// testing functions
pub fn test_elements() {
use super::libgui_elements;
let mut containers = Vec::<Container>::new();
/*
//for _ in 0..10 {
// containers.push(generate_box());
//}
containers.push(Container::new((5, 5), (15, 5), true));
containers.push(Container::new((10, 3), (50, 20), true));
let mut bar = IndicatorBar::new((10, 6), 12);
let mut bar2 = IndicatorBar::new((10, 7), 12);
bar.set_value(43);
bar.abs = 101;
bar2.set_value(14);
bar2.abs = 15;
containers[1].elements.push(Box::new(bar));
containers[1].elements.push(Box::new(bar2));
let tbox = libgui_elements::TextBox::new(
String::from("panic attack simps"),
String::from("i have finally obtained evidence of his simpiness against tari and crystal, however i cannot reveal this evidence for now, however, once the contract is over NO ONE CAN STOP ME MWHAHAHAHAHA"),
Pos::new(25, 10),
Pos::new(10, 9),
true,
);
containers[1].elements.push(Box::new(tbox));
*/
containers.push(Container::new(Pos::new(0, 1), Pos::new(80, 24), true));
let tbox = libgui_elements::TextBox::new(
String::from("ANNOUNCEMENTS"),
String::from(
"CrystalRPG coming soon! XD
this is gonna be the best game ever",
),
Pos::new(25, 10),
Pos::new(0, 0),
true,
);
containers[0].elements.push(Box::new(&tbox));
let mut bar = IndicatorBar::new(Pos::new(7, 7), 12);
bar.set_value(70);
bar.set_text(String::from("ayo"));
containers[0].elements.push(Box::new(bar));
render_frame(containers);
return;
}
// // testing functions
//
// pub fn test_elements() {
// use super::libgui_elements;
//
// let mut containers = Vec::<Container>::new();
//
// /*
//
// //for _ in 0..10 {
// // containers.push(generate_box());
// //}
//
// containers.push(Container::new((5, 5), (15, 5), true));
// containers.push(Container::new((10, 3), (50, 20), true));
//
// let mut bar = IndicatorBar::new((10, 6), 12);
// let mut bar2 = IndicatorBar::new((10, 7), 12);
//
// bar.set_value(43);
// bar.abs = 101;
// bar2.set_value(14);
// bar2.abs = 15;
// containers[1].elements.push(Box::new(bar));
// containers[1].elements.push(Box::new(bar2));
//
// let tbox = libgui_elements::TextBox::new(
// String::from("panic attack simps"),
// String::from("i have finally obtained evidence of his simpiness against tari and crystal, however i cannot reveal this evidence for now, however, once the contract is over NO ONE CAN STOP ME MWHAHAHAHAHA"),
// Pos::new(25, 10),
// Pos::new(10, 9),
// true,
// );
//
// containers[1].elements.push(Box::new(tbox));
//
// */
//
// containers.push(Container::new(Pos::new(0, 1), Pos::new(80, 24), true));
//
// let tbox = libgui_elements::TextBox::new(
// String::from("ANNOUNCEMENTS"),
// String::from(
// "CrystalRPG coming soon! XD
// this is gonna be the best game ever",
// ),
// Pos::new(25, 10),
// Pos::new(0, 0),
// true,
// );
//
// containers[0].elements.push(Box::new(&tbox));
//
// let mut bar = IndicatorBar::new(Pos::new(7, 7), 12);
// bar.set_value(70);
// bar.set_text(String::from("ayo"));
//
// containers[0].elements.push(Box::new(bar));
// render_frame(containers);
//
// return;
// }
// function to generate a box in a random location on the screen.