ah, that's good enough. Now to run it un-protected on my server.

main
_ 2021-10-25 01:06:09 +00:00
parent 119ec04d0c
commit 28f11e74c5
2 changed files with 11 additions and 1 deletions

View File

@ -64,7 +64,7 @@ fn parse_input (s: &str) -> PlayerAction {
use PlayerAction::*;
use PlayerActionRoomSpecific::*;
let s = s.to_lowercase ();
let s = s.trim ().to_lowercase ();
let look = |rest| RoomSpecific (Look (parse_item_name (rest)));
let activate = |rest| RoomSpecific (Use (parse_item_name (rest)));
@ -185,6 +185,9 @@ pub enum Response {
JokeEnding,
FailedDetectionCheck,
PlayerVictory,
// These are hints for spam detection on the Telnet frontend
Nonsense,
}
#[derive (Clone, Copy)]
@ -254,6 +257,7 @@ impl State {
PlayerAction::Nonsense => vec! [
line_response ("I couldn't understand that. Try `help` or `hint`."),
line_response ("`hint` may contain spoilers. `help` will not."),
Response::Nonsense,
],
PlayerAction::RoomSpecific (x) => self.room_1 (x),
}
@ -414,6 +418,7 @@ mod test {
("look table", RoomSpecific (Look (ItemName::Table))),
("look note ", RoomSpecific (Look (ItemName::Note))),
("LOOK TABLE", RoomSpecific (Look (ItemName::Table))),
("look ", RoomSpecific (LookAround)),
("wait", RoomSpecific (Wait)),
("hint", RoomSpecific (Hint)),
].into_iter () {

View File

@ -71,6 +71,10 @@ async fn process_socket (socket: TcpStream, id: &str)
{
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 read, mut write) = socket.into_split ();
@ -91,6 +95,7 @@ async fn process_socket (socket: TcpStream, id: &str)
}
'main_loop: loop {
interval.tick ().await;
let input = read_input (&mut read, &mut write).await.context ("couldn't get player input")?;
tracing::debug! ("Processing input {} from connection {}", seq, id);
seq += 1;