diff options
author | Griffin Smith <root@gws.fyi> | 2019-07-28T02·16-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-07-28T02·16-0400 |
commit | f22bcad817ee354b355d29b6b289894e2d15cfaa (patch) | |
tree | 509aa3b88f834ffaccd6a90b61ae2c1e1567622d /src/entities/character.rs | |
parent | 68e8ad8a0e6a5ac38b34658f03807ade603a687c (diff) |
Add a generic text-prompt system
Add a generic text-prompt system to the Game, and use it to prompt the character for their name on startup. There's also a Promise type in util, which is used for the result of the prompt.
Diffstat (limited to 'src/entities/character.rs')
-rw-r--r-- | src/entities/character.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/entities/character.rs b/src/entities/character.rs index 7bcb8b5c87e4..b917f140e635 100644 --- a/src/entities/character.rs +++ b/src/entities/character.rs @@ -13,6 +13,8 @@ pub struct Character { /// The position of the character, relative to the game pub position: Position, + + pub o_name: Option<String>, } impl Character { @@ -20,6 +22,7 @@ impl Character { Character { id: None, position: Position { x: 0, y: 0 }, + o_name: None, } } @@ -31,6 +34,16 @@ impl Character { // TODO 1 } + + pub fn name<'a>(&'a self) -> &'a str { + self.o_name + .as_ref() + .expect("Character name not initialized") + } + + pub fn set_name(&mut self, name: String) { + self.o_name = Some(name); + } } entity!(Character); |