feat: added 'build' command

Added the build command, that allows creating custom rooms
This commit is contained in:
Marlow Alfonso 2023-11-21 23:53:39 +00:00
parent 914054b788
commit cc01e352fb
3 changed files with 30 additions and 3 deletions

View File

@ -2,7 +2,7 @@
_A Multi User Dungeon for UNIX.dog members_
## Features (TO-DO)
- [ ] User-created maps
- [x] User-created maps
- [ ] PvP
- [ ] PvE
- [x] Local chat

View File

@ -23,11 +23,14 @@ def go(mud, id, players, rooms, params):
exit = params_list[0]
room = rooms[players[id]["room"]]
if exit in room["exits"]:
if room["exits"][exit] not in rooms:
mud.send_message(id, "Room '{}' not found."
.format(room["exits"][exit]))
return
for pid, pl in players.items():
if pl["room"] == players[id]["room"] and pid != id:
mud.send_message(pid, "{} left via exit '{}'."
.format(players[id]["name"], exit))
players[id]["room"] = room["exits"][exit]
mud.send_message(id, "You arrive at '{}'.".format(players[id]["room"]))
@ -77,3 +80,22 @@ def open(mud, id, players, rooms, params):
rooms[players[id]["room"]]["exits"][params_list[0]] = params_list[1]
mud.send_message(id, "You open the exit '{}' to '{}'."
.format(params_list[0], params_list[1]))
def build(mud, id, players, rooms, params):
params_list = params.split()
if len(params_list) < 3:
mud.send_message(id, "Invalid params.")
return
params_list = [params_list[0], params_list[1], " ".join(params_list[2:])]
room = params_list[0]
if room in rooms:
mud.send_message("Room '{}' already exits."
.format(room))
return
rooms[room] = {
"description": params_list[2],
"exits": {params_list[1]: players[id]["room"]},
"owner": players[id]["name"],
"builders": [players[id]["name"]]
}

7
run.py
View File

@ -76,6 +76,10 @@ def cmd_wconnect(id, params):
.format(params_list[0]))
def cmd_build(id, params):
cmd.build(mud, id, players, rooms, params)
def cmd_unknown(id, command):
cmd.unknown(mud, command, id)
@ -85,7 +89,8 @@ commands = {
"look": cmd_look,
"go": cmd_go,
"say": cmd_say,
"open": cmd_open
"open": cmd_open,
"build": cmd_build
}
waitlist_commands = {
"help": cmd_whelp,