diff --git a/README.md b/README.md index fc77726..fd313b0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/commands.py b/commands.py index 648c48c..8fb908f 100644 --- a/commands.py +++ b/commands.py @@ -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"]] + } diff --git a/run.py b/run.py index c56641c..b781f61 100755 --- a/run.py +++ b/run.py @@ -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,