forked from Zaechus/kingslayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add character creation; add Race and Class types to Player
- Loading branch information
Showing
6 changed files
with
104 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub enum Class { | ||
Fighter, | ||
Wizard, | ||
Rogue, | ||
} | ||
|
||
impl Class { | ||
pub fn to_string(&self) -> String { | ||
match self { | ||
Self::Fighter => "Fighter".to_string(), | ||
Self::Wizard => "Wizard".to_string(), | ||
Self::Rogue => "Rogue".to_string(), | ||
} | ||
} | ||
|
||
pub fn select_class(input: &str) -> Self { | ||
match input.chars().next() { | ||
Some('2') => Class::Rogue, | ||
Some('3') => Class::Wizard, | ||
_ => Class::Fighter, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
mod aliases; | ||
mod class; | ||
mod race; | ||
mod results; | ||
mod stats; | ||
mod status; | ||
|
||
pub use aliases::{Allies, Elements, Enemies, Items, Paths, Rooms}; | ||
pub use class::Class; | ||
pub use race::Race; | ||
pub use results::{Action, CmdResult}; | ||
pub use stats::Stats; | ||
pub use status::{CombatStatus, EnemyStatus}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub enum Race { | ||
Human, | ||
Dwarf, | ||
Elf, | ||
} | ||
|
||
impl Race { | ||
pub fn to_string(&self) -> String { | ||
match self { | ||
Self::Human => "Human".to_string(), | ||
Self::Dwarf => "Dwarf".to_string(), | ||
Self::Elf => "Elf".to_string(), | ||
} | ||
} | ||
|
||
pub fn select_race(input: &str) -> Self { | ||
match input.chars().next() { | ||
Some('2') => Race::Dwarf, | ||
Some('3') => Race::Elf, | ||
_ => Race::Human, | ||
} | ||
} | ||
} |