ah, that's good enough. Now to run it un-protected on my server.
							parent
							
								
									119ec04d0c
								
							
						
					
					
						commit
						28f11e74c5
					
				|  | @ -64,7 +64,7 @@ fn parse_input (s: &str) -> PlayerAction { | ||||||
| 	use PlayerAction::*; | 	use PlayerAction::*; | ||||||
| 	use PlayerActionRoomSpecific::*; | 	use PlayerActionRoomSpecific::*; | ||||||
| 	
 | 	
 | ||||||
| 	let s = s.to_lowercase (); | 	let s = s.trim ().to_lowercase (); | ||||||
| 	
 | 	
 | ||||||
| 	let look = |rest| RoomSpecific (Look (parse_item_name (rest))); | 	let look = |rest| RoomSpecific (Look (parse_item_name (rest))); | ||||||
| 	let activate = |rest| RoomSpecific (Use (parse_item_name (rest))); | 	let activate = |rest| RoomSpecific (Use (parse_item_name (rest))); | ||||||
|  | @ -185,6 +185,9 @@ pub enum Response { | ||||||
| 	JokeEnding, | 	JokeEnding, | ||||||
| 	FailedDetectionCheck, | 	FailedDetectionCheck, | ||||||
| 	PlayerVictory, | 	PlayerVictory, | ||||||
|  | 	
 | ||||||
|  | 	// These are hints for spam detection on the Telnet frontend
 | ||||||
|  | 	Nonsense, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive (Clone, Copy)] | #[derive (Clone, Copy)] | ||||||
|  | @ -254,6 +257,7 @@ impl State { | ||||||
| 			PlayerAction::Nonsense => vec! [ | 			PlayerAction::Nonsense => vec! [ | ||||||
| 				line_response ("I couldn't understand that. Try `help` or `hint`."), | 				line_response ("I couldn't understand that. Try `help` or `hint`."), | ||||||
| 				line_response ("`hint` may contain spoilers. `help` will not."), | 				line_response ("`hint` may contain spoilers. `help` will not."), | ||||||
|  | 				Response::Nonsense, | ||||||
| 			], | 			], | ||||||
| 			PlayerAction::RoomSpecific (x) => self.room_1 (x), | 			PlayerAction::RoomSpecific (x) => self.room_1 (x), | ||||||
| 		} | 		} | ||||||
|  | @ -414,6 +418,7 @@ mod test { | ||||||
| 			("look table", RoomSpecific (Look (ItemName::Table))), | 			("look table", RoomSpecific (Look (ItemName::Table))), | ||||||
| 			("look  note ", RoomSpecific (Look (ItemName::Note))), | 			("look  note ", RoomSpecific (Look (ItemName::Note))), | ||||||
| 			("LOOK TABLE", RoomSpecific (Look (ItemName::Table))), | 			("LOOK TABLE", RoomSpecific (Look (ItemName::Table))), | ||||||
|  | 			("look ", RoomSpecific (LookAround)), | ||||||
| 			("wait", RoomSpecific (Wait)), | 			("wait", RoomSpecific (Wait)), | ||||||
| 			("hint", RoomSpecific (Hint)), | 			("hint", RoomSpecific (Hint)), | ||||||
| 		].into_iter () { | 		].into_iter () { | ||||||
|  |  | ||||||
|  | @ -71,6 +71,10 @@ async fn process_socket (socket: TcpStream, id: &str) | ||||||
| { | { | ||||||
| 	use kajam_10_game::Response; | 	use kajam_10_game::Response; | ||||||
| 	
 | 	
 | ||||||
|  | 	let mut interval = tokio::time::interval (tokio::time::Duration::from_millis (500)); | ||||||
|  | 	interval.set_missed_tick_behavior (tokio::time::MissedTickBehavior::Delay); | ||||||
|  | 	interval.tick ().await; | ||||||
|  | 	
 | ||||||
| 	let mut seq = 0; | 	let mut seq = 0; | ||||||
| 	let (mut read, mut write) = socket.into_split (); | 	let (mut read, mut write) = socket.into_split (); | ||||||
| 	
 | 	
 | ||||||
|  | @ -91,6 +95,7 @@ async fn process_socket (socket: TcpStream, id: &str) | ||||||
| 	} | 	} | ||||||
| 	
 | 	
 | ||||||
| 	'main_loop: loop { | 	'main_loop: loop { | ||||||
|  | 		interval.tick ().await; | ||||||
| 		let input = read_input (&mut read, &mut write).await.context ("couldn't get player input")?; | 		let input = read_input (&mut read, &mut write).await.context ("couldn't get player input")?; | ||||||
| 		tracing::debug! ("Processing input {} from connection {}", seq, id); | 		tracing::debug! ("Processing input {} from connection {}", seq, id); | ||||||
| 		seq += 1; | 		seq += 1; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 _
						_