Fix a bug when a guest logs in
Also, wrote our expect script to validate the world interface.
This commit is contained in:
parent
250a57827b
commit
da51b5293f
4 changed files with 203 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -59,3 +59,4 @@ nosetests.xml
|
|||
/server/ssh-private.key
|
||||
/server/ssh-public.key
|
||||
/transcripts/202*.html
|
||||
/world/guest-book.md
|
||||
|
|
|
|||
|
|
@ -121,9 +121,11 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
|
|||
grove = self.search("mp01", global_search=True, quiet=True)
|
||||
if isinstance(grove, list):
|
||||
grove = grove[0]
|
||||
self.move_to(grove, quiet=True, use_destination=True)
|
||||
# self.move_to(grove, quiet=True, use_destination=True)
|
||||
self.location = grove
|
||||
|
||||
# Start the tutorial:
|
||||
self.db.visited = False
|
||||
self.db.jumped_times = 0
|
||||
self.db.tutorstate = 0
|
||||
TutorBird.do_start_tutorial(self)
|
||||
|
|
|
|||
195
world/test-run.exp
Executable file
195
world/test-run.exp
Executable file
|
|
@ -0,0 +1,195 @@
|
|||
#!/usr/bin/expect
|
||||
# Set timeout for expect commands
|
||||
set timeout 30
|
||||
|
||||
# Open the log file
|
||||
log_file results.txt
|
||||
|
||||
proc expectit {pattern} {
|
||||
expect {
|
||||
$pattern {
|
||||
return
|
||||
}
|
||||
timeout {
|
||||
puts "Error: Expected response '$pattern' not received."
|
||||
exit 1
|
||||
}
|
||||
eof {
|
||||
puts "Error: Connection closed unexpectedly."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Start the SSH session
|
||||
# spawn ssh -p 4004 user@howardabrams.com
|
||||
# Handle the password prompt
|
||||
# expectit "password:"
|
||||
# send "\r" ; # Send an empty password
|
||||
#
|
||||
# or
|
||||
spawn telnet localhost 4000
|
||||
|
||||
# Handle the prompt after logging in
|
||||
expectit "After you've logged in Enter"
|
||||
send "connect guest beourguest\n"
|
||||
|
||||
# That should be enough of the birdie ...
|
||||
expectit "perches on your shoulder"
|
||||
send "shoo\n"
|
||||
|
||||
# Send the time command and handle the response
|
||||
expectit "Have fun, and I'll leave you here"
|
||||
send "time\n"
|
||||
expect {
|
||||
"in the evening" {
|
||||
set phase "evening"
|
||||
}
|
||||
"in the afternoon" {
|
||||
set phase "afternoon"
|
||||
}
|
||||
"in the morning" {
|
||||
set phase "morning"
|
||||
}
|
||||
# What about "at night"?
|
||||
timeout {
|
||||
puts "Error: Expected time response not received."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
send "look\n"
|
||||
|
||||
# Expect different responses based on the phase variable
|
||||
switch $phase {
|
||||
"evening" {
|
||||
expect "darkening twilight"
|
||||
}
|
||||
"afternoon" {
|
||||
expect "lazy afternoon"
|
||||
}
|
||||
"morning" {
|
||||
expect "awakening dawn"
|
||||
}
|
||||
default {
|
||||
puts "Error: Unexpected phase value '$phase'."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
send "look trees\n"
|
||||
expectit "You feel dwarfed by colossal trees"
|
||||
|
||||
send "jump\n"
|
||||
expectit "You jump in the puddle!"
|
||||
|
||||
send "get stick\n"
|
||||
expect {
|
||||
"Could not find 'stick'." {
|
||||
# Print warning in red
|
||||
# send_user "\033[31mNo stick, check the stick script.\033[0m\n"
|
||||
send_user "No stick, check the stick script.\n"
|
||||
}
|
||||
"You pick up a stick." {
|
||||
# If stick is found, throw it
|
||||
send "throw stick\n"
|
||||
expect "it comes back to you"
|
||||
send "drop stick\n"
|
||||
expect "You drop a stick."
|
||||
}
|
||||
timeout {
|
||||
puts "Error: Expected response for 'get stick' not received."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
send "read book\n"
|
||||
# expect -re "You open the leather-bound book, and begin to read\[.\n\r\]*For repayment of a boon, The Summer Queen"
|
||||
expectit "You open the leather-bound book, and begin to read"
|
||||
expectit "For repayment of a boon, The Summer Queen"
|
||||
|
||||
expectit "revious"
|
||||
# quit reading the book:
|
||||
send "q\n"
|
||||
|
||||
send "look\n"
|
||||
expect {
|
||||
-re "Exits:.*" {
|
||||
# Store the matched line in a variable
|
||||
set matched_line $expect_out(buffer)
|
||||
|
||||
# Check if the matched line contains "boulder"
|
||||
if {[string match boulder $matched_line]} {
|
||||
puts "Error: The line contains 'boulder'."
|
||||
exit 1
|
||||
} else {
|
||||
puts "The line is valid and does not contain 'boulder'."
|
||||
}
|
||||
}
|
||||
timeout {
|
||||
puts "Error: Expected line starting with 'Exits:' not received."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
send "look boulder\n"
|
||||
expectit "You notice a foot hold"
|
||||
|
||||
send "look\n"
|
||||
expect -re "Exits:.*climb.*boulder"
|
||||
|
||||
expect {
|
||||
-re "You notice.*" {
|
||||
# Store the matched line in a variable
|
||||
set matched_line $expect_out(buffer)
|
||||
|
||||
# Check if the matched line contains "boulder"
|
||||
if {[string match vines $matched_line]} {
|
||||
puts "Error: The line contains 'vines'."
|
||||
exit 1
|
||||
} else {
|
||||
puts "The line is valid and does not contain 'vines'."
|
||||
}
|
||||
}
|
||||
timeout {
|
||||
puts "Error: Expected line starting with 'Exits:' not received."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
send "look vines\n"
|
||||
expectit "Strong vines twisted to look like rope"
|
||||
|
||||
send "look\n"
|
||||
expect -re "You notice.*vines"
|
||||
|
||||
send "climb boulder\n"
|
||||
expectit "You grab hold of some"
|
||||
|
||||
# And once on top...
|
||||
expectit "Still, a nice view."
|
||||
|
||||
send "sit moss"
|
||||
expectit "You sit on the patch of moss."
|
||||
|
||||
# We can't get this stuff:
|
||||
send "get moss"
|
||||
expectit "The moss is a bryophyte"
|
||||
|
||||
# Close the log file
|
||||
log_file
|
||||
|
||||
sleep 1
|
||||
send "quit\n"
|
||||
|
||||
# Handle the connection closed message without logging it
|
||||
expect {
|
||||
"Connection closed by foreign host" {
|
||||
# Ignore this response
|
||||
exp_continue
|
||||
}
|
||||
eof {
|
||||
# End the session
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ py timed_script = evennia.create_script(key="Create Sticks",
|
|||
# The ability to /climb/ the boulder isn’t immediately obvious, so let’s make it a bit of a secret:
|
||||
|
||||
# [[file:../../../projects/mud.org::*Boulder][Boulder:6]]
|
||||
@desc boulder = A boulder with patches of |Ymoss|n and delicate clover. A carved |Ysymbol|n and even some |Yrunes|n try to hide behind rope-like vines and tendrils of |Yivy|n as if keeping a secret.|/|/You notice a foot hold, and then another. You can |Gclimb|n this boulder!
|
||||
@desc boulder = A boulder with patches of |Ymoss|n and delicate clover. A carved |Ysymbol|n and even some |Yrunes|n try to hide behind rope-like |Yvines|n and tendrils of |Yivy|n as if keeping a secret.|/|/You notice a foot hold, and then another. You can |Gclimb|n this boulder!
|
||||
# Boulder:6 ends here
|
||||
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ py timed_script = evennia.create_script(key="Create Sticks",
|
|||
# [[file:../../../projects/mud.org::*Boulder][Boulder:12]]
|
||||
@lock vines = get:false()
|
||||
#
|
||||
@set vines/get_err_msg = "The vines are too strong to break or cut. Perhaps they could be detached from on top of the |Yboulder|n?"
|
||||
@set vines/get_err_msg = "The vines are too strong to break or cut. Perhaps they could be detached from the top of the |Yboulder|n?"
|
||||
# Boulder:12 ends here
|
||||
|
||||
|
||||
|
|
@ -2395,7 +2395,7 @@ pose gnome/default = smoking his pipe
|
|||
|
||||
|
||||
# [[file:../../../projects/mud.org::*Journal][Journal:3]]
|
||||
@desc journal = Leather-bound book worns with ages.
|
||||
@desc journal = Leather-bound book, cracked and worn from ages.
|
||||
#
|
||||
@give journal = gnome
|
||||
# Journal:3 ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue