Usable release, partially complete characters.ron, base functionality achieved in events.
This commit is contained in:
323
data/characters.ron
Normal file
323
data/characters.ron
Normal file
@@ -0,0 +1,323 @@
|
|||||||
|
[
|
||||||
|
Character (
|
||||||
|
id: AbigailWilliams,
|
||||||
|
name: "Abigail Williams",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [
|
||||||
|
BettyParris,
|
||||||
|
DeputyGovernorDanforth,
|
||||||
|
ReverendParris,
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
ElizabethProctor,
|
||||||
|
JohnProctor,
|
||||||
|
ReverendJohnHale,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: AnnPutnam,
|
||||||
|
name: "Ann Putnam",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 7,
|
||||||
|
friends: [
|
||||||
|
BettyParris,
|
||||||
|
ThomasPutnam,
|
||||||
|
ReverendParris,
|
||||||
|
MercyLewis,
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
ElizabethProctor,
|
||||||
|
JohnProctor,
|
||||||
|
RebeccaNurse,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: BettyParris,
|
||||||
|
name: "Betty Parris",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [
|
||||||
|
AbigailWilliams,
|
||||||
|
ReverendParris,
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
JohnProctor,
|
||||||
|
ElizabethProctor,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: DeputyGovernorDanforth,
|
||||||
|
name: "Deputy Governor Danforth",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 100,
|
||||||
|
friends: [
|
||||||
|
AbigailWilliams,
|
||||||
|
JudgeHathorne,
|
||||||
|
ReverendParris,
|
||||||
|
EzekielCheever,
|
||||||
|
MarshalHerrick,
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
ElizabethProctor,
|
||||||
|
JohnProctor,
|
||||||
|
ReverendJohnHale,
|
||||||
|
FrancisNurse,
|
||||||
|
GilesCorey,
|
||||||
|
MarthaCorey,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: ElizabethProctor,
|
||||||
|
name: "Elizabeth Proctor",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 5,
|
||||||
|
friends: [
|
||||||
|
FrancisNurse,
|
||||||
|
GilesCorey,
|
||||||
|
JohnProctor,
|
||||||
|
RebeccaNurse,
|
||||||
|
ReverendJohnHale,
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
AbigailWilliams,
|
||||||
|
DeputyGovernorDanforth,
|
||||||
|
EzekielCheever,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: EzekielCheever,
|
||||||
|
name: "Ezekiel Cheever",
|
||||||
|
standing: Standing (
|
||||||
|
society: 12,
|
||||||
|
court: 50,
|
||||||
|
friends: [
|
||||||
|
MarshalHerrick,
|
||||||
|
DeputyGovernorDanforth,
|
||||||
|
ReverendParris,
|
||||||
|
ReverendJohnHale,
|
||||||
|
JudgeHathorne,
|
||||||
|
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
ElizabethProctor,
|
||||||
|
JohnProctor,
|
||||||
|
FrancisNurse,
|
||||||
|
GilesCorey,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: FrancisNurse,
|
||||||
|
name: "Francis Nurse",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [
|
||||||
|
RebeccaNurse,
|
||||||
|
JohnProctor,
|
||||||
|
GilesCorey,
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
AnnPutnam,
|
||||||
|
AbigailWilliams,
|
||||||
|
ReverendJohnHale,
|
||||||
|
JudgeHathorne,
|
||||||
|
ThomasPutnam,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: RebeccaNurse,
|
||||||
|
name: "Rebecca Nurse",
|
||||||
|
standing: Standing (
|
||||||
|
society: 20,
|
||||||
|
court: 8,
|
||||||
|
friends: [
|
||||||
|
ElizabethProctor,
|
||||||
|
FrancisNurse,
|
||||||
|
JohnProctor,
|
||||||
|
MarthaCorey,
|
||||||
|
GilesCorey,
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
ThomasPutnam,
|
||||||
|
AnnPutnam,
|
||||||
|
ReverendJohnHale,
|
||||||
|
JudgeHathorne,
|
||||||
|
EzekielCheever,
|
||||||
|
MarshalHerrick,
|
||||||
|
AbigailWilliams,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: GilesCorey,
|
||||||
|
name: "Giles Corey",
|
||||||
|
standing: Standing (
|
||||||
|
society: 2,
|
||||||
|
court: 5,
|
||||||
|
friends: [
|
||||||
|
JohnProctor,
|
||||||
|
MarthaCorey,
|
||||||
|
FrancisNurse,
|
||||||
|
],
|
||||||
|
enemies: [
|
||||||
|
EzekielCheever,
|
||||||
|
JudgeHathorne,
|
||||||
|
ReverendJohnHale,
|
||||||
|
MarshalHerrick,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: GoodyOsborne,
|
||||||
|
name: "Goody Osborne",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: JohnProctor,
|
||||||
|
name: "John Proctor",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: JudgeHathorne,
|
||||||
|
name: "Judge Hathorne",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: MaryWarren,
|
||||||
|
name: "Mary Warren",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: MarshalHerrick,
|
||||||
|
name: "Marshal Herrick",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: MarthaCorey,
|
||||||
|
name: "Martha Corey",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: MercyLewis,
|
||||||
|
name: "Mercy Lewis",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: RebeccaNurse,
|
||||||
|
name: "Rebecca Nurse",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: ReverendJohnHale,
|
||||||
|
name: "Reverend John Hale",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: ReverendParris,
|
||||||
|
name: "Reverend Parris",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: SarahGood,
|
||||||
|
name: "Sarah Good",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: SusannaWalcott,
|
||||||
|
name: "Susanna Walcott",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: ThomasPutnam,
|
||||||
|
name: "Thomas Putnam",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Character (
|
||||||
|
id: Tituba,
|
||||||
|
name: "Tituba",
|
||||||
|
standing: Standing (
|
||||||
|
society: 10,
|
||||||
|
court: 10,
|
||||||
|
friends: [],
|
||||||
|
enemies: []
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,53 +1,56 @@
|
|||||||
|
// Copyright (c) 2024 Cutieguwu | Olivia Brooks
|
||||||
|
//
|
||||||
|
// -*- coding: utf-8 -*-
|
||||||
|
// @Title: Culling of the Sheep
|
||||||
|
// @Author: Cutieguwu | Olivia Brooks
|
||||||
|
// @Description: Components for characters.
|
||||||
|
//
|
||||||
|
// @Script: characters.rs
|
||||||
|
// @Date Created: 03 Dec, 2024
|
||||||
|
// @Last Modified: 10 Dec, 2024
|
||||||
|
// @Last Modified by: Cutieguwu | Olivia Brooks
|
||||||
|
// --------------------------------------------
|
||||||
|
|
||||||
|
use std::fs::File;
|
||||||
|
|
||||||
use rand::distributions::{Distribution, Standard};
|
use rand::distributions::{Distribution, Standard};
|
||||||
|
use ron::de::from_reader;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::Gamemode;
|
use crate::Gamemode;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||||
pub struct Character {
|
pub struct Character {
|
||||||
pub name: &'static str,
|
pub id: People,
|
||||||
|
pub name: String,
|
||||||
pub standing: Standing,
|
pub standing: Standing,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Character {
|
impl Character {
|
||||||
pub fn build_player(gamemode: Gamemode) -> Character {
|
pub fn build_player<'a>(
|
||||||
Character {
|
characters: &'a mut Vec<Character>,
|
||||||
name: "You",
|
gamemode: Gamemode,
|
||||||
standing: match gamemode {
|
) -> Character {
|
||||||
Gamemode::Abigail => Standing {
|
let character_model: People = match gamemode {
|
||||||
society: 10,
|
Gamemode::Abigail => People::AbigailWilliams,
|
||||||
court: 10,
|
Gamemode::MaryWarren => People::MaryWarren,
|
||||||
friends: vec![],
|
Gamemode::JohnProctor => People::JohnProctor,
|
||||||
enemies: vec![]
|
Gamemode::GoodyOsborne => People::GoodyOsborne,
|
||||||
},
|
};
|
||||||
Gamemode::MaryWarren => Standing {
|
let position: usize = characters.iter()
|
||||||
society: 5,
|
.position(|x| x.id == character_model)
|
||||||
court: 5,
|
.expect("Failed to locate character to model player by");
|
||||||
friends: vec![],
|
|
||||||
enemies: vec![]
|
characters.swap_remove(position)
|
||||||
},
|
|
||||||
Gamemode::JohnProctor => Standing {
|
|
||||||
society: 2,
|
|
||||||
court: 2,
|
|
||||||
friends: vec![],
|
|
||||||
enemies: vec![]
|
|
||||||
},
|
|
||||||
Gamemode::GoodyOsborne => Standing {
|
|
||||||
society: -15,
|
|
||||||
court: -5,
|
|
||||||
friends: vec![],
|
|
||||||
enemies: vec![]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||||
pub struct Standing {
|
pub struct Standing {
|
||||||
pub society: i8,
|
pub society: i8,
|
||||||
pub court: i8,
|
pub court: i8,
|
||||||
pub friends: Vec<&'static People>,
|
pub friends: Vec<People>,
|
||||||
pub enemies: Vec<&'static People>,
|
pub enemies: Vec<People>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Standing {
|
impl Standing {
|
||||||
@@ -67,241 +70,80 @@ impl Standing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||||
pub enum People {
|
pub enum People {
|
||||||
AbigailWilliams(Option<Character>),
|
AbigailWilliams,
|
||||||
AnnPutnam(Option<Character>),
|
AnnPutnam,
|
||||||
BettyParris(Option<Character>),
|
BettyParris,
|
||||||
DeputyGovernorDanforth(Option<Character>),
|
DeputyGovernorDanforth,
|
||||||
ElizabethProctor(Option<Character>),
|
ElizabethProctor,
|
||||||
EzekielCheever(Option<Character>),
|
EzekielCheever,
|
||||||
FrancisNurse(Option<Character>),
|
FrancisNurse,
|
||||||
GilesCorey(Option<Character>),
|
GilesCorey,
|
||||||
GoodyOsborne(Option<Character>),
|
GoodyOsborne,
|
||||||
JohnProctor(Option<Character>),
|
JohnProctor,
|
||||||
JudgeHathorne(Option<Character>),
|
JudgeHathorne,
|
||||||
MaryWarren(Option<Character>),
|
MaryWarren,
|
||||||
MarshalHerrick(Option<Character>),
|
MarshalHerrick,
|
||||||
MarthaCorey(Option<Character>),
|
MarthaCorey,
|
||||||
MercyLewis(Option<Character>),
|
MercyLewis,
|
||||||
RebeccaNurse(Option<Character>),
|
RebeccaNurse,
|
||||||
ReverendParris(Option<Character>),
|
ReverendJohnHale,
|
||||||
ReverendJohnHale(Option<Character>),
|
ReverendParris,
|
||||||
SarahGood(Option<Character>),
|
SarahGood,
|
||||||
SusannaWalcott(Option<Character>),
|
SusannaWalcott,
|
||||||
ThomasPutnam(Option<Character>),
|
ThomasPutnam,
|
||||||
Tituba(Option<Character>),
|
Tituba,
|
||||||
|
Player,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl People {
|
impl People {
|
||||||
pub fn build_characters() -> Vec<People> {
|
pub fn load_characters() -> Vec<Character> {
|
||||||
vec![
|
let file_path = format!("{}/data/characters.ron", env!("CARGO_MANIFEST_DIR"));
|
||||||
People::AbigailWilliams(Some(Character {
|
let file = File::open(file_path).expect("Error opening character file");
|
||||||
name: "Abigail Williams",
|
|
||||||
standing: Standing {
|
|
||||||
society: 10,
|
|
||||||
court: 10,
|
|
||||||
friends: vec![
|
|
||||||
&People::BettyParris(None),
|
|
||||||
&People::DeputyGovernorDanforth(None),
|
|
||||||
&People::ReverendParris(None),
|
|
||||||
],
|
|
||||||
enemies: vec![
|
|
||||||
&People::ElizabethProctor(None),
|
|
||||||
&People::JohnProctor(None),
|
|
||||||
&People::ReverendJohnHale(None),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
People::AnnPutnam(Some(Character {
|
|
||||||
name: "Ann Putnam",
|
|
||||||
standing: Standing {
|
|
||||||
society: 10,
|
|
||||||
court: 7,
|
|
||||||
friends: vec![
|
|
||||||
&People::BettyParris(None),
|
|
||||||
&People::ThomasPutnam(None),
|
|
||||||
&People::ReverendParris(None),
|
|
||||||
&People::MercyLewis(None),
|
|
||||||
],
|
|
||||||
enemies: vec![
|
|
||||||
&People::ElizabethProctor(None),
|
|
||||||
&People::JohnProctor(None),
|
|
||||||
&People::RebeccaNurse(None),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
People::BettyParris(Some(Character {
|
|
||||||
name: "Betty Parris",
|
|
||||||
standing: Standing {
|
|
||||||
society: 10,
|
|
||||||
court: 10,
|
|
||||||
friends: vec![
|
|
||||||
&People::AbigailWilliams(None),
|
|
||||||
&People::ReverendParris(None),
|
|
||||||
],
|
|
||||||
enemies: vec![
|
|
||||||
&People::JohnProctor(None),
|
|
||||||
&People::ElizabethProctor(None),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
People::DeputyGovernorDanforth(Some(Character {
|
|
||||||
name: "Deputy Governor Danforth",
|
|
||||||
standing: Standing {
|
|
||||||
society: 10,
|
|
||||||
court: 100,
|
|
||||||
friends: vec![
|
|
||||||
&People::AbigailWilliams(None),
|
|
||||||
&People::JudgeHathorne(None),
|
|
||||||
&People::ReverendParris(None),
|
|
||||||
&People::EzekielCheever(None),
|
|
||||||
&People::MarshalHerrick(None),
|
|
||||||
],
|
|
||||||
enemies: vec![
|
|
||||||
&People::ElizabethProctor(None),
|
|
||||||
&People::JohnProctor(None),
|
|
||||||
&People::ReverendJohnHale(None),
|
|
||||||
&People::FrancisNurse(None),
|
|
||||||
&People::GilesCorey(None),
|
|
||||||
&People::MarthaCorey(None),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
People::ElizabethProctor(Some(Character{
|
|
||||||
name: "Elizabeth Proctor",
|
|
||||||
standing: Standing {
|
|
||||||
society: 10,
|
|
||||||
court: 5,
|
|
||||||
friends: vec![
|
|
||||||
&People::FrancisNurse(None),
|
|
||||||
&People::GilesCorey(None),
|
|
||||||
&People::JohnProctor(None),
|
|
||||||
&People::RebeccaNurse(None),
|
|
||||||
&People::ReverendJohnHale(None),
|
|
||||||
],
|
|
||||||
enemies: vec![
|
|
||||||
&People::AbigailWilliams(None),
|
|
||||||
&People::DeputyGovernorDanforth(None),
|
|
||||||
&People::EzekielCheever(None),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
People::EzekielCheever(Some(Character {
|
|
||||||
name: "Ezekiel Cheever",
|
|
||||||
standing: Standing {
|
|
||||||
society: 12,
|
|
||||||
court: 50,
|
|
||||||
friends: vec![
|
|
||||||
&People::MarshalHerrick(None),
|
|
||||||
&People::DeputyGovernorDanforth(None),
|
|
||||||
&People::ReverendParris(None),
|
|
||||||
&People::ReverendJohnHale(None),
|
|
||||||
&People::JudgeHathorne(None),
|
|
||||||
|
|
||||||
],
|
// Return deserialized file content.
|
||||||
enemies: vec![
|
match from_reader(file) {
|
||||||
&People::ElizabethProctor(None),
|
Ok(x) => x,
|
||||||
&People::JohnProctor(None),
|
Err(e) => {
|
||||||
&People::FrancisNurse(None),
|
println!("Failed to load config: {}", e);
|
||||||
&People::GilesCorey(None),
|
|
||||||
]
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
})),
|
|
||||||
People::FrancisNurse(Some(Character {
|
|
||||||
name: "Francis Nurse",
|
|
||||||
standing: Standing {
|
|
||||||
society: 10,
|
|
||||||
court: 10,
|
|
||||||
friends: vec![
|
|
||||||
&People::RebeccaNurse(None),
|
|
||||||
&People::JohnProctor(None),
|
|
||||||
&People::GilesCorey(None),
|
|
||||||
],
|
|
||||||
enemies: vec![
|
|
||||||
&People::AnnPutnam(None),
|
|
||||||
&People::AbigailWilliams(None),
|
|
||||||
&People::ReverendJohnHale(None),
|
|
||||||
&People::JudgeHathorne(None),
|
|
||||||
&People::ThomasPutnam(None),
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
})),
|
|
||||||
People::RebeccaNurse(Some(Character {
|
|
||||||
name: "Rebecca Nurse",
|
|
||||||
standing: Standing {
|
|
||||||
society: 20,
|
|
||||||
court: 8,
|
|
||||||
friends: vec![
|
|
||||||
&People::ElizabethProctor(None),
|
|
||||||
&People::FrancisNurse(None),
|
|
||||||
&People::JohnProctor(None),
|
|
||||||
&People::MarthaCorey(None),
|
|
||||||
&People::GilesCorey(None),
|
|
||||||
],
|
|
||||||
enemies: vec![
|
|
||||||
&People::ThomasPutnam(None),
|
|
||||||
&People::AnnPutnam(None),
|
|
||||||
&People::ReverendJohnHale(None),
|
|
||||||
&People::JudgeHathorne(None),
|
|
||||||
&People::EzekielCheever(None),
|
|
||||||
&People::MarshalHerrick(None),
|
|
||||||
&People::AbigailWilliams(None),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
People::GilesCorey(Some(Character {
|
|
||||||
name: "Giles Corey",
|
|
||||||
standing: Standing {
|
|
||||||
society: 2,
|
|
||||||
court: 5,
|
|
||||||
friends: vec![
|
|
||||||
&People::JohnProctor(None),
|
|
||||||
&People::MarthaCorey(None),
|
|
||||||
&People::FrancisNurse(None),
|
|
||||||
],
|
|
||||||
enemies: vec![
|
|
||||||
&People::EzekielCheever(None),
|
|
||||||
&People::JudgeHathorne(None),
|
|
||||||
&People::ReverendJohnHale(None),
|
|
||||||
&People::MarshalHerrick(None),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Distribution<People> for Standard {
|
impl Distribution<People> for Standard {
|
||||||
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> People {
|
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> People {
|
||||||
match rng.gen_range(0..=21) {
|
match rng.gen_range(0..=21) {
|
||||||
0 => People::AbigailWilliams(None),
|
0 => People::AbigailWilliams,
|
||||||
1 => People::AnnPutnam(None),
|
1 => People::AnnPutnam,
|
||||||
2 => People::BettyParris(None),
|
2 => People::BettyParris,
|
||||||
3 => People::DeputyGovernorDanforth(None),
|
3 => People::DeputyGovernorDanforth,
|
||||||
4 => People::ElizabethProctor(None),
|
4 => People::ElizabethProctor,
|
||||||
5 => People::EzekielCheever(None),
|
5 => People::EzekielCheever,
|
||||||
6 => People::FrancisNurse(None),
|
6 => People::FrancisNurse,
|
||||||
7 => People::GilesCorey(None),
|
7 => People::GilesCorey,
|
||||||
8 => People::GoodyOsborne(None),
|
8 => People::GoodyOsborne,
|
||||||
9 => People::JohnProctor(None),
|
9 => People::JohnProctor,
|
||||||
10 => People::JudgeHathorne(None),
|
10 => People::JudgeHathorne,
|
||||||
11 => People::MarshalHerrick(None),
|
11 => People::MarshalHerrick,
|
||||||
12 => People::MarthaCorey(None),
|
12 => People::MarthaCorey,
|
||||||
13 => People::MaryWarren(None),
|
13 => People::MaryWarren,
|
||||||
14 => People::RebeccaNurse(None),
|
14 => People::RebeccaNurse,
|
||||||
15 => People::ReverendJohnHale(None),
|
15 => People::ReverendJohnHale,
|
||||||
16 => People::ReverendParris(None),
|
16 => People::ReverendParris,
|
||||||
18 => People::SarahGood(None),
|
18 => People::SarahGood,
|
||||||
19 => People::SusannaWalcott(None),
|
19 => People::SusannaWalcott,
|
||||||
20 => People::ThomasPutnam(None),
|
20 => People::ThomasPutnam,
|
||||||
21 => People::Tituba(None),
|
21 => People::Tituba,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum SurvivalStatus {
|
pub enum SurvivalStatus {
|
||||||
PlayerMassacred,
|
PlayerMassacred,
|
||||||
PlayerLived,
|
PlayerLived,
|
||||||
|
|||||||
192
src/events.rs
192
src/events.rs
@@ -1,25 +1,41 @@
|
|||||||
|
// Copyright (c) 2024 Cutieguwu | Olivia Brooks
|
||||||
|
//
|
||||||
|
// -*- coding: utf-8 -*-
|
||||||
|
// @Title: Culling of the Sheep
|
||||||
|
// @Author: Cutieguwu | Olivia Brooks
|
||||||
|
// @Description: Components for events.
|
||||||
|
//
|
||||||
|
// @Script: events.rs
|
||||||
|
// @Date Created: 03 Dec, 2024
|
||||||
|
// @Last Modified: 08 Dec, 2024
|
||||||
|
// @Last Modified by: Cutieguwu | Olivia Brooks
|
||||||
|
// --------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
use std::i8;
|
use std::i8;
|
||||||
|
|
||||||
use rand::{
|
use rand::distributions::{Distribution, Standard};
|
||||||
distributions::{Distribution, Standard},
|
use rand::rngs::ThreadRng;
|
||||||
rngs::ThreadRng,
|
use rand::seq::SliceRandom;
|
||||||
};
|
|
||||||
|
|
||||||
use crate::characters::{
|
use crate::characters::{Character, SurvivalStatus};
|
||||||
Character,
|
use crate::utils::input;
|
||||||
People,
|
|
||||||
SurvivalStatus,
|
const BREAKLINE: &'static str = "-------------------------------------";
|
||||||
};
|
|
||||||
|
pub fn print_breakline() {
|
||||||
|
println!("\n{}\n", BREAKLINE)
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub trait EventHandle {
|
pub trait EventHandle {
|
||||||
fn handle<'a>(
|
fn handle<'a>(
|
||||||
self: &Self,
|
self: &Self,
|
||||||
rng: &'a ThreadRng,
|
rng: &'a mut ThreadRng,
|
||||||
player: &'a mut Character,
|
player: &'a mut Character,
|
||||||
characters: &'a mut Vec<People>,
|
characters: &'a mut Vec<Character>,
|
||||||
) -> EventReturn {
|
) -> SurvivalStatus {
|
||||||
EventReturn::None
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,19 +45,81 @@ pub struct Trial;
|
|||||||
impl EventHandle for Trial {
|
impl EventHandle for Trial {
|
||||||
fn handle<'a>(
|
fn handle<'a>(
|
||||||
self: &Self,
|
self: &Self,
|
||||||
rng: &'a ThreadRng,
|
rng: &'a mut ThreadRng,
|
||||||
player: &'a mut Character,
|
player: &'a mut Character,
|
||||||
characters: &'a mut Vec<People>,
|
characters: &'a mut Vec<Character>,
|
||||||
) -> EventReturn {
|
) -> SurvivalStatus {
|
||||||
let mut player_status: SurvivalStatus = SurvivalStatus::PlayerDied;
|
let doppelgangers = characters.clone();
|
||||||
|
|
||||||
|
print_breakline();
|
||||||
|
|
||||||
println!("You have been summoned before the court.\n");
|
println!("You have been summoned before the court.\n");
|
||||||
|
println!("[0] You may appease the court by admitting to witchcraft.");
|
||||||
|
println!("[1] Or you may die.");
|
||||||
|
|
||||||
if player.standing.clone().calculate() >= {0 as i8} {
|
// Get choice from player, return early if they choose to die.
|
||||||
player_status = SurvivalStatus::PlayerLived
|
loop {
|
||||||
|
match input().as_str() {
|
||||||
|
// Attempt to accuse
|
||||||
|
"0" => break,
|
||||||
|
// Die a witch
|
||||||
|
"1" => return SurvivalStatus::PlayerDied,
|
||||||
|
_ => ()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
EventReturn::Survival(player_status)
|
print_breakline();
|
||||||
|
|
||||||
|
println!("Someone must have coerced you into following Satan.");
|
||||||
|
println!("Attempt to save yourself; who will you accuse?\n");
|
||||||
|
|
||||||
|
// Randomly select four characters.
|
||||||
|
let accusable: Vec<&Character> = doppelgangers
|
||||||
|
.choose_multiple(rng, 4)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
for character in &accusable {
|
||||||
|
println!(
|
||||||
|
"[{:?}] {}",
|
||||||
|
accusable
|
||||||
|
.iter()
|
||||||
|
.position(|x| x == character)
|
||||||
|
.expect("Could not find character."),
|
||||||
|
character.name
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
let accusee_index: u8 = loop {
|
||||||
|
let temp: Option<i32> = match input().as_str() {
|
||||||
|
"0" => Some(0),
|
||||||
|
"1" => Some(1),
|
||||||
|
"2" => Some(2),
|
||||||
|
"3" => Some(3),
|
||||||
|
_ => None
|
||||||
|
};
|
||||||
|
|
||||||
|
if temp != None {
|
||||||
|
break temp.unwrap() as u8
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
push_enemy(
|
||||||
|
player,
|
||||||
|
accusable[accusee_index as usize],
|
||||||
|
characters
|
||||||
|
);
|
||||||
|
|
||||||
|
print_breakline();
|
||||||
|
|
||||||
|
println!("The court will now decide your fate considering.");
|
||||||
|
|
||||||
|
// Have the player stand trial.
|
||||||
|
// A wild accusation may not be enough to save them.
|
||||||
|
if player.standing.clone().calculate() > {0 as i8} {
|
||||||
|
SurvivalStatus::PlayerLived
|
||||||
|
} else {
|
||||||
|
SurvivalStatus::PlayerDied
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,33 +127,83 @@ impl EventHandle for Trial {
|
|||||||
pub struct WildAccusation;
|
pub struct WildAccusation;
|
||||||
|
|
||||||
impl EventHandle for WildAccusation {
|
impl EventHandle for WildAccusation {
|
||||||
|
#[allow(unused_variables)]
|
||||||
fn handle<'a>(
|
fn handle<'a>(
|
||||||
self: &Self,
|
self: &Self,
|
||||||
rng: &'a ThreadRng,
|
rng: &'a mut ThreadRng,
|
||||||
player: &'a mut Character,
|
player: &'a mut Character,
|
||||||
characters: &'a mut Vec<People>,
|
characters: &'a mut Vec<Character>,
|
||||||
) -> EventReturn {
|
) -> SurvivalStatus {
|
||||||
EventReturn::None
|
let doppelgangers = characters.clone();
|
||||||
|
let accuser: &Character = doppelgangers
|
||||||
|
.choose(rng)
|
||||||
|
.expect("Failed to fetch character as accuser.");
|
||||||
|
|
||||||
|
let accusee: &Character = doppelgangers
|
||||||
|
.choose(rng)
|
||||||
|
.expect("Failed to fetch character as accusee.");
|
||||||
|
|
||||||
|
print_breakline();
|
||||||
|
|
||||||
|
println!("{:?} accused {:?}", accuser, accusee);
|
||||||
|
|
||||||
|
push_enemy(accuser, accusee, characters);
|
||||||
|
|
||||||
|
SurvivalStatus::PlayerLived
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn push_enemy<'a>(
|
||||||
|
accuser: &Character,
|
||||||
|
accusee: &Character,
|
||||||
|
characters: &'a mut Vec<Character>,
|
||||||
|
) -> Vec<Character> {
|
||||||
|
let characters = characters;
|
||||||
|
// If accuser not an enemy, add them as such.
|
||||||
|
if None == accusee.standing.enemies
|
||||||
|
.iter()
|
||||||
|
.find(|x| *x == &accuser.id)
|
||||||
|
{
|
||||||
|
accusee.standing.enemies.to_owned().push(accuser.id.clone());
|
||||||
|
|
||||||
|
let position: usize = characters.iter()
|
||||||
|
.position(|x| x.id == accusee.id)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
characters[position] = accusee.clone();
|
||||||
|
};
|
||||||
|
|
||||||
|
characters.to_vec()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Events {
|
pub enum Events {
|
||||||
Trial(Trial),
|
Trial(Trial),
|
||||||
|
WildAccusation(WildAccusation),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EventHandle for Events {
|
||||||
|
fn handle<'a>(
|
||||||
|
self: &Self,
|
||||||
|
rng: &'a mut ThreadRng,
|
||||||
|
player: &'a mut Character,
|
||||||
|
characters: &'a mut Vec<Character>,
|
||||||
|
) -> SurvivalStatus {
|
||||||
|
match self {
|
||||||
|
Events::Trial(trial) => trial.handle(rng, player, characters),
|
||||||
|
Events::WildAccusation(wild_accusation) => {
|
||||||
|
wild_accusation.handle(rng, player, characters)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Distribution<Events> for Standard {
|
impl Distribution<Events> for Standard {
|
||||||
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> Events {
|
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> Events {
|
||||||
match rng.gen_range(0..=0) {
|
match rng.gen_range(0..=1) {
|
||||||
0 => Events::Trial(Trial),
|
0 => Events::Trial(Trial),
|
||||||
1 => todo!(),
|
1 => Events::WildAccusation(WildAccusation),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum EventReturn {
|
|
||||||
Survival(SurvivalStatus),
|
|
||||||
None,
|
|
||||||
}
|
|
||||||
111
src/main.rs
111
src/main.rs
@@ -1,90 +1,79 @@
|
|||||||
|
// Copyright (c) 2024 Cutieguwu | Olivia Brooks
|
||||||
|
//
|
||||||
|
// -*- coding: utf-8 -*-
|
||||||
|
// @Title: Culling of the Sheep
|
||||||
|
// @Author: Cutieguwu | Olivia Brooks
|
||||||
|
// @Description: A game to demonstrate the Salem Witch Trials.
|
||||||
|
//
|
||||||
|
// @Script: main.rs
|
||||||
|
// @Date Created: 26 Nov, 2024
|
||||||
|
// @Last Modified: 09 Dec, 2024
|
||||||
|
// @Last Modified by: Cutieguwu | Olivia Brooks
|
||||||
|
// --------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
mod characters;
|
mod characters;
|
||||||
mod events;
|
mod events;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use characters::{
|
use rand::{random, thread_rng};
|
||||||
Character,
|
use rand::rngs::ThreadRng;
|
||||||
People,
|
|
||||||
SurvivalStatus,
|
|
||||||
};
|
|
||||||
|
|
||||||
use events::{
|
use utils::{fmt_args, ArgType, FlagType};
|
||||||
EventHandle,
|
|
||||||
EventReturn,
|
|
||||||
Events,
|
|
||||||
Trial,
|
|
||||||
};
|
|
||||||
|
|
||||||
use rand::{
|
use crate::characters::{Character, People, SurvivalStatus};
|
||||||
random,
|
use crate::events::{EventHandle, Events, print_breakline};
|
||||||
thread_rng,
|
|
||||||
rngs::ThreadRng
|
|
||||||
};
|
|
||||||
|
|
||||||
use utils::{
|
|
||||||
fmt_args,
|
|
||||||
ArgType,
|
|
||||||
FlagType,
|
|
||||||
};
|
|
||||||
|
|
||||||
//Number of game rounds.
|
//Number of game rounds.
|
||||||
const ROUNDS: u8 = 15;
|
const ROUNDS: u8 = 15;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let cmd_args: Vec<ArgType> = fmt_args();
|
let mut characters: Vec<Character> = People::load_characters();
|
||||||
let mut characters: Vec<People> = People::build_characters();
|
|
||||||
let rng: ThreadRng = thread_rng();
|
|
||||||
|
|
||||||
// Set player default values based on gamemode.
|
|
||||||
let mut player: Character = Character::build_player(Gamemode::get(&cmd_args));
|
|
||||||
let mut end_status: SurvivalStatus = SurvivalStatus::PlayerLived;
|
let mut end_status: SurvivalStatus = SurvivalStatus::PlayerLived;
|
||||||
|
// Set player default values based on gamemode.
|
||||||
|
let mut player: Character = Character::build_player(
|
||||||
|
&mut characters,
|
||||||
|
Gamemode::get(fmt_args()),
|
||||||
|
);
|
||||||
|
let mut rng: ThreadRng = thread_rng();
|
||||||
|
|
||||||
// Game loop.
|
// Game loop.
|
||||||
for r in 0..=ROUNDS {
|
for r in 0..=ROUNDS {
|
||||||
end_status = run_event(
|
end_status = random::<Events>().handle(
|
||||||
&rng,
|
&mut rng,
|
||||||
&mut player,
|
&mut player,
|
||||||
&mut characters,
|
&mut characters,
|
||||||
random(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if matches!(end_status, SurvivalStatus::PlayerLived) { break }
|
dbg!(&characters);
|
||||||
|
|
||||||
if characters.len() == 0 {
|
if characters.len() == 1 {
|
||||||
end_status = SurvivalStatus::PlayerMassacred
|
end_status = SurvivalStatus::PlayerMassacred;
|
||||||
} else if r == ROUNDS {
|
|
||||||
end_status = SurvivalStatus::PlayerLived
|
|
||||||
} else if player.standing.clone().calculate() <= 0 {
|
|
||||||
//Standing too low, bring to court.
|
|
||||||
end_status = run_event(
|
|
||||||
&rng,
|
|
||||||
&mut player,
|
|
||||||
&mut characters,
|
|
||||||
Events::Trial(Trial),
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if end_status == SurvivalStatus::PlayerDied
|
||||||
|
|| end_status == SurvivalStatus::PlayerMassacred
|
||||||
|
|| r == ROUNDS
|
||||||
|
{
|
||||||
|
break
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
print_breakline();
|
||||||
|
|
||||||
|
// Game end result.
|
||||||
match end_status {
|
match end_status {
|
||||||
SurvivalStatus::PlayerDied => println!("You died. And for what?"),
|
SurvivalStatus::PlayerDied => println!("You died. And for what?"),
|
||||||
SurvivalStatus::PlayerLived => println!("You survived, but at what cost? How many died to save you?"),
|
SurvivalStatus::PlayerLived => {
|
||||||
SurvivalStatus::PlayerMassacred => println!("You killed everyone. I ask, at what end will you yield. Care you not for the life of others?"),
|
println!("You survived, but at what cost?");
|
||||||
};
|
println!("How many died to save you?");
|
||||||
}
|
|
||||||
|
|
||||||
fn run_event<'main>(
|
|
||||||
rng: &ThreadRng ,
|
|
||||||
player: &mut Character,
|
|
||||||
characters: &mut Vec<People>,
|
|
||||||
event: Events,
|
|
||||||
) -> SurvivalStatus {
|
|
||||||
match event {
|
|
||||||
Events::Trial(trial) => match trial.handle(rng, player, characters) {
|
|
||||||
EventReturn::Survival(state) => state,
|
|
||||||
_ => unreachable!(),
|
|
||||||
},
|
},
|
||||||
}
|
SurvivalStatus::PlayerMassacred => {
|
||||||
|
println!("You killed everyone.");
|
||||||
|
println!("I ask, at what end will you yield.");
|
||||||
|
println!("Care you not for the life of others?");
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -100,7 +89,7 @@ pub enum Gamemode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Gamemode {
|
impl Gamemode {
|
||||||
fn get(cmd_args: &Vec<ArgType>) -> Gamemode {
|
fn get(cmd_args: Vec<ArgType>) -> Gamemode {
|
||||||
if cmd_args.len() != 1 {
|
if cmd_args.len() != 1 {
|
||||||
match &cmd_args[1] {
|
match &cmd_args[1] {
|
||||||
ArgType::Command(command) => match command.as_str() {
|
ArgType::Command(command) => match command.as_str() {
|
||||||
|
|||||||
38
src/utils.rs
38
src/utils.rs
@@ -1,7 +1,20 @@
|
|||||||
use std::{
|
// Copyright (c) 2024 Cutieguwu | Olivia Brooks
|
||||||
env::args,
|
//
|
||||||
io, ops::Deref,
|
// -*- coding: utf-8 -*-
|
||||||
};
|
// @Title: Culling of the Sheep
|
||||||
|
// @Author: Cutieguwu | Olivia Brooks
|
||||||
|
// @Description: Utils for cli argument handling.
|
||||||
|
//
|
||||||
|
// @Script: characters.rs
|
||||||
|
// @Date Created: 03 Dec, 2024
|
||||||
|
// @Last Modified: 10 Dec, 2024
|
||||||
|
// @Last Modified by: Cutieguwu | Olivia Brooks
|
||||||
|
// --------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
use std::env::args;
|
||||||
|
use std::io;
|
||||||
|
use std::str::Chars;
|
||||||
|
|
||||||
const DASH: char = 45 as u8 as char;
|
const DASH: char = 45 as u8 as char;
|
||||||
|
|
||||||
@@ -27,15 +40,15 @@ pub fn fmt_args() -> Vec<ArgType> {
|
|||||||
args_vec.push(match try_flag(&obj) {
|
args_vec.push(match try_flag(&obj) {
|
||||||
None => ArgType::Command(obj),
|
None => ArgType::Command(obj),
|
||||||
Some(flag) => ArgType::Flag(flag),
|
Some(flag) => ArgType::Flag(flag),
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
args_vec[0] = ArgType::Binary(match &args_vec[0] {
|
args_vec[0] = ArgType::Binary(match &args_vec[0] {
|
||||||
ArgType::Command(command) => command.clone(),
|
ArgType::Command(command) => command.to_owned(),
|
||||||
err => panic!(
|
err => panic!(
|
||||||
"Expected ArgType::Command at args_vec[0], found {:?}",
|
"Expected ArgType::Command at args_vec[0], found {:?}",
|
||||||
err,
|
err,
|
||||||
)
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
args_vec
|
args_vec
|
||||||
@@ -43,12 +56,12 @@ pub fn fmt_args() -> Vec<ArgType> {
|
|||||||
|
|
||||||
fn try_flag<'a>(arg: &'a String) -> Option<FlagType> {
|
fn try_flag<'a>(arg: &'a String) -> Option<FlagType> {
|
||||||
// Short term var to reduce number of chars() calls.
|
// Short term var to reduce number of chars() calls.
|
||||||
let mut arg_chars = arg.chars();
|
let arg_chars: Chars = arg.chars();
|
||||||
|
|
||||||
if arg_chars.nth(1).unwrap() == DASH {
|
if arg_chars.clone().nth(1).unwrap() == DASH {
|
||||||
//eg. --my-flag
|
//eg. --my-flag
|
||||||
Some(FlagType::Long(break_flag_long(arg.clone())))
|
Some(FlagType::Long(break_flag_long(arg.clone())))
|
||||||
} else if arg_chars.nth(0).unwrap() == DASH {
|
} else if arg_chars.clone().nth(0).unwrap() == DASH {
|
||||||
//eg. -Syu
|
//eg. -Syu
|
||||||
Some(FlagType::Short(break_flag_short(arg.clone())))
|
Some(FlagType::Short(break_flag_short(arg.clone())))
|
||||||
} else {
|
} else {
|
||||||
@@ -74,8 +87,9 @@ pub fn input() -> String {
|
|||||||
let mut input_buffer: String = String::new();
|
let mut input_buffer: String = String::new();
|
||||||
|
|
||||||
io::stdin()
|
io::stdin()
|
||||||
.read_line( &mut input_buffer)
|
.read_line(&mut input_buffer)
|
||||||
.expect("Failed to read line");
|
.expect("Failed to read line");
|
||||||
|
|
||||||
input_buffer
|
// Clear special characters and return as String
|
||||||
|
input_buffer.trim_end_matches(&['\r', '\n'][..]).to_string()
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user