Added the feral skills code into the bot.
Showing
4 changed files
with
70 additions
and
9 deletions
... | @@ -413,6 +413,23 @@ def db_convert_soul_plate_to_reflector(member_id, soul_plate, idx): | ... | @@ -413,6 +413,23 @@ def db_convert_soul_plate_to_reflector(member_id, soul_plate, idx): |
413 | return True | 413 | return True |
414 | 414 | ||
415 | 415 | ||
416 | def db_convert_soul_plate_to_skill(member_id, soul_plate, idx, skill): | ||
417 | pankration_data = db_get_pankration_record(member_id) | ||
418 | |||
419 | skill_data = pankration_data['feral_skills'] | ||
420 | if not skill_data: | ||
421 | feral_skills = [] | ||
422 | else: | ||
423 | feral_skills = pickle.loads(str(skill_data)) | ||
424 | |||
425 | feral_skills.append(skill) | ||
426 | db_update_pankration_record(member_id, 'feral_skills', pickle.dumps(feral_skills)) | ||
427 | |||
428 | #if not db_remove_soul_plate(member_id, idx): | ||
429 | # return False | ||
430 | return True | ||
431 | |||
432 | |||
416 | def db_register_battle(member_id, reflector, idx, target_member_id=None): | 433 | def db_register_battle(member_id, reflector, idx, target_member_id=None): |
417 | pan_record = db_get_pankration_record(member_id) | 434 | pan_record = db_get_pankration_record(member_id) |
418 | conn = sqlite3.connect('db.sqlite3') | 435 | conn = sqlite3.connect('db.sqlite3') | ... | ... |
No preview for this file type
... | @@ -87,14 +87,14 @@ registered_commands = {'!help': 'do_help', '!commands': 'do_help', | ... | @@ -87,14 +87,14 @@ registered_commands = {'!help': 'do_help', '!commands': 'do_help', |
87 | '!stars': 'do_stars', | 87 | '!stars': 'do_stars', |
88 | '!rigged': 'do_rigged', | 88 | '!rigged': 'do_rigged', |
89 | '!listzones': 'do_list_zones', | 89 | '!listzones': 'do_list_zones', |
90 | '!huntmonster': 'do_hunt_monster', | 90 | '!huntmonster': 'do_hunt_monster', '!hunt': 'do_hunt_monster', |
91 | '!listferalskills': 'do_list_feral_skills', '!listferalskill': 'do_list_feral_skills', | 91 | '!listskills': 'do_list_feral_skills', '!listferalskills': 'do_list_feral_skills', '!listferalskill': 'do_list_feral_skills', |
92 | '!listreflectors': 'do_list_reflectors', '!listreflector': 'do_list_reflectors', | 92 | '!listreflectors': 'do_list_reflectors', '!listreflector': 'do_list_reflectors', |
93 | '!listsoulplates': 'do_list_soul_plates', '!listsoulplate': 'do_list_soul_plates', | 93 | '!listsoulplates': 'do_list_soul_plates', '!listsoulplate': 'do_list_soul_plates', |
94 | '!convertplate': 'do_convert_plate', '!convertsoulplate': 'do_convert_plate', | 94 | '!convert': 'do_convert_plate', '!convertplate': 'do_convert_plate', '!convertsoulplate': 'do_convert_plate', |
95 | '!assignskill': 'do_assign_skill', | ||
96 | '!registerbattle': 'do_register_battle', | 95 | '!registerbattle': 'do_register_battle', |
97 | '!setreflectorname': 'do_set_reflector_name', | 96 | '!setreflectorname': 'do_set_reflector_name', |
97 | '!equip': 'do_equip_feral_skills', '!equipskill': 'do_equip_feral_skills', '!equipferalskill': 'do_equip_feral_skills', | ||
98 | '!pankration': 'do_pankration', | 98 | '!pankration': 'do_pankration', |
99 | } | 99 | } |
100 | 100 | ||
... | @@ -1044,7 +1044,7 @@ def do_pankration(client, message_parts, message): | ... | @@ -1044,7 +1044,7 @@ def do_pankration(client, message_parts, message): |
1044 | 1044 | ||
1045 | *Hunting for Soul Plates:* | 1045 | *Hunting for Soul Plates:* |
1046 | **!listzones** - Returns a list of zones available for hunting and how many credits it costs to search in that zone. Depending on the weather and other factors some zones may not always be available. | 1046 | **!listzones** - Returns a list of zones available for hunting and how many credits it costs to search in that zone. Depending on the weather and other factors some zones may not always be available. |
1047 | **!huntmonster <zone>** - An attempt will be made to search for a soul plate (monster) in the zone specified. Each search costs a certain amount of credits. Each zone has a different cost. | 1047 | **!hunt <zone>** - An attempt will be made to search for a soul plate (monster) in the zone specified. Each search costs a certain amount of credits. Each zone has a different cost. |
1048 | 1048 | ||
1049 | *Viewing Your Inventory:* | 1049 | *Viewing Your Inventory:* |
1050 | **!listsoulplates** - Returns a list of all soul plates you have in your posession. | 1050 | **!listsoulplates** - Returns a list of all soul plates you have in your posession. |
... | @@ -1052,10 +1052,10 @@ def do_pankration(client, message_parts, message): | ... | @@ -1052,10 +1052,10 @@ def do_pankration(client, message_parts, message): |
1052 | **!listferalskills** - Returns a list of all feral skills you have in your inventory | 1052 | **!listferalskills** - Returns a list of all feral skills you have in your inventory |
1053 | 1053 | ||
1054 | *Editing Your Collections:* | 1054 | *Editing Your Collections:* |
1055 | **!convertplate <plate number> <convert_to>** - From the list of soul plates you can choose to either convert the plate into a \"reflector\" or \"skill\". | 1055 | **!convert <plate number> <convert_to>** - From the list of soul plates you can choose to either convert the plate into a \"reflector\" or \"skill\". |
1056 | Ex: **!convertplate 1 reflector** | 1056 | Ex: **!convertplate 1 reflector** |
1057 | **!convertplate 4 skill** | 1057 | **!convertplate 4 skill** |
1058 | **!assignskill <reflector number> <skill num>** - Assigns a skill to a reflector. Each skill is worth a certain amount of feral points, each monster has a maximum of feral points available. | 1058 | **!equip <skill num> <reflector number>** - Assigns a skill to a reflector. Each skill is worth a certain amount of feral points, each monster has a maximum of feral points available. |
1059 | **!setreflectorname <reflector number> <name>** - This will rename a monster in your collection to a custom name. | 1059 | **!setreflectorname <reflector number> <name>** - This will rename a monster in your collection to a custom name. |
1060 | 1060 | ||
1061 | *Arena Battle:* | 1061 | *Arena Battle:* |
... | @@ -1150,8 +1150,14 @@ def do_convert_plate(client, message_parts, message): | ... | @@ -1150,8 +1150,14 @@ def do_convert_plate(client, message_parts, message): |
1150 | else: | 1150 | else: |
1151 | send_message(client, message.channel, 'There was an issue converting your soul plate...Conversion failed.') | 1151 | send_message(client, message.channel, 'There was an issue converting your soul plate...Conversion failed.') |
1152 | elif convert_to == "skill": | 1152 | elif convert_to == "skill": |
1153 | send_message(client, message.channel, '**Feral Skills are not yet supported**') | 1153 | soul_plates[plate_num].convert_to_feral_skill() |
1154 | # do skill stuff | 1154 | skill = soul_plates[plate_num].convert_to_feral_skill() |
1155 | if not skill: | ||
1156 | send_message(client, message.channel, 'The conversion **failed** the soul plate has been destroyed in the process.') | ||
1157 | else: | ||
1158 | send_message(client, message.channel, 'Congratulations! The soul plate was converted to feral skill: **{}**'.format(byteify(skill))) | ||
1159 | data.db_convert_soul_plate_to_skill(member['member_id'], soul_plates[plate_num], plate_num, skill) | ||
1160 | do_list_feral_skills(client, message_parts, message) | ||
1155 | pass | 1161 | pass |
1156 | else: | 1162 | else: |
1157 | send_message(client, message.channel, 'A plate can only be converted into a reflector or skill. Please see !pankration for an example.') | 1163 | send_message(client, message.channel, 'A plate can only be converted into a reflector or skill. Please see !pankration for an example.') |
... | @@ -1190,6 +1196,44 @@ def do_list_reflectors(client, message_parts, message): | ... | @@ -1190,6 +1196,44 @@ def do_list_reflectors(client, message_parts, message): |
1190 | send_message(client, message.channel, 'You have no reflectors.') | 1196 | send_message(client, message.channel, 'You have no reflectors.') |
1191 | 1197 | ||
1192 | 1198 | ||
1199 | def do_equip_feral_skills(client, message_parts, message): | ||
1200 | member = data.db_get_member(message.author.id) | ||
1201 | |||
1202 | skill_num = message_parts[0] | ||
1203 | reflector_num = message_parts[1] | ||
1204 | |||
1205 | pankration_data = data.db_get_pankration_record(member['member_id']) | ||
1206 | if pankration_data and pankration_data['reflectors']: | ||
1207 | reflectors = pickle.loads(str(pankration_data['reflectors'])) | ||
1208 | |||
1209 | if pankration_data and pankration_data['feral_skills']: | ||
1210 | feral_skills = pickle.loads(str(pankration_data['feral_skills'])) | ||
1211 | |||
1212 | if not skill_num.isdigit() or int(skill_num) < 1 or int(skill_num) > len(feral_skills): | ||
1213 | send_message(client, message.channel, 'The requested feral skill is invalid. Please provide the number from !listferalskills') | ||
1214 | return | ||
1215 | skill_num = int(skill_num) - 1 | ||
1216 | if not reflector_num.isdigit() or int(reflector_num) < 1 or int(reflector_num) > len(reflectors): | ||
1217 | send_message(client, message.channel, 'The requested reflector is invalid. Please provide the number from !listreflectors') | ||
1218 | return | ||
1219 | reflector_num = int(reflector_num) - 1 | ||
1220 | |||
1221 | skill_name = feral_skills[skill_num] | ||
1222 | print(reflector_num) | ||
1223 | print(reflectors[reflector_num]) | ||
1224 | success, err_message = reflectors[reflector_num].equip_feral_skill(skill_name) | ||
1225 | if not success: | ||
1226 | send_message(client, message.channel, byteify(err_message)) | ||
1227 | else: | ||
1228 | data.db_update_pankration_record(member['member_id'], 'reflectors', pickle.dumps(reflectors)) | ||
1229 | send_message(client, message.channel, "{} has been equipped.\n{}".format(skill_name, reflectors[reflector_num])) | ||
1230 | |||
1231 | else: | ||
1232 | send_message(client, message.channel, 'You have no feral skills. You can get more feral skills by hunting for soul plates and converting them into skills.') | ||
1233 | else: | ||
1234 | send_message(client, message.channel, 'You have no reflectors. You can get more reflectors by hunting monsters and converting soul plates into reflectors.') | ||
1235 | |||
1236 | |||
1193 | def do_list_feral_skills(client, message_parts, message): | 1237 | def do_list_feral_skills(client, message_parts, message): |
1194 | member = data.db_get_member(message.author.id) | 1238 | member = data.db_get_member(message.author.id) |
1195 | 1239 | ... | ... |
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment