reorganised some stuff and started coding another game
This commit is contained in:
@@ -20,7 +20,6 @@ pub mod system;
|
||||
pub mod user;
|
||||
pub use system::std as std;
|
||||
pub use user::bin::*;
|
||||
use crate::calc::Calculator;
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
|
||||
@@ -306,8 +306,8 @@ impl Renderer {
|
||||
self.screen_ref.chars[i][j].write(*col);
|
||||
}
|
||||
}
|
||||
self.internal_set_cursor_position(self.col_pos as u8, BUFFER_HEIGHT as u8 - 1);
|
||||
}
|
||||
self.internal_set_cursor_position(self.col_pos as u8, BUFFER_HEIGHT as u8 - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
mod functions;
|
||||
mod calc;
|
||||
|
||||
pub use calc::Calculator;
|
||||
@@ -0,0 +1,4 @@
|
||||
pub mod calc;
|
||||
pub mod editor;
|
||||
pub mod grapher;
|
||||
pub mod tasks;
|
||||
@@ -1,5 +0,0 @@
|
||||
//pub mod calc;
|
||||
mod functions;
|
||||
pub mod calc;
|
||||
|
||||
pub use calc::*;
|
||||
@@ -0,0 +1,25 @@
|
||||
pub struct Effect {
|
||||
pub EffectType: EffectType,
|
||||
pub potency: i32,
|
||||
pub duration: Option<i32>,
|
||||
}
|
||||
|
||||
pub enum EffectType {
|
||||
Poison,
|
||||
Regeneration,
|
||||
|
||||
Harming,
|
||||
Healing,
|
||||
|
||||
Speed,
|
||||
Slowness,
|
||||
Stunned,
|
||||
Confused,
|
||||
|
||||
Strength,
|
||||
Weakness,
|
||||
|
||||
OnFire,
|
||||
|
||||
Invisible,
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
use hashbrown::HashMap;
|
||||
|
||||
use crate::user::lib::geometry::Position;
|
||||
use super::{map::Map, player::Player};
|
||||
|
||||
pub struct Game {
|
||||
pub score: u32,
|
||||
pub player: Player,
|
||||
pub map: Map,
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
pub struct Helmet {
|
||||
name: &'static str,
|
||||
lore: &'static str,
|
||||
stats: ArmourStats,
|
||||
}
|
||||
|
||||
pub struct Chestplate {
|
||||
name: &'static str,
|
||||
lore: &'static str,
|
||||
stats: ArmourStats,
|
||||
}
|
||||
|
||||
pub struct Boots {
|
||||
name: &'static str,
|
||||
lore: &'static str,
|
||||
stats: ArmourStats,
|
||||
}
|
||||
|
||||
pub struct ArmourStats {
|
||||
defence: i32,
|
||||
health_bonus: i32,
|
||||
mana_bonus: i32,
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
pub trait Item {
|
||||
fn name(&self) -> &str;
|
||||
fn description(&self) -> &str;
|
||||
|
||||
fn sell_price(&self) -> i32;
|
||||
fn buy_price(&self) -> i32;
|
||||
}
|
||||
|
||||
pub mod armour;
|
||||
pub mod weapons;
|
||||
pub mod potions;
|
||||
@@ -0,0 +1,10 @@
|
||||
use hashbrown::HashMap;
|
||||
|
||||
pub struct Map {
|
||||
tiles: HashMap<(i32, i32), Tile>
|
||||
}
|
||||
|
||||
pub enum Tile {
|
||||
Empty,
|
||||
Wall,
|
||||
}
|
||||
@@ -1 +1,7 @@
|
||||
mod entity;
|
||||
mod player;
|
||||
mod map;
|
||||
mod effect;
|
||||
mod items;
|
||||
|
||||
pub mod game;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
use alloc::{boxed::Box, string::String, vec::Vec};
|
||||
|
||||
use super::{effect::Effect, items::{armour::{Boots, Chestplate, Helmet}, Item}};
|
||||
|
||||
pub struct Player {
|
||||
pub name: String,
|
||||
|
||||
pub health: f64,
|
||||
pub max_health: f64,
|
||||
|
||||
pub mana: f64,
|
||||
pub max_mana: f64,
|
||||
|
||||
pub defence: f64,
|
||||
pub agility: f64,
|
||||
|
||||
pub stamina: f64,
|
||||
pub max_stamina: f64,
|
||||
|
||||
pub level: f64,
|
||||
pub experience: f64,
|
||||
pub skill_points: f64,
|
||||
|
||||
pub helmet: Option<Helmet>,
|
||||
pub chestplate: Option<Chestplate>,
|
||||
pub boots: Option<Boots>,
|
||||
|
||||
pub inventory: [Box<dyn Item>; 20],
|
||||
|
||||
pub effects: Vec<Effect>,
|
||||
}
|
||||
|
||||
impl Player {
|
||||
const BASE_MAX_HEALTH: f64 = 100.0;
|
||||
const BASE_MAX_MANA: f64 = 100.0;
|
||||
const BASE_MAX_STAMINA: f64 = 100.0;
|
||||
|
||||
const BASE_DAMAGE: f64 = 0.0;
|
||||
const BASE_DEFENCE: f64 = 0.0;
|
||||
const BASE_AGILITY: f64 = 0.0;
|
||||
|
||||
const BASE_LEVEL : f64 = 1.0;
|
||||
}
|
||||
@@ -3,4 +3,5 @@ pub mod gameoflife;
|
||||
pub mod crystalrpg;
|
||||
pub mod pong;
|
||||
pub mod snake;
|
||||
pub mod paper_rs;
|
||||
pub mod paper;
|
||||
pub mod tetris;
|
||||
@@ -1,9 +1,9 @@
|
||||
use core::any::Any;
|
||||
|
||||
use alloc::{boxed::Box, format, string::String, vec::Vec, vec};
|
||||
use alloc::{boxed::Box, format, string::String, vec::Vec};
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::{std::{self, application::{Application, Error}, io::{Color, ColorCode, Display, KeyStroke, Stdin}, render::{ColouredChar, Dimensions, Frame, Position, RenderError}, time}, user::{bin::games::asteroids::Game, lib::libgui::cg_core::CgComponent}};
|
||||
use crate::{std::{self, application::{Application, Error}, io::{Color, ColorCode, Display, KeyStroke, Stdin}, render::{ColouredChar, Dimensions, Frame, Position, RenderError}, time}, user::lib::libgui::cg_core::CgComponent};
|
||||
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
@@ -48,7 +48,7 @@ impl Application for GameBoard {
|
||||
}
|
||||
}
|
||||
|
||||
async fn run(&mut self, args: Vec<String>) -> Result<(), Error> {
|
||||
async fn run(&mut self, _args: Vec<String>) -> Result<(), Error> {
|
||||
let _display = Display::borrow();
|
||||
|
||||
'outer: loop {
|
||||
@@ -1,4 +0,0 @@
|
||||
/// this game is basically a ripoff of paper.io
|
||||
pub mod paper;
|
||||
|
||||
pub use paper::GameBoard;
|
||||
@@ -4,7 +4,6 @@ use alloc::vec::Vec;
|
||||
use core::any::Any;
|
||||
use async_trait::async_trait;
|
||||
use crate::std::application::{Application, Error};
|
||||
use crate::std;
|
||||
use crate::std::render::{BUFFER_HEIGHT, BUFFER_WIDTH, ColorCode, ColouredChar, Dimensions, Frame, Position, RenderError};
|
||||
use crate::std::io::{Color, Display, KeyStroke, Stdin};
|
||||
use crate::std::time::Timer;
|
||||
@@ -27,7 +26,7 @@ impl Application for Game {
|
||||
}
|
||||
|
||||
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
|
||||
let d = Display::borrow();
|
||||
let _d = Display::borrow();
|
||||
|
||||
let mut update_time = Timer::new(0.1);
|
||||
|
||||
@@ -124,7 +123,7 @@ impl CgComponent for Game {
|
||||
fn render(&self) -> Result<Frame, RenderError> {
|
||||
let mut frame = Frame::new(Dimensions::new(0, 0), Dimensions::new(80, 25))?;
|
||||
|
||||
for y in (0..5) {
|
||||
for y in 0..5 {
|
||||
frame.write(Position::new(self.player1.pos.x, self.player1.pos.y + y -2), ColouredChar::coloured('▓', ColorCode::new(Color::Cyan, Color::Black))).unwrap();
|
||||
frame.write(Position::new(self.player2.pos.x, self.player2.pos.y + y -2), ColouredChar::coloured('▓', ColorCode::new(Color::Cyan, Color::Black))).unwrap();
|
||||
}
|
||||
|
||||
+4
-13
@@ -1,14 +1,5 @@
|
||||
|
||||
pub mod calc;
|
||||
pub mod crystalfetch;
|
||||
pub mod rickroll;
|
||||
pub mod apps;
|
||||
pub mod games;
|
||||
pub mod utils;
|
||||
pub mod shell;
|
||||
pub mod tasks;
|
||||
pub mod editor;
|
||||
mod gigachad_detector;
|
||||
|
||||
//mod shellrewrite;
|
||||
|
||||
mod grapher;
|
||||
|
||||
mod games;
|
||||
pub mod shellrewrite;
|
||||
+58
-64
@@ -1,30 +1,56 @@
|
||||
// External crates
|
||||
use lazy_static::lazy_static;
|
||||
use spin::Mutex;
|
||||
use vga::{
|
||||
writers::{PrimitiveDrawing, GraphicsWriter, Graphics640x480x16},
|
||||
colors::Color16,
|
||||
};
|
||||
|
||||
use alloc::{boxed::Box, format, string::{String, ToString}, vec, vec::Vec};
|
||||
use vga::writers::{PrimitiveDrawing};
|
||||
// Standard library
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
format,
|
||||
string::{String, ToString},
|
||||
vec,
|
||||
vec::Vec,
|
||||
};
|
||||
|
||||
// Internal crates
|
||||
use crate::{
|
||||
printerr,
|
||||
println,
|
||||
};
|
||||
|
||||
use crate::std::{
|
||||
application::{Application, Error, Exit},
|
||||
time::{timer, wait},
|
||||
io::{
|
||||
Color, write, Screen, Stdin, Serial, KeyStroke
|
||||
std::{
|
||||
application::{Application, Error, Exit},
|
||||
time::{timer, wait},
|
||||
io::{Color, write, Screen, Stdin, Serial, KeyStroke, Display},
|
||||
},
|
||||
};
|
||||
use crate::std::io::Display;
|
||||
|
||||
use crate::user::{
|
||||
lib::libgui::{
|
||||
cg_core::{CgComponent, CgKeyboardCapture},
|
||||
cg_widgets::CgDialog,
|
||||
user::{
|
||||
lib::libgui::{
|
||||
cg_core::{CgComponent, CgKeyboardCapture},
|
||||
cg_widgets::CgDialog,
|
||||
},
|
||||
bin::{
|
||||
apps::{
|
||||
calc::Calculator,
|
||||
editor::Editor,
|
||||
grapher::Grapher,
|
||||
tasks::Tasks,
|
||||
},
|
||||
games::{
|
||||
asteroids::Game as AsteroidsGame,
|
||||
gameoflife::GameOfLife,
|
||||
paper::GameBoard,
|
||||
pong::Game as PongGame,
|
||||
snake::Game as SnakeGame,
|
||||
// tetris::TetrisEngine,
|
||||
},
|
||||
utils::{
|
||||
crystalfetch::CrystalFetch,
|
||||
gigachad_detector::GigachadDetector,
|
||||
rickroll::Rickroll,
|
||||
},
|
||||
},
|
||||
},
|
||||
bin::*,
|
||||
bin::games::*,
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
@@ -42,7 +68,7 @@ pub async fn command_handler() {
|
||||
pub async fn eventloop() {
|
||||
println!("running!");
|
||||
|
||||
let mut fetch = crystalfetch::CrystalFetch::new();
|
||||
let mut fetch = CrystalFetch::new();
|
||||
let string = String::from(" ");
|
||||
let mut vec: Vec<String> = Vec::new();
|
||||
vec.push(string);
|
||||
@@ -99,21 +125,21 @@ async fn exec() -> Result<(), Error> {
|
||||
|
||||
match cmd.as_str() {
|
||||
"calculate" | "calc" | "solve" => {
|
||||
let mut cmd = calc::Calculator::new();
|
||||
let mut cmd = Calculator::new();
|
||||
cmd.run(args).await?;
|
||||
}
|
||||
|
||||
"rickroll" => {
|
||||
let mut cmd = rickroll::Rickroll::new();
|
||||
let mut cmd = Rickroll::new();
|
||||
cmd.run(args).await?;
|
||||
}
|
||||
|
||||
"crystalfetch" => {
|
||||
let mut cmd = crystalfetch::CrystalFetch::new();
|
||||
let mut cmd = CrystalFetch::new();
|
||||
cmd.run(args).await?;
|
||||
}
|
||||
"tasks" => {
|
||||
let mut cmd = tasks::Tasks::new();
|
||||
let mut cmd = Tasks::new();
|
||||
cmd.run(args).await?;
|
||||
}
|
||||
"VGA" => {
|
||||
@@ -126,20 +152,20 @@ async fn exec() -> Result<(), Error> {
|
||||
mode.draw_line((80, 60), (120, 420), Color16::Cyan);
|
||||
}
|
||||
"graph" => {
|
||||
grapher::Grapher::new().run(args).await?;
|
||||
Grapher::new().run(args).await?;
|
||||
}
|
||||
"games/snake" => {
|
||||
snake::Game::new().run(args).await?;
|
||||
SnakeGame::new().run(args).await?;
|
||||
}
|
||||
"games/asteroids" => {
|
||||
let mut asteroid_game = asteroids::Game::new();
|
||||
let mut asteroid_game = AsteroidsGame::new();
|
||||
asteroid_game.run(args).await?;
|
||||
}
|
||||
"games/pong" => {
|
||||
pong::Game::new().run(args).await?;
|
||||
PongGame::new().run(args).await?;
|
||||
}
|
||||
"games/paper.rs" => {
|
||||
let mut game = paper_rs::GameBoard::new();
|
||||
let mut game = GameBoard::new();
|
||||
game.run(args).await?;
|
||||
}
|
||||
"serial" => {
|
||||
@@ -147,34 +173,24 @@ async fn exec() -> Result<(), Error> {
|
||||
println!("{}", c);
|
||||
}
|
||||
"games/gameoflife" => {
|
||||
let mut game = gameoflife::GameOfLife::new();
|
||||
let mut game = GameOfLife::new();
|
||||
game.run(Vec::new()).await?;
|
||||
}
|
||||
"games/tetris" => {
|
||||
// let mut game = tetris::TetrisEngine::new();
|
||||
// let mut game = TetrisEngine::new();
|
||||
// game.run(Vec::new()).await?;
|
||||
}
|
||||
|
||||
"gigachad?" => {
|
||||
let mut detector = gigachad_detector::GigachadDetector::new();
|
||||
let mut detector = GigachadDetector::new();
|
||||
detector.run(args).await?;
|
||||
}
|
||||
|
||||
"editor" => {
|
||||
let mut editor = editor::Editor::new();
|
||||
let mut editor = Editor::new();
|
||||
editor.run(args).await?;
|
||||
}
|
||||
|
||||
"wait" => {
|
||||
if args.len() != 1 {
|
||||
return Err(Error::CommandFailed("exactly one argument must be provided".to_string()))
|
||||
}
|
||||
if let Ok(time) = args[0].parse::<u64>() {
|
||||
wait(time as f64);
|
||||
println!("waited for {}s", time);
|
||||
}
|
||||
}
|
||||
|
||||
// direct OS functions (not applications)
|
||||
"echo" => {
|
||||
println!(
|
||||
@@ -351,25 +367,3 @@ async fn setup_ui() {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+137
-137
@@ -1,158 +1,158 @@
|
||||
// importing libraries
|
||||
use async_trait::async_trait;
|
||||
use lazy_static::lazy_static;
|
||||
use spin::Mutex;
|
||||
use x86_64::instructions::interrupts;
|
||||
// // importing libraries
|
||||
// use async_trait::async_trait;
|
||||
// use lazy_static::lazy_static;
|
||||
// use spin::Mutex;
|
||||
// use x86_64::instructions::interrupts;
|
||||
|
||||
use alloc::{boxed::Box, string::{String, ToString}, vec, vec::Vec};
|
||||
// use alloc::{boxed::Box, string::{String, ToString}, vec, vec::Vec};
|
||||
|
||||
use crate::{
|
||||
kernel::tasks::{executor::Executor, Task},
|
||||
std::application::{Application, Error},
|
||||
std::io::{print, println, Stdin, Screen},
|
||||
user::bin::*,
|
||||
};
|
||||
use crate::std::io::{Color, write};
|
||||
use crate::user::bin::gigachad_detector::GigachadDetector;
|
||||
// use crate::{
|
||||
// kernel::tasks::{executor::Executor, Task},
|
||||
// std::application::{Application, Error},
|
||||
// std::io::{print, println, Stdin, Screen},
|
||||
// user::bin::*,
|
||||
// };
|
||||
// use crate::std::io::{Color, write};
|
||||
// use crate::user::bin::gigachad_detector::GigachadDetector;
|
||||
|
||||
use super::*;
|
||||
// use super::*;
|
||||
|
||||
// [ CRYSTAL SHELL ]
|
||||
// the purpose of this module is to provide a basic unix shell like experience for the user
|
||||
// to interact with the OS
|
||||
// this is a rewrite of my original shell.
|
||||
// this shell should support:
|
||||
// - browsing the virtual filesystem
|
||||
// - executing programs
|
||||
// - basic arithmetic
|
||||
// - chained execution ( multiple commands linked together) eg: '5 + 5 | echo' which calculates
|
||||
// the result of 5 + 5 and then sends the result to an echo command which prints it to console
|
||||
// // [ CRYSTAL SHELL ]
|
||||
// // the purpose of this module is to provide a basic unix shell like experience for the user
|
||||
// // to interact with the OS
|
||||
// // this is a rewrite of my original shell.
|
||||
// // this shell should support:
|
||||
// // - browsing the virtual filesystem
|
||||
// // - executing programs
|
||||
// // - basic arithmetic
|
||||
// // - chained execution ( multiple commands linked together) eg: '5 + 5 | echo' which calculates
|
||||
// // the result of 5 + 5 and then sends the result to an echo command which prints it to console
|
||||
|
||||
|
||||
/// starts the shell
|
||||
/// this function should be directly called by main.rs or by an init system
|
||||
// /// starts the shell
|
||||
// /// this function should be directly called by main.rs or by an init system
|
||||
|
||||
|
||||
|
||||
fn run_task(task_name: String, args: Vec<String>) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
// fn run_task(task_name: String, args: Vec<String>) -> Result<(), String> {
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
pub async fn userspace() -> Result<(), String> {
|
||||
let mut executor = Executor::new();
|
||||
// pub async fn userspace() -> Result<(), String> {
|
||||
// let mut executor = Executor::new();
|
||||
|
||||
let mut shell = Shell::new();
|
||||
shell.run(vec![]).await.unwrap();
|
||||
// let mut shell = Shell::new();
|
||||
// shell.run(vec![]).await.unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
struct Shell {
|
||||
history: Vec<String>,
|
||||
}
|
||||
// struct Shell {
|
||||
// history: Vec<String>,
|
||||
// }
|
||||
|
||||
#[async_trait]
|
||||
impl Application for Shell {
|
||||
fn new() -> Shell {
|
||||
Shell {
|
||||
history: Vec::new(),
|
||||
}
|
||||
}
|
||||
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
|
||||
loop {
|
||||
self.prompt();
|
||||
let input = Stdin::readline().await;
|
||||
let (cmd, args) = self.parse_args(input).unwrap();
|
||||
self.run_cmd(cmd, args).await.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
// #[async_trait]
|
||||
// impl Application for Shell {
|
||||
// fn new() -> Shell {
|
||||
// Shell {
|
||||
// history: Vec::new(),
|
||||
// }
|
||||
// }
|
||||
// async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
|
||||
// loop {
|
||||
// self.prompt();
|
||||
// let input = Stdin::readline().await;
|
||||
// let (cmd, args) = self.parse_args(input).unwrap();
|
||||
// self.run_cmd(cmd, args).await.unwrap();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
impl Shell {
|
||||
fn prompt(&mut self) {
|
||||
write(format_args!("\n Crystal> "), (Color::Cyan, Color::Black));
|
||||
}
|
||||
// impl Shell {
|
||||
// fn prompt(&mut self) {
|
||||
// write(format_args!("\n Crystal> "), (Color::Cyan, Color::Black));
|
||||
// }
|
||||
|
||||
// fn exec<R, T: Fn() -> R>(command: T) -> Result<R, Error> { // this command runs when a shell command is executed
|
||||
// Ok(command())
|
||||
// }
|
||||
async fn run_cmd(&mut self, cmd: String, args: Vec<String>) -> Result<(), Error> {
|
||||
match cmd.as_str() {
|
||||
"calculate" | "calc" | "solve" => {
|
||||
let mut cmd = calc::Calculator::new();
|
||||
cmd.run(args).await?;
|
||||
}
|
||||
"rickroll" => {
|
||||
let mut cmd = rickroll::Rickroll::new();
|
||||
cmd.run(args).await?;
|
||||
}
|
||||
"crystalfetch" => {
|
||||
let mut cmd = crystalfetch::CrystalFetch::new();
|
||||
cmd.run(args).await?;
|
||||
}
|
||||
"tasks" => {
|
||||
let mut cmd = tasks::Tasks::new();
|
||||
cmd.run(args).await?;
|
||||
}
|
||||
"play" => {
|
||||
let mut gameloop = crystal_rpg::init::GameLoop::new();
|
||||
gameloop.run(args).await?;
|
||||
}
|
||||
"echo" => {
|
||||
println!(
|
||||
"Crystal: '{}'",
|
||||
" ".join(args)
|
||||
)
|
||||
}
|
||||
"clear" => {
|
||||
Screen::clear();
|
||||
}
|
||||
"print" => {
|
||||
use crate::std::os::OS;
|
||||
let x: String = OS.lock().version.clone();
|
||||
println!("{}", x);
|
||||
}
|
||||
"snake" => {
|
||||
let mut game = snake::Game::new();
|
||||
game.run(Vec::new()).await?;
|
||||
}
|
||||
"gigachad?" => {
|
||||
let mut gigachad_detector = GigachadDetector::new();
|
||||
gigachad_detector.run(args).await?;
|
||||
}
|
||||
"test_features" => {
|
||||
use crate::std::random::Random;
|
||||
println!("{}", Random::int(0, 10));
|
||||
}
|
||||
_ => {
|
||||
return Err(Error::UnknownCommand(
|
||||
"command not yet implemented".to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn parse_args(&self, command: String) -> Result<(String, Vec<String>), String> {
|
||||
let mut args: Vec<String> = Vec::new();
|
||||
// // fn exec<R, T: Fn() -> R>(command: T) -> Result<R, Error> { // this command runs when a shell command is executed
|
||||
// // Ok(command())
|
||||
// // }
|
||||
// async fn run_cmd(&mut self, cmd: String, args: Vec<String>) -> Result<(), Error> {
|
||||
// match cmd.as_str() {
|
||||
// "calculate" | "calc" | "solve" => {
|
||||
// let mut cmd = calc::Calculator::new();
|
||||
// cmd.run(args).await?;
|
||||
// }
|
||||
// "rickroll" => {
|
||||
// let mut cmd = rickroll::Rickroll::new();
|
||||
// cmd.run(args).await?;
|
||||
// }
|
||||
// "crystalfetch" => {
|
||||
// let mut cmd = crystalfetch::CrystalFetch::new();
|
||||
// cmd.run(args).await?;
|
||||
// }
|
||||
// "tasks" => {
|
||||
// let mut cmd = tasks::Tasks::new();
|
||||
// cmd.run(args).await?;
|
||||
// }
|
||||
// "play" => {
|
||||
// let mut gameloop = crystal_rpg::init::GameLoop::new();
|
||||
// gameloop.run(args).await?;
|
||||
// }
|
||||
// "echo" => {
|
||||
// println!(
|
||||
// "Crystal: '{}'",
|
||||
// " ".join(args)
|
||||
// )
|
||||
// }
|
||||
// "clear" => {
|
||||
// Screen::clear();
|
||||
// }
|
||||
// "print" => {
|
||||
// use crate::std::os::OS;
|
||||
// let x: String = OS.lock().version.clone();
|
||||
// println!("{}", x);
|
||||
// }
|
||||
// "snake" => {
|
||||
// let mut game = snake::Game::new();
|
||||
// game.run(Vec::new()).await?;
|
||||
// }
|
||||
// "gigachad?" => {
|
||||
// let mut gigachad_detector = GigachadDetector::new();
|
||||
// gigachad_detector.run(args).await?;
|
||||
// }
|
||||
// "test_features" => {
|
||||
// use crate::std::random::Random;
|
||||
// println!("{}", Random::int(0, 10));
|
||||
// }
|
||||
// _ => {
|
||||
// return Err(Error::UnknownCommand(
|
||||
// "command not yet implemented".to_string(),
|
||||
// ))
|
||||
// }
|
||||
// }
|
||||
// Ok(())
|
||||
// }
|
||||
// fn parse_args(&self, command: String) -> Result<(String, Vec<String>), String> {
|
||||
// let mut args: Vec<String> = Vec::new();
|
||||
|
||||
for arg in command.split(" ").collect::<Vec<&str>>() {
|
||||
match arg {
|
||||
"" => {}
|
||||
x => args.push(x.to_string()),
|
||||
}
|
||||
}
|
||||
// for arg in command.split(" ").collect::<Vec<&str>>() {
|
||||
// match arg {
|
||||
// "" => {}
|
||||
// x => args.push(x.to_string()),
|
||||
// }
|
||||
// }
|
||||
|
||||
let cmd: String;
|
||||
if args.len() > 0 {
|
||||
cmd = args[0].clone();
|
||||
args.remove(0);
|
||||
}
|
||||
else {
|
||||
return Err("command was empty.".to_string());
|
||||
};
|
||||
// let cmd: String;
|
||||
// if args.len() > 0 {
|
||||
// cmd = args[0].clone();
|
||||
// args.remove(0);
|
||||
// }
|
||||
// else {
|
||||
// return Err("command was empty.".to_string());
|
||||
// };
|
||||
|
||||
Ok((cmd, args))
|
||||
}
|
||||
}
|
||||
// Ok((cmd, args))
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ use crate::std::{
|
||||
};
|
||||
use crate::println;
|
||||
|
||||
const _CRYSTAL_LOGO: &str =
|
||||
"\n $$$$$$\\ $$\\ $$\\ $$$$$$\\ $$$$$$\\
|
||||
const _CRYSTAL_LOGO: &str ="\n
|
||||
$$$$$$\\ $$\\ $$\\ $$$$$$\\ $$$$$$\\
|
||||
$$ __$$\\ $$ | $$ $$ __$$\\$$ __$$\\
|
||||
$$ / \\__|$$$$$$\\ $$\\ $$\\ $$$$$$$\\$$$$$$\\ $$$$$$\\ $$ $$ / $$ $$ / \\__|
|
||||
$$ | $$ __$$\\$$ | $$ $$ _____\\_$$ _| \\____$$\\$$ $$ | $$ \\$$$$$$\\
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod crystalfetch;
|
||||
pub mod gigachad_detector;
|
||||
pub mod rickroll;
|
||||
Reference in New Issue
Block a user