mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Merge pull request #1436 from chainsol/fix_tunnel_exit_typeclass
Added basic Typeclass support to CmdTunnel
This commit is contained in:
commit
330e292a6e
2 changed files with 20 additions and 4 deletions
|
|
@ -866,7 +866,7 @@ class CmdTunnel(COMMAND_DEFAULT_CLASS):
|
|||
create new rooms in cardinal directions only
|
||||
|
||||
Usage:
|
||||
@tunnel[/switch] <direction> [= <roomname>[;alias;alias;...][:typeclass]]
|
||||
@tunnel[/switch] <direction>[:typeclass] [= <roomname>[;alias;alias;...][:typeclass]]
|
||||
|
||||
Switches:
|
||||
oneway - do not create an exit back to the current location
|
||||
|
|
@ -911,21 +911,34 @@ class CmdTunnel(COMMAND_DEFAULT_CLASS):
|
|||
"""Implements the tunnel command"""
|
||||
|
||||
if not self.args or not self.lhs:
|
||||
string = "Usage: @tunnel[/switch] <direction> [= <roomname>" \
|
||||
string = "Usage: @tunnel[/switch] <direction>[:typeclass] [= <roomname>" \
|
||||
"[;alias;alias;...][:typeclass]]"
|
||||
self.caller.msg(string)
|
||||
return
|
||||
if self.lhs not in self.directions:
|
||||
|
||||
# If we get a typeclass, we need to get just the exitname
|
||||
exitshort = self.lhs.split(":")[0]
|
||||
|
||||
if exitshort not in self.directions:
|
||||
string = "@tunnel can only understand the following directions: %s." % ",".join(
|
||||
sorted(self.directions.keys()))
|
||||
string += "\n(use @dig for more freedom)"
|
||||
self.caller.msg(string)
|
||||
return
|
||||
|
||||
# retrieve all input and parse it
|
||||
exitshort = self.lhs
|
||||
exitname, backshort = self.directions[exitshort]
|
||||
backname = self.directions[backshort][0]
|
||||
|
||||
# if we recieved a typeclass for the exit, add it to the alias(short name)
|
||||
if ":" in self.lhs:
|
||||
# limit to only the first : character
|
||||
exit_typeclass = ":" + self.lhs.split(":", 1)[-1]
|
||||
# exitshort and backshort are the last part of the exit strings,
|
||||
# so we add our typeclass argument after
|
||||
exitshort += exit_typeclass
|
||||
backshort += exit_typeclass
|
||||
|
||||
roomname = "Some place"
|
||||
if self.rhs:
|
||||
roomname = self.rhs # this may include aliases; that's fine.
|
||||
|
|
|
|||
|
|
@ -266,6 +266,9 @@ class TestBuilding(CommandTest):
|
|||
def test_tunnel(self):
|
||||
self.call(building.CmdTunnel(), "n = TestRoom2;test2", "Created room TestRoom2")
|
||||
|
||||
def test_tunnel_exit_typeclass(self):
|
||||
self.call(building.CmdTunnel(), "n:evennia.objects.objects.DefaultExit = TestRoom3", "Created room TestRoom3")
|
||||
|
||||
def test_exit_commands(self):
|
||||
self.call(building.CmdOpen(), "TestExit1=Room2", "Created new Exit 'TestExit1' from Room to Room2")
|
||||
self.call(building.CmdLink(), "TestExit1=Room", "Link created TestExit1 > Room (one way).")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue