add 'cheat' command for quicker testing
							parent
							
								
									28f11e74c5
								
							
						
					
					
						commit
						42567278d3
					
				|  | @ -150,6 +150,7 @@ enum RoomName { | ||||||
| 	Room1, | 	Room1, | ||||||
| 	/// Duplicate of starting room so I can change things around a little.
 | 	/// Duplicate of starting room so I can change things around a little.
 | ||||||
| 	_Room2, | 	_Room2, | ||||||
|  | 	SortingPuzzle, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Default for RoomName { | impl Default for RoomName { | ||||||
|  | @ -213,10 +214,16 @@ pub struct State { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl State { | impl State { | ||||||
|  | 	pub fn cheat (&mut self) { | ||||||
|  | 		self.current_room = RoomName::SortingPuzzle; | ||||||
|  | 	} | ||||||
|  | 	
 | ||||||
| 	/// Send a line of player input (e.g. "look table") into the game and return
 | 	/// Send a line of player input (e.g. "look table") into the game and return
 | ||||||
| 	/// a Vec of Responses. The runtime should process these responses in order.
 | 	/// a Vec of Responses. The runtime should process these responses in order.
 | ||||||
| 	
 | 	
 | ||||||
| 	pub fn step (&mut self, input: &str) -> Vec <Response> { | 	pub fn step (&mut self, input: &str) -> Vec <Response> { | ||||||
|  | 		use RoomName::*; | ||||||
|  | 		
 | ||||||
| 		match self.intro_state { | 		match self.intro_state { | ||||||
| 			IntroState::Stage1 => { | 			IntroState::Stage1 => { | ||||||
| 				self.intro_state = IntroState::Stage2; | 				self.intro_state = IntroState::Stage2; | ||||||
|  | @ -259,7 +266,10 @@ impl State { | ||||||
| 				line_response ("`hint` may contain spoilers. `help` will not."), | 				line_response ("`hint` may contain spoilers. `help` will not."), | ||||||
| 				Response::Nonsense, | 				Response::Nonsense, | ||||||
| 			], | 			], | ||||||
| 			PlayerAction::RoomSpecific (x) => self.room_1 (x), | 			PlayerAction::RoomSpecific (x) => match self.current_room { | ||||||
|  | 				Room1 => self.room_1 (x), | ||||||
|  | 				_ => just (line_response ("ERR: Invalid current room")), | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	
 | 	
 | ||||||
|  |  | ||||||
|  | @ -51,8 +51,12 @@ fn read_input () -> Result <String> { | ||||||
| 	Ok (buffer) | 	Ok (buffer) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn game () -> Result <()> { | fn game (args: &[String]) -> Result <()> { | ||||||
| 	let mut state = State::default (); | 	let mut state = State::default (); | ||||||
|  | 	
 | ||||||
|  | 	if args.get (1) == Some (&"cheat".to_string ()) { | ||||||
|  | 		state.cheat (); | ||||||
|  | 	} | ||||||
| 	let responses = state.step (""); | 	let responses = state.step (""); | ||||||
| 	
 | 	
 | ||||||
| 	for response in responses.into_iter () { | 	for response in responses.into_iter () { | ||||||
|  | @ -91,7 +95,8 @@ fn game () -> Result <()> { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn main () -> Result <()> { | fn main () -> Result <()> { | ||||||
| 	game ()?; | 	let args: Vec <_> = std::env::args ().collect (); | ||||||
|  | 	game (&args [..])?; | ||||||
| 	
 | 	
 | ||||||
| 	Ok (()) | 	Ok (()) | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 _
						_