Added put command and bug fixes for look.
Showing
8 changed files
with
49 additions
and
6 deletions
... | @@ -44,6 +44,7 @@ def look(id, mud, players, tokens): | ... | @@ -44,6 +44,7 @@ def look(id, mud, players, tokens): |
44 | if len(items) > 0: | 44 | if len(items) > 0: |
45 | mud.send_message(id, 'You look in your {} and see:\r\n'.format(subject)) | 45 | mud.send_message(id, 'You look in your {} and see:\r\n'.format(subject)) |
46 | inv_list = [] | 46 | inv_list = [] |
47 | print(items) | ||
47 | for name, i in items.items(): | 48 | for name, i in items.items(): |
48 | if len(i) > 1: | 49 | if len(i) > 1: |
49 | inv_list.append(str(len(i)) + " " + name + "s") | 50 | inv_list.append(str(len(i)) + " " + name + "s") | ... | ... |
commands/put.txt
0 → 100644
1 | def put(id, tokens, players, mud): | ||
2 | if len(tokens) == 0: | ||
3 | mud.send_message(id, 'What do you want to put and where do you want to put it?') | ||
4 | return True | ||
5 | subject = tokens[0] | ||
6 | if 'in' == tokens[1]: | ||
7 | del tokens[1] | ||
8 | dest = tokens[1] | ||
9 | |||
10 | room_name = players[id]["room"] | ||
11 | room_data = utils.load_object_from_file('rooms/' + room_name + '.json') | ||
12 | |||
13 | if subject in players[id]['inventory']: | ||
14 | if dest in players[id]['inventory'] or dest in room_data['inventory']: | ||
15 | |||
16 | if dest in room_data['inventory']: | ||
17 | if subject in room_data['inventory'][dest][0]["inventory"].get(subject): | ||
18 | room_data['inventory'][dest][0]["inventory"][subject] = [players[id]['inventory'][subject].pop()] | ||
19 | else: | ||
20 | room_data['inventory'][dest][0]["inventory"][subject].append(players[id]['inventory'][subject].pop()) | ||
21 | elif dest in players[id]['inventory']: | ||
22 | if subject in players[id]['inventory'][dest][0]["inventory"].get(subject): | ||
23 | players[id]['inventory'][dest][0]["inventory"][subject] = [players[id]['inventory'][subject].pop()] | ||
24 | else: | ||
25 | players[id]['inventory'][dest][0]["inventory"][subject].append(players[id]['inventory'][subject].pop()) | ||
26 | if len(players[id]['inventory'][tokens[0]]) <= 0: | ||
27 | del players[id]['inventory'][tokens[0]] | ||
28 | |||
29 | utils.save_object_to_file(room_data, 'rooms/' + room_name + '.json') | ||
30 | for pid, pl in players.items(): | ||
31 | # if they're in the same room as the player | ||
32 | if players[pid]["room"] == players[id]["room"]: | ||
33 | # send them a message telling them what the player said | ||
34 | mud.send_message(pid, "{} put a {} in a {}.".format(players[id]["name"], subject, dest)) | ||
35 | utils.save_object_to_file(players[id], "players/{}.json".format(players[id]["name"])) | ||
36 | else: | ||
37 | mud.send_message(id, 'You cannot put {} in {} since it is not here.'.format(subject, dest)) | ||
38 | else: | ||
39 | mud.send_message(id, 'You do not have {} in your inventory.'.format(subject)) | ||
40 | |||
41 | put(id, tokens, players, mud) | ||
42 | del put | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | {"at": {"kick": {"desc": "You unleash a powerful kick", "dmg": "2d4", "cost": 5}}, "sp": {"fireball": {"desc": "A fireball blasts from your fingertips striking the target", "dmg": "2d4", "cost": 5}}, "mp": 10.0, "prompt": "h %hp m %mp s %st> ", "password": true, "mpr": 0.25, "maxmp": 10, "hp": 74, "maxhp": 953, "star": 0.4, "room": "Outside", "sta": 10.00000000000004, "inventory": {"bag": [{"inventory": {"candle": [{"expires": 0}, {"expires": 0}]}, "expires": 0}], "candle": [{"expires": 0}, {"expires": 0}]}, "maxsta": 10, "aa": "1d2", "weapon": "sword", "aliases": {}, "name": "test"} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | {"mpr": 0.25, "aa": "1d2", "password": true, "sp": {"fireball": {"desc": "A fireball blasts from your fingertips striking the target", "cost": 5, "dmg": "2d4"}}, "maxhp": 953, "maxsta": 10, "inventory": {"bag": [{"expires": 0, "inventory": {"candle": [{"expires": 0}, {"expires": 0}]}}], "candle": [{"age": 0}, {"age": 0}]}, "aliases": {}, "prompt": "h %hp m %mp s %st> ", "name": "test", "hp": 74, "mp": 10.0, "maxmp": 10, "weapon": "sword", "sta": 10.00000000000004, "room": "Room001", "at": {"kick": {"desc": "You unleash a powerful kick", "cost": 5, "dmg": "2d4"}}, "star": 0.4} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | {"inventory": {"candle": [{"age": 0}, {"age": 0}]}, "look_items": {"tavern": "A roughly constructed building."}, "title": "Outside the Tavern", "exits": {"tavern": "Tavern"}, "description": "You are standing outside of a simple tavern made of pressed clay and shale roof. The door becons you to come in and have a drink."} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | {"look_items": {"tavern": "A roughly constructed building."}, "description": "You are standing outside of a simple tavern made of pressed clay and shale roof. The door becons you to come in and have a drink.", "inventory": {}, "exits": {"tavern": "Tavern"}, "title": "Outside the Tavern"} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | {"description": "The back of the bar gives a full view of the tavern. The bar top is a large wooden plank thrown across some barrels.", "look_items": {"bar": "The bar is a long wooden plank thrown over roughly hewn barrels.", "barrel,barrels": "The old barrels bands are thick with oxidation and stained with the purple of spilled wine.", "wooden,oak,plank": "An old solid oak plank that has a large number of chips and drink marks."}, "title": "Behind the bar", "exits": {"tavern": "Tavern"}, "inventory": {}} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | {"look_items": {"wooden,oak,plank": "An old solid oak plank that has a large number of chips and drink marks.", "barrel,barrels": "The old barrels bands are thick with oxidation and stained with the purple of spilled wine.", "bar": "The bar is a long wooden plank thrown over roughly hewn barrels."}, "description": "The back of the bar gives a full view of the tavern. The bar top is a large wooden plank thrown across some barrels.", "inventory": {"candle": [{"age": 0}]}, "exits": {"tavern": "Tavern"}, "title": "Behind the bar"} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | {"cricket": {"active": [{"sta": 10, "target": "", "maxhp": 15, "maxmp": 10, "maxsta": 10, "hp": 15, "mp": 10, "action": "attack"}], "max": 1}} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | {"cricket": {"max": 1, "active": [{"hp": 15, "mp": 10, "maxmp": 10, "maxhp": 15, "sta": 10, "maxsta": 10, "target": "", "action": "attack"}]}} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | {"title": "Tavern", "description": "You're in a cozy tavern warmed by an open fire.", "exits": {"outside": "Outside", "behind": "Room001", "dark": "Dark"}, "look_items": {"bar": "The bar is a long wooden plank thrown over roughly hewn barrels.", "barrel,barrels": "The old barrels bands are thick with oxidation and stained with the purple of spilled wine.", "wooden,oak,plank": "An old solid oak plank that has a large number of chips and drink marks.", "fire": "The fire crackles quietly in the corner providing a small amount of light and heat."}, "inventory": {"candle": [{"age": 0}, {"age": 0}, {"age": 0}, {"age": 0}, {"age": 0}, {"age": 0}, {"age": 0}]}} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | {"look_items": {"wooden,oak,plank": "An old solid oak plank that has a large number of chips and drink marks.", "barrel,barrels": "The old barrels bands are thick with oxidation and stained with the purple of spilled wine.", "bar": "The bar is a long wooden plank thrown over roughly hewn barrels.", "fire": "The fire crackles quietly in the corner providing a small amount of light and heat."}, "description": "You're in a cozy tavern warmed by an open fire.", "inventory": {"candle": [{"age": 0}, {"age": 0}, {"age": 0}, {"age": 0}, {"age": 0}]}, "exits": {"behind": "Room001", "dark": "Dark", "outside": "Outside"}, "title": "Tavern"} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | {"cricket": {"active": [{"sta": 10, "target": "", "maxhp": 20, "maxmp": 10, "maxsta": 10, "hp": 20, "mp": 10, "action": "attack"}, {"sta": 10, "target": "", "maxhp": 23, "maxmp": 10, "maxsta": 10, "hp": 23, "mp": 10, "action": "attack"}], "max": 2}} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | {"cricket": {"max": 2, "active": [{"hp": 20, "mp": 10, "maxmp": 10, "maxhp": 20, "sta": 10, "maxsta": 10, "target": "", "action": "attack"}, {"hp": 23, "mp": 10, "maxmp": 10, "maxhp": 23, "sta": 10, "maxsta": 10, "target": "", "action": "attack"}]}} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment