Updated readme and release. Removed unused files.
Showing
4 changed files
with
127 additions
and
88 deletions
... | @@ -59,3 +59,125 @@ All damage rolls are described in the number of times to roll and the random amo | ... | @@ -59,3 +59,125 @@ All damage rolls are described in the number of times to roll and the random amo |
59 | * cost - The cost in stamina of the attack | 59 | * cost - The cost in stamina of the attack |
60 | * dmg - the amount of damage caused by this attack | 60 | * dmg - the amount of damage caused by this attack |
61 | * desc - the description to display when the attack is performed | 61 | * desc - the description to display when the attack is performed |
62 | |||
63 | ### Where to buy your ESP8266 | ||
64 | |||
65 | https://www.amazon.com/gp/product/B01IK9GEQG/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1 | ||
66 | |||
67 | I like the NodeMcu devices. They have 4mb flash and work well and are fairly robust and compact. | ||
68 | |||
69 | ### How to Load on a New ESP8266 | ||
70 | |||
71 | Use python 3.6+ | ||
72 | |||
73 | Create a virtual environment to save your brainspace. | ||
74 | |||
75 | ``` | ||
76 | virtualenv venv | ||
77 | ``` | ||
78 | |||
79 | Use your virtual env: | ||
80 | |||
81 | Mac / Linux: | ||
82 | ``` | ||
83 | source venv/bin/activate | ||
84 | ``` | ||
85 | |||
86 | Windows: | ||
87 | ``` | ||
88 | venv\Scripts\activate | ||
89 | ``` | ||
90 | |||
91 | Install esptool and the other required pip modules which will let you install the micropython firmware. | ||
92 | |||
93 | ``` | ||
94 | pip install -r requirements.txt | ||
95 | ``` | ||
96 | |||
97 | After the modules are installed you will need to use esptool to erase the flash. | ||
98 | if things go wrong... https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/intro.html | ||
99 | |||
100 | Find the com port, you should look in your devices, plug / unplug until you figure it out. | ||
101 | |||
102 | ``` | ||
103 | esptool --port COM1 erase_flash | ||
104 | ``` | ||
105 | |||
106 | This will remove all data from the device. | ||
107 | |||
108 | Download a version of micropython for your device: | ||
109 | |||
110 | http://micropython.org/resources/firmware/esp8266-20171101-v1.9.3.bin | ||
111 | |||
112 | The mud is written based on 1.9.3 and I suspect it will be very version sensitive. | ||
113 | |||
114 | After the file has been downloaded (use wget? browser? curl? whatever makes you happy) | ||
115 | |||
116 | ``` | ||
117 | esptool --port COM1 --baud 460800 write_flash --flash_size=detect 0 esp8266-20171101-v1.9.3.bin | ||
118 | ``` | ||
119 | |||
120 | This will write the binary micropython os to the device. After this you will want to validate the write was successful. | ||
121 | |||
122 | We will use the miniterm included with pyserial to connect to the device. | ||
123 | |||
124 | ``` | ||
125 | python -m serial.tools.miniterm COM1 115200 | ||
126 | ``` | ||
127 | |||
128 | After you get in you will have access to the micropython terminal which will let you run python. | ||
129 | |||
130 | Enter the following to check the firmware to be sure everything went well. | ||
131 | ``` | ||
132 | import esp | ||
133 | esp.check_fw() | ||
134 | ``` | ||
135 | |||
136 | This should return a "True" at the end along with the checksum if things went well. | ||
137 | |||
138 | Next the WebREPL server needs to be setup to ease file transfer. | ||
139 | |||
140 | ``` | ||
141 | import webrepl_setup | ||
142 | ``` | ||
143 | |||
144 | This script will ask you for a password and a few other odds and ends. | ||
145 | |||
146 | After a reboot you will need to configure your wifi. | ||
147 | |||
148 | ``` | ||
149 | import network | ||
150 | sta_if = network.WLAN(network.STA_IF) | ||
151 | ap_if = network.WLAN(network.AP_IF) | ||
152 | |||
153 | # activate the station interface | ||
154 | sta_if.active(True) | ||
155 | |||
156 | sta_if.connect('<your ESSID>', '<your password>') | ||
157 | |||
158 | # Run this again and again until you get an IP Address. If this fails your connect is likely wrong. | ||
159 | sta_if.ifconfig() | ||
160 | ``` | ||
161 | |||
162 | Note your IP Address from the sta_if.ifconfig() | ||
163 | |||
164 | Disconnect from the serial miniterm with a ctrl+] | ||
165 | |||
166 | After exiting the miniterm edit the release.py and change the IP Address and port: | ||
167 | |||
168 | ``` | ||
169 | PORT = 'COM1' | ||
170 | IPADDRESS = '192.168.1.122' | ||
171 | ``` | ||
172 | |||
173 | Run the release script: | ||
174 | |||
175 | ``` | ||
176 | python release.py | ||
177 | ``` | ||
178 | |||
179 | Reboot your device and the mud will be running at the IP Address on port 1234. To connect: | ||
180 | |||
181 | ``` | ||
182 | telnet 192.168.1.122 1234 | ||
183 | ``` | ... | ... |
inventoryhandler.py
deleted
100644 → 0
1 | import utils | ||
2 | |||
3 | class InventoryHandler(object): | ||
4 | |||
5 | def __init__(self, directory): | ||
6 | self.directory = directory | ||
7 | |||
8 | def _get_inventory_file(self, item_name): | ||
9 | filename = self.directory + '/' + item_name + ".txt" | ||
10 | item_data = utils.load_object_from_file(filename) | ||
11 | if item_data is None: | ||
12 | print("Error opening inventory file: {}".format(item_name)) | ||
13 | return {} | ||
14 | return item_data | ||
15 | |||
16 | def get_title(self, item_name): | ||
17 | return self._get_inventory_file(item_name)['title'] | ||
18 | |||
19 | def get_description(self, item_name): | ||
20 | return self._get_inventory_file(item_name)['description'] | ||
21 | |||
22 | def get_type(self, item_name): | ||
23 | return self._get_inventory_file(item_name)['type'] | ||
24 | |||
25 | def get_power(self, item_name): | ||
26 | return self._get_inventory_file(item_name)['power'] | ||
27 | |||
28 | def get_damage(self, item_name): | ||
29 | return self._get_inventory_file(item_name)['damage'] | ||
30 | |||
31 | def get_weight(self, item_name): | ||
32 | return self._get_inventory_file(item_name)['weight'] |
... | @@ -3,20 +3,22 @@ import io | ... | @@ -3,20 +3,22 @@ import io |
3 | import os | 3 | import os |
4 | import sys | 4 | import sys |
5 | 5 | ||
6 | ###################################### | ||
7 | # EDIT THIS TO MATCH YOUR SETTINGS | ||
6 | PORT = 'COM17' | 8 | PORT = 'COM17' |
9 | IPADDRESS = '192.168.1.122' | ||
10 | ###################################### | ||
11 | |||
7 | BAUDRATE = 115200 | 12 | BAUDRATE = 115200 |
8 | IPADDRESS = ' 192.168.1.122' | ||
9 | 13 | ||
10 | folders = ['help', 'rooms', 'inventory', 'commands', 'mobs'] | 14 | folders = ['help', 'rooms', 'inventory', 'commands', 'mobs'] |
11 | 15 | ||
12 | files = [ | 16 | files = [ |
13 | "commandhandler.py", | 17 | "commandhandler.py", |
14 | "inventoryhandler.py", | ||
15 | "main.py", | 18 | "main.py", |
16 | "mobs.txt", | 19 | "mobs.txt", |
17 | "spawner.txt", | 20 | "spawner.txt", |
18 | "mudserver.py", | 21 | "mudserver.py", |
19 | "roomloader.py", | ||
20 | "utils.py", | 22 | "utils.py", |
21 | "welcome.txt", | 23 | "welcome.txt", |
22 | "wifiweb.py" | 24 | "wifiweb.py" | ... | ... |
roomloader.py
deleted
100644 → 0
1 | |||
2 | import json | ||
3 | import utils | ||
4 | |||
5 | class RoomLoader(object): | ||
6 | |||
7 | def __init__(self, directory): | ||
8 | self.directory = directory | ||
9 | |||
10 | def _get_room_file(self, room_name): | ||
11 | filename = self.directory + '/' + room_name + ".txt" | ||
12 | room_data = utils.load_object_from_file(filename) | ||
13 | if room_data is None: | ||
14 | print("Error opening room file: {}".format(room_name)) | ||
15 | return {} | ||
16 | return room_data | ||
17 | |||
18 | def _save_room_file(self, room_name, room_data): | ||
19 | filename = self.directory + '/' + room_name + ".txt" | ||
20 | utils.save_object_to_file(room_data, filename) | ||
21 | |||
22 | def get_title(self, room_name): | ||
23 | return self._get_room_file(room_name).get('title', None) | ||
24 | |||
25 | def get_description(self, room_name): | ||
26 | return self._get_room_file(room_name).get('description', None) | ||
27 | |||
28 | def get_exits(self, room_name): | ||
29 | return self._get_room_file(room_name).get('exits', None) | ||
30 | |||
31 | def get_look_items(self, room_name): | ||
32 | return self._get_room_file(room_name).get('look_items', None) | ||
33 | |||
34 | def get_inventory(self, room_name): | ||
35 | return self._get_room_file(room_name).get('inventory', None) | ||
36 | |||
37 | def add_to_inventory(self, room_name, item_name, quantity): | ||
38 | room_data = self._get_room_file(room_name) | ||
39 | if item_name in room_data['inventory']: | ||
40 | room_data['inventory'][item_name] += quantity | ||
41 | else: | ||
42 | room_data['inventory'][item_name] = 1 | ||
43 | self._save_room_file(room_name, room_data) | ||
44 | return True | ||
45 | |||
46 | def remove_from_inventory(self, room_name, item_name, quantity): | ||
47 | room_data = self._get_room_file(room_name) | ||
48 | if item_name in room_data['inventory']: | ||
49 | room_data['inventory'][item_name] -= quantity | ||
50 | if room_data['inventory'][item_name] <= 0: | ||
51 | del room_data['inventory'][item_name] | ||
52 | self._save_room_file(room_name, room_data) | ||
53 | return True | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment