Refactored the way messages are processed. Added new raffle.
Showing
4 changed files
with
350 additions
and
156 deletions
1 | import operator | ||
1 | import sqlite3 | 2 | import sqlite3 |
3 | import datetime | ||
2 | 4 | ||
3 | conn = sqlite3.connect('db.sqlite3') | 5 | conn = sqlite3.connect('db.sqlite3') |
4 | 6 | ||
5 | def log(message): | 7 | def log(message): |
8 | try: | ||
6 | logging.warning("{} - {}".format(datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S'), message)) | 9 | logging.warning("{} - {}".format(datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S'), message)) |
10 | except: | ||
11 | pass | ||
7 | 12 | ||
8 | ################## | 13 | ################## |
9 | ## Database Calls | 14 | ## Database Calls | ... | ... |
No preview for this file type
... | @@ -4,8 +4,8 @@ import requests | ... | @@ -4,8 +4,8 @@ import requests |
4 | import discord | 4 | import discord |
5 | import random | 5 | import random |
6 | import datetime | 6 | import datetime |
7 | import time | ||
7 | import re | 8 | import re |
8 | import operator | ||
9 | import pickle | 9 | import pickle |
10 | import logging | 10 | import logging |
11 | 11 | ||
... | @@ -39,12 +39,48 @@ client = discord.Client() | ... | @@ -39,12 +39,48 @@ client = discord.Client() |
39 | wolf = {} | 39 | wolf = {} |
40 | logging.basicConfig(filename='hellsbot.log',level=logging.WARNING) | 40 | logging.basicConfig(filename='hellsbot.log',level=logging.WARNING) |
41 | 41 | ||
42 | registered_commands = {'!help': 'do_help', '!commands': 'do_help', | ||
43 | '!shutup': 'do_shutup', | ||
44 | '!roll': 'do_roll', | ||
45 | '!lastseen': 'do_lastseen', | ||
46 | '!youtube': 'do_youtube', | ||
47 | '!image': 'do_image', | ||
48 | '!gif': 'do_gif', | ||
49 | '!gameslist': 'do_gameslist', '!gamelist': 'do_gameslist', | ||
50 | '!aliases': 'do_alias', '!alias': 'do_alias', | ||
51 | '!addalias': 'do_addalias', | ||
52 | '!games': 'do_games', | ||
53 | '!reloadbot': 'do_reload', '!restartbot': 'do_reload', '!rebootbot': 'do_reload', | ||
54 | '!whoplayed': 'do_whoplayed', | ||
55 | '!gimmecredits': 'do_gimmecredits', '!gimmecredit': 'do_gimmecredits', | ||
56 | '!grantcredits': 'do_grantcredits', | ||
57 | '!ticketrank': 'do_ticketrank', | ||
58 | '!startraffle': 'do_startraffle', | ||
59 | '!raffle': 'do_raffle', | ||
60 | '!buyticket': 'do_buyticket', | ||
61 | '!balance': 'do_balance', | ||
62 | '!slotsrules': 'do_slotsrules', | ||
63 | '!slots': 'do_slots', | ||
64 | '!hit': 'do_bj_hit', '!draw': 'do_bj_hit', | ||
65 | '!stay': 'do_bj_stay', '!stand': 'do_bj_stay', | ||
66 | '!bet': 'do_bj_bet', | ||
67 | '!msg': 'do_msg', | ||
68 | '!addfortune': 'do_addfortune', | ||
69 | '!fortune': 'do_fortune', | ||
70 | '!question': 'do_question', | ||
71 | '!addjoke': 'do_addjoke', | ||
72 | '!joke': 'do_joke', | ||
73 | } | ||
74 | |||
42 | ##################### | 75 | ##################### |
43 | ## Utility Functions | 76 | ## Utility Functions |
44 | ##################### | 77 | ##################### |
45 | 78 | ||
46 | def log(message): | 79 | def log(message): |
80 | try: | ||
47 | logging.warning("{} - {}".format(datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S'), message)) | 81 | logging.warning("{} - {}".format(datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S'), message)) |
82 | except: | ||
83 | pass | ||
48 | 84 | ||
49 | def format_exception(e): | 85 | def format_exception(e): |
50 | exception_list = traceback.format_stack() | 86 | exception_list = traceback.format_stack() |
... | @@ -145,30 +181,60 @@ def check_msg_queue(): | ... | @@ -145,30 +181,60 @@ def check_msg_queue(): |
145 | log("{}\nFailed to send message: {}".format(format_exception(e), message['message_id'],)) | 181 | log("{}\nFailed to send message: {}".format(format_exception(e), message['message_id'],)) |
146 | return | 182 | return |
147 | 183 | ||
148 | @client.event | 184 | def do_roll(client, message_parts, message): |
149 | def on_message(message): | 185 | request = message_parts[0] |
150 | #print message.content | 186 | count = 1 |
151 | #print message.author | 187 | dice = 100 |
152 | #print client.user | 188 | if request.strip() != '': |
153 | global muted_until | 189 | if 'd' in request: |
154 | # we do not want the bot to reply to itself | 190 | dice_parts = request.split('d') |
155 | if message.author == client.user: | 191 | if len(dice_parts) == 2: |
192 | if dice_parts[0].isdigit() and dice_parts[1].isdigit(): | ||
193 | count = int(dice_parts[0]) | ||
194 | dice = int(dice_parts[1]) | ||
195 | if count > 100000000000000000: | ||
196 | client.send_message(message.channel, '{} stop fucking around with those stupid numbers...'.format(message.author.mention())) | ||
156 | return | 197 | return |
157 | 198 | ||
158 | if message.content.lower().startswith(client.user.name.lower()): | 199 | if count > 100: |
159 | log('Someone is talking to %s' % (client.user.name.lower(),)) | 200 | client.send_message(message.channel, '{} 100 is the largest number of dice I will roll.'.format(message.author.mention())) |
160 | if ' or ' in message.content: | 201 | return |
161 | questions = message.content[len(client.user.name)+1:].replace('?', '').split(' or ') | 202 | roll_results = [] |
162 | client.send_message(message.channel, '{} I choose: {}'.format(message.author.mention(), random.choice(questions).encode('utf-8',errors='ignore'))) | 203 | for i in range(count): |
204 | roll_results.append(random.randint(1,dice)) | ||
205 | out_string = '{} your roll {}d{}: {} = {}'.format(message.author.mention(), count, dice, '+'.join(str(r) for r in roll_results), sum(roll_results)) | ||
206 | client.send_message(message.channel, out_string) | ||
207 | return | ||
208 | |||
209 | def do_lastseen(client, message_parts, message): | ||
210 | username = ' '.join(message_parts).replace('@', '').lower() | ||
211 | member = data.db_get_member(username=username) | ||
212 | #log(member) | ||
213 | if member: | ||
214 | out_string = '' | ||
215 | if member['is_afk'] == 1: | ||
216 | out_string = 'Went AFK at: {}\n'.format(member['afk_at']) | ||
217 | elif member['status'] == 'offline': | ||
218 | out_string = 'Currently Offline\n' | ||
219 | else: | ||
220 | out_string = 'Currently Online\n' | ||
221 | out_string += 'Last Status: {} at {} which was {}\nPrevious Status: {}\n'.format(member['status'], | ||
222 | member['status_change_at'], | ||
223 | human(datetime.datetime.strptime(member['status_change_at'], '%Y/%m/%d %H:%M:%S')), | ||
224 | member['prev_status']) | ||
163 | 225 | ||
226 | client.send_message(message.channel, 'Last Information on {}:\n{}'.format(byteify(username), out_string)) | ||
227 | else: | ||
228 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(byteify(username), message.author.mention())) | ||
229 | return | ||
164 | 230 | ||
165 | if message.content.startswith('!help') or message.content.startswith('!commands'): | 231 | def do_help(client, message_parts, message): |
166 | client.send_message(message.channel, | 232 | client.send_message(message.channel, |
167 | """{} Available Commands: | 233 | """{} Available Commands: |
168 | You can ask compound or questions and I will choose. Example: HellsBot Rui is a Faggot or Rui is a faggot? | 234 | You can ask compound or questions and I will choose. Example: HellsBot Rui is a Faggot or Rui is a faggot? |
169 | 235 | ||
170 | User Info: | 236 | User Info: |
171 | !aliases - Returns a list of all aliases a user has set for themselves. | 237 | !aliases <username> - Returns a list of all aliases a user has set for themselves. |
172 | !addalias <alias> - Adds an alias to your list of aliases. | 238 | !addalias <alias> - Adds an alias to your list of aliases. |
173 | !lastseen <username> - Returns info on when the user was last seen and their status. | 239 | !lastseen <username> - Returns info on when the user was last seen and their status. |
174 | Messages: | 240 | Messages: |
... | @@ -203,88 +269,36 @@ Stuff: | ... | @@ -203,88 +269,36 @@ Stuff: |
203 | !joke - Returns a random joke. | 269 | !joke - Returns a random joke. |
204 | !roll <1d20> - Roll X number of dice of size X. 1d20 returns 1 roll 1-20. 3d6 returns 3 rolls of 1-6 etc... | 270 | !roll <1d20> - Roll X number of dice of size X. 1d20 returns 1 roll 1-20. 3d6 returns 3 rolls of 1-6 etc... |
205 | !secret | 271 | !secret |
206 | !shutup - disables all image / gif / youtube span for 5 minutes | 272 | !shutup - disables all image / gif / youtube spam for 5 minutes |
207 | !bemyirlwaifu""".format(message.author.mention())) | 273 | !bemyirlwaifu""".format(message.author.mention())) |
208 | return | ||
209 | |||
210 | if message.content.startswith('!lastseen'): | ||
211 | username = message.content[10:].replace('@', '').lower() | ||
212 | member = data.db_get_member(username=username) | ||
213 | #log(member) | ||
214 | if member: | ||
215 | out_string = '' | ||
216 | if member['is_afk'] == 1: | ||
217 | out_string = 'Went AFK at: {}\n'.format(member['afk_at']) | ||
218 | elif member['status'] == 'offline': | ||
219 | out_string = 'Currently Offline\n' | ||
220 | else: | ||
221 | out_string = 'Currently Online\n' | ||
222 | out_string += 'Last Status: {} at {} which was {}\nPrevious Status: {}\n'.format(member['status'], | ||
223 | member['status_change_at'], | ||
224 | human(datetime.datetime.strptime(member['status_change_at'], '%Y/%m/%d %H:%M:%S')), | ||
225 | member['prev_status']) | ||
226 | |||
227 | client.send_message(message.channel, 'Last Information on {}:\n{}'.format(username, out_string)) | ||
228 | else: | ||
229 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention())) | ||
230 | return | ||
231 | 274 | ||
232 | if message.content.startswith('!shutup'): | 275 | def do_shutup(client, message_parts, message): |
233 | muted_until = datetime.datetime.now() + datetime.timedelta(minutes=5) | 276 | muted_until = datetime.datetime.now() + datetime.timedelta(minutes=5) |
234 | client.send_message(message.channel, search_youtube(query)) | 277 | client.send_message(message.channel, 'All image / gif / youtube spam disabled for 5 minutes') |
235 | return | 278 | return |
236 | 279 | ||
237 | if message.content.startswith('!youtube'): | 280 | def do_youtube(client, message_parts, message): |
238 | if datetime.datetime.now() < muted_until: | 281 | if datetime.datetime.now() < muted_until: |
239 | return | 282 | return |
240 | query = message.content[9:] | 283 | client.send_message(message.channel, search_youtube(' '.join(message_parts))) |
241 | client.send_message(message.channel, search_youtube(query)) | ||
242 | return | 284 | return |
243 | 285 | ||
244 | if message.content.startswith('!image'): | 286 | def do_image(client, message_parts, message): |
245 | if datetime.datetime.now() < muted_until: | 287 | if datetime.datetime.now() < muted_until: |
246 | return | 288 | return |
247 | query = message.content[7:] | 289 | client.send_message(message.channel, search_google_images(' '.join(message_parts))) |
248 | client.send_message(message.channel, search_google_images(query)) | ||
249 | return | 290 | return |
250 | 291 | ||
251 | if message.content.startswith('!gif'): | 292 | def do_gif(client, message_parts, message): |
252 | if datetime.datetime.now() < muted_until: | 293 | if datetime.datetime.now() < muted_until: |
253 | return | 294 | return |
254 | query = message.content[7:] | 295 | client.send_message(message.channel, search_google_images(' '.join(message_parts), True)) |
255 | client.send_message(message.channel, search_google_images(query, True)) | ||
256 | return | ||
257 | |||
258 | if message.content.startswith('!roll'): | ||
259 | request = message.content[6:] | ||
260 | count = 1 | ||
261 | dice = 100 | ||
262 | if request.strip() != '': | ||
263 | if 'd' in request: | ||
264 | dice_parts = request.split('d') | ||
265 | if len(dice_parts) == 2: | ||
266 | if dice_parts[0].isdigit() and dice_parts[1].isdigit(): | ||
267 | count = int(dice_parts[0]) | ||
268 | dice = int(dice_parts[1]) | ||
269 | if count > 100000000000000000: | ||
270 | client.send_message(message.channel, '{} stop fucking around with those stupid numbers...'.format(message.author.mention())) | ||
271 | return | 296 | return |
272 | 297 | ||
273 | if count > 100: | 298 | def do_gameslist(client, message_parts, message): |
274 | client.send_message(message.channel, '{} 100 is the largest number of dice I will roll.'.format(message.author.mention())) | ||
275 | return | ||
276 | roll_results = [] | ||
277 | for i in range(count): | ||
278 | roll_results.append(random.randint(1,dice)) | ||
279 | out_string = '{} your roll {}d{}: {} = {}'.format(message.author.mention(), count, dice, '+'.join(str(r) for r in roll_results), sum(roll_results)) | ||
280 | client.send_message(message.channel, out_string) | ||
281 | return | ||
282 | |||
283 | if message.content.startswith('!gameslist') or message.content.startswith('!gamelist') : | ||
284 | parts = message.content.split(' ') | ||
285 | limit = 20 | 299 | limit = 20 |
286 | if len(parts) > 1 and parts[1].isdigit(): | 300 | if len(message_parts) > 0 and message_parts[0].isdigit(): |
287 | limit = int(parts[1]) | 301 | limit = int(message_parts[0]) |
288 | games_list = data.db_get_games_list(limit) | 302 | games_list = data.db_get_games_list(limit) |
289 | 303 | ||
290 | out_string = '' | 304 | out_string = '' |
... | @@ -294,24 +308,27 @@ Stuff: | ... | @@ -294,24 +308,27 @@ Stuff: |
294 | while len(out_string) > 0: | 308 | while len(out_string) > 0: |
295 | client.send_message(message.channel, out_string[:1900]) | 309 | client.send_message(message.channel, out_string[:1900]) |
296 | out_string = out_string[1900:] | 310 | out_string = out_string[1900:] |
297 | |||
298 | return | 311 | return |
299 | 312 | ||
300 | if message.content.startswith('!aliases'): | 313 | def do_alias(client, message_parts, message): |
301 | username = message.content[9:].replace('@', '').lower() | 314 | if len(message_parts) > 0: |
315 | username = ' '.join(message_parts).replace('@', '').lower() | ||
302 | member = data.db_get_member(username=username) | 316 | member = data.db_get_member(username=username) |
317 | else: | ||
318 | username = message.author.name | ||
319 | member = data.db_get_member(message.author.id) | ||
303 | if member: | 320 | if member: |
304 | aliases = data.db_get_aliases(member['member_id']) | 321 | aliases = data.db_get_aliases(member['member_id']) |
305 | if aliases: | 322 | if aliases: |
306 | client.send_message(message.channel, '{} has the following aliases: {}'.format(username, byteify(', '.join(aliases)))) | 323 | client.send_message(message.channel, '{} has the following aliases: {}'.format(byteify(username), byteify(', '.join(aliases)))) |
307 | else: | 324 | else: |
308 | client.send_message(message.channel, 'No known alises for {} yet {}'.format(username, message.author.mention())) | 325 | client.send_message(message.channel, 'No known alises for {} yet {}'.format(byteify(username), message.author.mention())) |
309 | else: | 326 | else: |
310 | client.send_message(message.channel, 'I don\'t know who you are speaking of {}!'.format(message.author.mention())) | 327 | client.send_message(message.channel, 'I don\'t know who you are speaking of {}!'.format(message.author.mention())) |
311 | return | 328 | return |
312 | 329 | ||
313 | if message.content.startswith('!addalias'): | 330 | def do_addalias(client, message_parts, message): |
314 | alias = message.content[10:] | 331 | alias = ' '.join(message_parts) |
315 | username = message.author.name.lower() | 332 | username = message.author.name.lower() |
316 | member = data.db_get_member(username=username) | 333 | member = data.db_get_member(username=username) |
317 | if member: | 334 | if member: |
... | @@ -321,17 +338,28 @@ Stuff: | ... | @@ -321,17 +338,28 @@ Stuff: |
321 | client.send_message(message.channel, 'Something horrible happened and it is all your fault, try logging out / on again or play a game. (or fuck off i dunno i\'m just an error message. Who am I to tell you how to run your life...)') | 338 | client.send_message(message.channel, 'Something horrible happened and it is all your fault, try logging out / on again or play a game. (or fuck off i dunno i\'m just an error message. Who am I to tell you how to run your life...)') |
322 | return | 339 | return |
323 | 340 | ||
324 | if message.content.startswith('!games'): | 341 | def do_games(client, message_parts, message): |
325 | username = message.content[7:].replace('@', '').lower() | 342 | if len(message_parts) > 0: |
343 | username = ' '.join(message_parts).replace('@', '').lower() | ||
344 | else: | ||
345 | username = message.author.name | ||
326 | games_list = data.db_get_games(username) | 346 | games_list = data.db_get_games(username) |
327 | if games_list: | 347 | if games_list: |
328 | games = ', '.join(games_list) | 348 | games = ', '.join(games_list) |
329 | client.send_message(message.channel, 'I have seen {} playing: {}'.format(username, games)) | 349 | games = games.replace("FINAL FANTASY XIV", "**FINAL FANTASY XIV**") |
350 | log(byteify(games)) | ||
351 | client.send_message(message.channel, 'I have seen {} playing: {}'.format(byteify(username), byteify(games))) | ||
330 | else: | 352 | else: |
331 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention())) | 353 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(byteify(username), message.author.mention())) |
354 | |||
355 | def do_reload(client, message_parts, message): | ||
356 | if message.author.id != '78767557628133376': | ||
357 | client.send_message(message.channel, "You shouldn't be calling this. You are clearly looking to piss Hellsbreath off.") | ||
358 | return | ||
359 | call(["service", "hellsbot", "restart"]) | ||
332 | 360 | ||
333 | if message.content.startswith('!whoplayed'): | 361 | def do_whoplayed(client, message_parts, message): |
334 | game_name = message.content[11:] | 362 | game_name = ' '.join(message_parts) |
335 | member_list = data.db_get_whoplayed(game_name) | 363 | member_list = data.db_get_whoplayed(game_name) |
336 | if not member_list: | 364 | if not member_list: |
337 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(byteify(game_name), message.author.mention())) | 365 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(byteify(game_name), message.author.mention())) |
... | @@ -345,7 +373,7 @@ Stuff: | ... | @@ -345,7 +373,7 @@ Stuff: |
345 | out_string = out_string[1900:] | 373 | out_string = out_string[1900:] |
346 | return | 374 | return |
347 | 375 | ||
348 | if message.content.startswith('!gimmecredits'): | 376 | def do_gimmecredits(client, message_parts, message): |
349 | member = data.db_get_member(message.author.id) | 377 | member = data.db_get_member(message.author.id) |
350 | if not member: | 378 | if not member: |
351 | client.send_message(message.author, "There was a problem looking up your information.") | 379 | client.send_message(message.author, "There was a problem looking up your information.") |
... | @@ -359,7 +387,7 @@ Stuff: | ... | @@ -359,7 +387,7 @@ Stuff: |
359 | client.send_message(message.author, "You already have credits. Stop begging.") | 387 | client.send_message(message.author, "You already have credits. Stop begging.") |
360 | return | 388 | return |
361 | 389 | ||
362 | if message.content.startswith('!grantcredits'): | 390 | def do_grantcredits(clients, message_parts, message): |
363 | if message.author.id != '78767557628133376': | 391 | if message.author.id != '78767557628133376': |
364 | client.send_message(message.channel, "You are not Hellsbreath. Use !gimmecredits to get a few extra if you run out.") | 392 | client.send_message(message.channel, "You are not Hellsbreath. Use !gimmecredits to get a few extra if you run out.") |
365 | return | 393 | return |
... | @@ -374,10 +402,7 @@ Stuff: | ... | @@ -374,10 +402,7 @@ Stuff: |
374 | client.send_message(message.channel, "{} has been given {} credits.".format(member['member_name'], 100)) | 402 | client.send_message(message.channel, "{} has been given {} credits.".format(member['member_name'], 100)) |
375 | return | 403 | return |
376 | 404 | ||
377 | if message.content.startswith('!ticketrank'): | 405 | def do_ticketrank(clients, message_parts, message): |
378 | # if message.author.id != '78767557628133376': | ||
379 | # client.send_message(message.channel, "You are not Hellsbreath. Use !gimmecredits to get a few extra if you run out.") | ||
380 | # return | ||
381 | members = data.db_get_all_members() | 406 | members = data.db_get_all_members() |
382 | if len(members) < 0: | 407 | if len(members) < 0: |
383 | client.send_message(message.channel, "There was a problem looking up your information.") | 408 | client.send_message(message.channel, "There was a problem looking up your information.") |
... | @@ -401,7 +426,7 @@ Stuff: | ... | @@ -401,7 +426,7 @@ Stuff: |
401 | client.send_message(message.channel, out_string) | 426 | client.send_message(message.channel, out_string) |
402 | return | 427 | return |
403 | 428 | ||
404 | if message.content.startswith('!startraffle'): | 429 | def do_startraffle(client, message_parts, message): |
405 | if message.author.id != '78767557628133376': | 430 | if message.author.id != '78767557628133376': |
406 | client.send_message(message.channel, "You are not Hellsbreath. Go die in an especially hot fire.") | 431 | client.send_message(message.channel, "You are not Hellsbreath. Go die in an especially hot fire.") |
407 | return | 432 | return |
... | @@ -426,28 +451,33 @@ Stuff: | ... | @@ -426,28 +451,33 @@ Stuff: |
426 | ticket_reel += [member['discord_mention']] * member['tickets'] | 451 | ticket_reel += [member['discord_mention']] * member['tickets'] |
427 | percent = (float(member['tickets']) / float(ticket_count)) * 100.0 | 452 | percent = (float(member['tickets']) / float(ticket_count)) * 100.0 |
428 | out_string += "{} - {}%\n".format(byteify(member['member_name']), int(percent)) | 453 | out_string += "{} - {}%\n".format(byteify(member['member_name']), int(percent)) |
454 | if len(ticket_reel) > 0: | ||
429 | winner = random.choice(ticket_reel) | 455 | winner = random.choice(ticket_reel) |
430 | while winner in ticket_reel: | 456 | while winner in ticket_reel: |
431 | ticket_reel.remove(winner) | 457 | ticket_reel.remove(winner) |
458 | client.send_message(message.channel, "\n\n\n**The winner is....\n\n{}!**".format(byteify(winner))) | ||
459 | if len(ticket_reel) > 0: | ||
432 | second = random.choice(ticket_reel) | 460 | second = random.choice(ticket_reel) |
433 | while second in ticket_reel: | 461 | while second in ticket_reel: |
434 | ticket_reel.remove(second) | 462 | ticket_reel.remove(second) |
463 | time.sleep(0.5) | ||
464 | client.send_message(message.channel, "\n\n*2nd Place:* {}".format(byteify(winner))) | ||
465 | if len(ticket_reel) > 0: | ||
435 | third = random.choice(ticket_reel) | 466 | third = random.choice(ticket_reel) |
436 | 467 | time.sleep(0.5) | |
437 | out_string += "\n\n\n**The winner is....\n\n{}!**\n\n*2nd Place:* {}\n*3rd Place:* {}".format(byteify(winner), byteify(second), byteify(third)) | 468 | client.send_message(message.channel, "\n*3rd Place:* {}".format(byteify(winner))) |
438 | client.send_message(message.channel, byteify(out_string)) | ||
439 | return | 469 | return |
440 | 470 | ||
441 | if message.content.startswith('!raffle'): | 471 | def do_raffle(client, message_parts, message): |
442 | client.send_message(message.channel, """Current Raffle Item: | 472 | client.send_message(message.channel, """Current Raffle Item: |
443 | 473 | ||
444 | **1st Place** | 474 | **1st Place** |
445 | 475 | ||
446 | Game: **Fairy Fencer F** | 476 | Game: **Lightning Returns** |
447 | Description: | 477 | Description: |
448 | *Long ago, the Vile God and the Goddess waged war with each other. Equally matched, they were sealed away in another world… Now a lazy young man named Fang somehow finds himself a key part of this war he’d really rather not deal with, but fate beckons in this uncommon RPG!* | 478 | *Lightning Returns is the concluding chapter of the Final Fantasy XIII saga and series heroine Lightning's final battle. The grand finale of the trilogy brings a world reborn as well as free character customization and stunning action based battles.* |
449 | 479 | ||
450 | http://store.steampowered.com/app/347830/ | 480 | http://store.steampowered.com/app/345350/ |
451 | 481 | ||
452 | **2nd Place** | 482 | **2nd Place** |
453 | 483 | ||
... | @@ -457,7 +487,7 @@ http://store.steampowered.com/app/347830/ | ... | @@ -457,7 +487,7 @@ http://store.steampowered.com/app/347830/ |
457 | 487 | ||
458 | 1 Random Steam Key | 488 | 1 Random Steam Key |
459 | 489 | ||
460 | Raffle Date: **2/2/2016 00:00:00 (ish)** | 490 | Raffle Date: **2/9/2016 00:00:00 (ish)** |
461 | 491 | ||
462 | You will be contacted if you win. To win you must purchase tickets with the !buyticket command for 100 credits. | 492 | You will be contacted if you win. To win you must purchase tickets with the !buyticket command for 100 credits. |
463 | You can get extra credits by playing !slots <amount> and !bet <amount> on BlackJack. | 493 | You can get extra credits by playing !slots <amount> and !bet <amount> on BlackJack. |
... | @@ -465,7 +495,8 @@ You can get extra credits by playing !slots <amount> and !bet <amount> on BlackJ | ... | @@ -465,7 +495,8 @@ You can get extra credits by playing !slots <amount> and !bet <amount> on BlackJ |
465 | **Disclaimer:** *If anything should go wrong you get no refund and there is no guarantee or warrantee on anything. 1 prize per person no matter how many tickets you have.* | 495 | **Disclaimer:** *If anything should go wrong you get no refund and there is no guarantee or warrantee on anything. 1 prize per person no matter how many tickets you have.* |
466 | """) | 496 | """) |
467 | return | 497 | return |
468 | if message.content.startswith('!buyticket'): | 498 | |
499 | def do_buyticket(client, message_parts, message): | ||
469 | member = data.db_get_member(message.author.id) | 500 | member = data.db_get_member(message.author.id) |
470 | if not member: | 501 | if not member: |
471 | client.send_message(message.author, "There was a problem looking up your information.") | 502 | client.send_message(message.author, "There was a problem looking up your information.") |
... | @@ -479,7 +510,7 @@ You can get extra credits by playing !slots <amount> and !bet <amount> on BlackJ | ... | @@ -479,7 +510,7 @@ You can get extra credits by playing !slots <amount> and !bet <amount> on BlackJ |
479 | client.send_message(message.author, "Raffle ticket purchased. Tickets: {} Credits: {}".format(response, credits)) | 510 | client.send_message(message.author, "Raffle ticket purchased. Tickets: {} Credits: {}".format(response, credits)) |
480 | return | 511 | return |
481 | 512 | ||
482 | if message.content.startswith('!balance'): | 513 | def do_balance(client, message_parts, message): |
483 | member = data.db_get_member(message.author.id) | 514 | member = data.db_get_member(message.author.id) |
484 | if not member: | 515 | if not member: |
485 | client.send_message(message.author, "There was a problem looking up your information.") | 516 | client.send_message(message.author, "There was a problem looking up your information.") |
... | @@ -487,7 +518,7 @@ You can get extra credits by playing !slots <amount> and !bet <amount> on BlackJ | ... | @@ -487,7 +518,7 @@ You can get extra credits by playing !slots <amount> and !bet <amount> on BlackJ |
487 | client.send_message(message.author, "Credits: {}\nTickets: {}".format(member['credits'], member['tickets'])) | 518 | client.send_message(message.author, "Credits: {}\nTickets: {}".format(member['credits'], member['tickets'])) |
488 | return | 519 | return |
489 | 520 | ||
490 | if message.content.startswith('!slotsrules'): | 521 | def do_slotsrules(client, message_parts, message): |
491 | client.send_message(message.channel, """Paying Combinations: | 522 | client.send_message(message.channel, """Paying Combinations: |
492 | 523 | ||
493 | :moneybag:\t:moneybag:\t:moneybag:\t\t\t pays\t250 | 524 | :moneybag:\t:moneybag:\t:moneybag:\t\t\t pays\t250 |
... | @@ -506,7 +537,8 @@ Max Bet: 10 credits | ... | @@ -506,7 +537,8 @@ Max Bet: 10 credits |
506 | 537 | ||
507 | To Play: !slots <bet>""") | 538 | To Play: !slots <bet>""") |
508 | return | 539 | return |
509 | if message.content.startswith('!slots'): | 540 | |
541 | def do_slots(client, message_parts, message): | ||
510 | member = data.db_get_member(message.author.id) | 542 | member = data.db_get_member(message.author.id) |
511 | if not member: | 543 | if not member: |
512 | client.send_message(message.author, "There was a problem looking up your information.") | 544 | client.send_message(message.author, "There was a problem looking up your information.") |
... | @@ -571,12 +603,10 @@ To Play: !slots <bet>""") | ... | @@ -571,12 +603,10 @@ To Play: !slots <bet>""") |
571 | credits = data.db_get_credit(member['member_id']) | 603 | credits = data.db_get_credit(member['member_id']) |
572 | out_string += "\nCredits: {}".format(credits) | 604 | out_string += "\nCredits: {}".format(credits) |
573 | 605 | ||
574 | #log(out_string) | ||
575 | client.send_message(message.author, out_string) | 606 | client.send_message(message.author, out_string) |
576 | |||
577 | return | 607 | return |
578 | 608 | ||
579 | if message.content.startswith('!hit') or message.content.startswith('!draw'): | 609 | def do_bj_hit(client, message_parts, message): |
580 | member = data.db_get_member(message.author.id) | 610 | member = data.db_get_member(message.author.id) |
581 | if not member: | 611 | if not member: |
582 | client.send_message(message.author, "There was a problem looking up your information.") | 612 | client.send_message(message.author, "There was a problem looking up your information.") |
... | @@ -613,7 +643,7 @@ To Play: !slots <bet>""") | ... | @@ -613,7 +643,7 @@ To Play: !slots <bet>""") |
613 | client.send_message(message.author, "You must start a game with !bet before you can ask for a new card.") | 643 | client.send_message(message.author, "You must start a game with !bet before you can ask for a new card.") |
614 | return | 644 | return |
615 | 645 | ||
616 | if message.content.startswith('!stay') or message.content.startswith('!stand'): | 646 | def do_bj_stay(client, message_parts, message): |
617 | member = data.db_get_member(message.author.id) | 647 | member = data.db_get_member(message.author.id) |
618 | if not member: | 648 | if not member: |
619 | client.send_message(message.author, "There was a problem looking up your information.") | 649 | client.send_message(message.author, "There was a problem looking up your information.") |
... | @@ -639,7 +669,7 @@ To Play: !slots <bet>""") | ... | @@ -639,7 +669,7 @@ To Play: !slots <bet>""") |
639 | client.send_message(message.author, out_string) | 669 | client.send_message(message.author, out_string) |
640 | return | 670 | return |
641 | 671 | ||
642 | if message.content.startswith('!bet'): | 672 | def do_bj_bet(client, message_parts, message): |
643 | member = data.db_get_member(message.author.id) | 673 | member = data.db_get_member(message.author.id) |
644 | if not member: | 674 | if not member: |
645 | client.send_message(message.author, "There was a problem looking up your information.") | 675 | client.send_message(message.author, "There was a problem looking up your information.") |
... | @@ -707,16 +737,15 @@ To Play: !slots <bet>""") | ... | @@ -707,16 +737,15 @@ To Play: !slots <bet>""") |
707 | out_string += "\nCredits: {}".format(credits) | 737 | out_string += "\nCredits: {}".format(credits) |
708 | 738 | ||
709 | client.send_message(message.author, out_string) | 739 | client.send_message(message.author, out_string) |
710 | |||
711 | return | 740 | return |
712 | 741 | ||
713 | # !msg joe in 5 minutes YOU ARE A DICK | 742 | def do_msg(client, message_parts, message): |
714 | if message.content.startswith('!msg'): | ||
715 | channel = message.channel | 743 | channel = message.channel |
716 | author = message.author | 744 | author = message.author |
717 | #author = message.author.name | 745 | #author = message.author.name |
718 | username = '' | 746 | username = '' |
719 | try: | 747 | try: |
748 | # TODO: Switch message_bits with message_parts | ||
720 | message_bits = message.content.split(" ") | 749 | message_bits = message.content.split(" ") |
721 | msg_datetime = datetime.datetime.now() | 750 | msg_datetime = datetime.datetime.now() |
722 | msg_idx = 2 | 751 | msg_idx = 2 |
... | @@ -745,7 +774,7 @@ To Play: !slots <bet>""") | ... | @@ -745,7 +774,7 @@ To Play: !slots <bet>""") |
745 | user_mention = '' | 774 | user_mention = '' |
746 | # TODO: have it look in the database. Do this AFTER on startup we add all users. | 775 | # TODO: have it look in the database. Do this AFTER on startup we add all users. |
747 | for member in client.get_all_members(): | 776 | for member in client.get_all_members(): |
748 | log("MEMBER: %s" % member) | 777 | #log("MEMBER: {}".format(byteify(member))) |
749 | if username.lower() == member.name.lower(): | 778 | if username.lower() == member.name.lower(): |
750 | user_mention = member.mention() | 779 | user_mention = member.mention() |
751 | user_id = member.id | 780 | user_id = member.id |
... | @@ -755,13 +784,13 @@ To Play: !slots <bet>""") | ... | @@ -755,13 +784,13 @@ To Play: !slots <bet>""") |
755 | 784 | ||
756 | msg_text = byteify(' '.join(message_bits[msg_idx:])) | 785 | msg_text = byteify(' '.join(message_bits[msg_idx:])) |
757 | message = {'user_id': user_id, 'channel': channel.id, 'delivery_time': msg_datetime.strftime('%Y/%m/%d %H:%M:%S'), 'message': msg_text} | 786 | message = {'user_id': user_id, 'channel': channel.id, 'delivery_time': msg_datetime.strftime('%Y/%m/%d %H:%M:%S'), 'message': msg_text} |
758 | log("Message: %s" % message) | 787 | log("Message: %s" % byteify(message)) |
759 | data.db_add_message(msg_text, msg_datetime.strftime('%Y-%m-%d %H:%M:%S'), channel.id, author.mention(), user_mention, user_id) | 788 | data.db_add_message(msg_text, msg_datetime.strftime('%Y-%m-%d %H:%M:%S'), channel.id, author.mention(), user_mention, user_id) |
760 | # print("Data: %s" % data) | 789 | # print("Data: %s" % data) |
761 | #test_ch = Object(channel.id) | 790 | #test_ch = Object(channel.id) |
762 | #client.send_message(test_ch, 'Test Message {}.'.format(author)) | 791 | #client.send_message(test_ch, 'Test Message {}.'.format(author)) |
763 | except Exception as e: | 792 | except Exception as e: |
764 | client.send_message(channel, 'Your shitty message has been rejected {}. {}'.format(author.name, e)) | 793 | client.send_message(channel, 'Your shitty message has been rejected {}. {}'.format(author.name, format_exception(e))) |
765 | return | 794 | return |
766 | if msg_datetime < datetime.datetime.now(): | 795 | if msg_datetime < datetime.datetime.now(): |
767 | client.send_message(channel, '{} your message will be delivered to {} as soon as they are available.'.format(author.name, user_mention)) | 796 | client.send_message(channel, '{} your message will be delivered to {} as soon as they are available.'.format(author.name, user_mention)) |
... | @@ -770,7 +799,7 @@ To Play: !slots <bet>""") | ... | @@ -770,7 +799,7 @@ To Play: !slots <bet>""") |
770 | check_msg_queue() | 799 | check_msg_queue() |
771 | return | 800 | return |
772 | 801 | ||
773 | if message.content.startswith('!addfortune'): | 802 | def do_addfortune(client, message_parts, message): |
774 | try: | 803 | try: |
775 | fortune = message.content[9:] | 804 | fortune = message.content[9:] |
776 | if 'aa737a5846' in fortune: | 805 | if 'aa737a5846' in fortune: |
... | @@ -788,10 +817,11 @@ To Play: !slots <bet>""") | ... | @@ -788,10 +817,11 @@ To Play: !slots <bet>""") |
788 | client.send_message(message.channel, 'Your shitty fortune has been added {}.'.format(message.author.mention())) | 817 | client.send_message(message.channel, 'Your shitty fortune has been added {}.'.format(message.author.mention())) |
789 | return | 818 | return |
790 | 819 | ||
791 | if message.content.startswith('!fortune'): | 820 | def do_fortune(client, message_parts, message): |
792 | fortune = None | 821 | fortune = None |
793 | try: | 822 | try: |
794 | c = conn.cursor() | 823 | c = conn.cursor() |
824 | # TODO: Move this shit to data | ||
795 | fortune = c.execute("SELECT fortune FROM fortunes ORDER BY RANDOM() LIMIT 1;").fetchone()[0] | 825 | fortune = c.execute("SELECT fortune FROM fortunes ORDER BY RANDOM() LIMIT 1;").fetchone()[0] |
796 | log(fortune) | 826 | log(fortune) |
797 | except Exception as e: | 827 | except Exception as e: |
... | @@ -803,7 +833,7 @@ To Play: !slots <bet>""") | ... | @@ -803,7 +833,7 @@ To Play: !slots <bet>""") |
803 | client.send_message(message.channel, '{} Your fortune is... {}'.format(message.author.mention(), byteify(fortune))) | 833 | client.send_message(message.channel, '{} Your fortune is... {}'.format(message.author.mention(), byteify(fortune))) |
804 | return | 834 | return |
805 | 835 | ||
806 | if message.content.startswith('!question'): | 836 | def do_question(client, message_parts, message): |
807 | question = message.content[10:] | 837 | question = message.content[10:] |
808 | if "is it gay" in question: | 838 | if "is it gay" in question: |
809 | client.send_message(message.channel, 'Yes {}, it is gay.'.format(message.author.mention())) | 839 | client.send_message(message.channel, 'Yes {}, it is gay.'.format(message.author.mention())) |
... | @@ -832,7 +862,7 @@ To Play: !slots <bet>""") | ... | @@ -832,7 +862,7 @@ To Play: !slots <bet>""") |
832 | client.send_message(message.channel, 'I don\'t know {}.'.format(message.author.mention())) | 862 | client.send_message(message.channel, 'I don\'t know {}.'.format(message.author.mention())) |
833 | return | 863 | return |
834 | 864 | ||
835 | if message.content.startswith('!addjoke'): | 865 | def do_addjoke(client, message_parts, message): |
836 | try: | 866 | try: |
837 | joke = message.content[9:] | 867 | joke = message.content[9:] |
838 | if 'aa737a5846' in joke: | 868 | if 'aa737a5846' in joke: |
... | @@ -850,7 +880,7 @@ To Play: !slots <bet>""") | ... | @@ -850,7 +880,7 @@ To Play: !slots <bet>""") |
850 | client.send_message(message.channel, 'Your shitty joke has been added {}.'.format(message.author.mention())) | 880 | client.send_message(message.channel, 'Your shitty joke has been added {}.'.format(message.author.mention())) |
851 | return | 881 | return |
852 | 882 | ||
853 | if message.content.startswith('!joke'): | 883 | def do_joke(client, message_parts, message): |
854 | joke = None | 884 | joke = None |
855 | try: | 885 | try: |
856 | c = conn.cursor() | 886 | c = conn.cursor() |
... | @@ -865,23 +895,54 @@ To Play: !slots <bet>""") | ... | @@ -865,23 +895,54 @@ To Play: !slots <bet>""") |
865 | client.send_message(message.channel, '{} {}'.format(message.author.mention(), byteify(joke))) | 895 | client.send_message(message.channel, '{} {}'.format(message.author.mention(), byteify(joke))) |
866 | return | 896 | return |
867 | 897 | ||
898 | @client.event | ||
899 | def on_message(message): | ||
900 | #print message.content | ||
901 | #print message.author | ||
902 | #print client.user | ||
903 | global muted_until | ||
904 | # we do not want the bot to reply to itself | ||
905 | if message.author == client.user: | ||
906 | return | ||
907 | |||
908 | message_parts = message.content.split(" ") | ||
909 | for command, method in registered_commands.iteritems(): | ||
910 | if message_parts[0] == command: | ||
911 | try: | ||
912 | globals()[method](client, message_parts[1:], message) | ||
913 | except Exception as e: | ||
914 | log("{} - {}".format(format_exception(e), e.message)) | ||
915 | return | ||
916 | |||
917 | if message.content.lower().startswith(client.user.name.lower()): | ||
918 | log('Someone is talking to %s' % (client.user.name.lower(),)) | ||
919 | if ' or ' in message.content: | ||
920 | questions = message.content[len(client.user.name)+1:].replace('?', '').split(' or ') | ||
921 | client.send_message(message.channel, '{} I choose: {}'.format(message.author.mention(), random.choice(questions).encode('utf-8',errors='ignore'))) | ||
922 | |||
868 | if message.content.startswith('!secret'): | 923 | if message.content.startswith('!secret'): |
869 | client.send_message(message.channel, 'git gud {}! My source is here: http://git.savsoul.com/barry/discordbot\nVersion: {}'.format(message.author.mention(), VERSION)) | 924 | client.send_message(message.channel, 'git gud {}! My source is here: http://git.savsoul.com/barry/discordbot\nVersion: {}'.format(message.author.mention(), VERSION)) |
925 | return | ||
870 | 926 | ||
871 | if message.content.startswith('!bemyirlwaifu'): | 927 | if message.content.startswith('!bemyirlwaifu'): |
872 | client.send_message(message.channel, 'http://orig13.deviantart.net/b25e/f/2014/175/3/d/no_waifu_no_laifu_by_imtheonenexttome-d7nsx3b.gif {}!'.format(message.author.mention())) | 928 | client.send_message(message.channel, 'http://orig13.deviantart.net/b25e/f/2014/175/3/d/no_waifu_no_laifu_by_imtheonenexttome-d7nsx3b.gif {}!'.format(message.author.mention())) |
929 | return | ||
873 | 930 | ||
874 | if message.content.startswith('HILLARY 2016'): | 931 | if message.content.startswith('HILLARY 2016'): |
875 | client.send_message(message.channel, ':bomb: Ohhhhhh, now you done it...:bomb:'.format(message.author.mention())) | 932 | client.send_message(message.channel, ':bomb: Ohhhhhh, now you done it...:bomb:'.format(message.author.mention())) |
933 | return | ||
934 | |||
935 | if message.content.startswith('!squid'): | ||
936 | client.send_message(message.channel, 'くコ:彡 くコ:彡 くコ:彡 くコ:彡') | ||
937 | return | ||
938 | |||
939 | if message.content.startswith('!stars'): | ||
940 | client.send_message(message.channel, '✮═━┈ ✰═━┈ ✮═━┈ ✰═━┈ ✮═━┈ ✰═━┈ ✮═━┈ ✰═━┈ ✮═━┈ ✰═━┈ ✰═━┈┈ ✰═━┈┈') | ||
941 | return | ||
876 | 942 | ||
877 | if message.content.startswith('!hello'): | 943 | if message.content.startswith('!hello'): |
878 | client.send_message(message.channel, 'Hello {}!'.format(message.author.mention())) | 944 | client.send_message(message.channel, 'Hello {}!'.format(message.author.mention())) |
879 | |||
880 | if message.content.startswith('!reloadbot'): | ||
881 | if message.author.id != '78767557628133376': | ||
882 | client.send_message(message.channel, "You shouldn't be calling this. You are clearly looking to piss Hellsbreath off.") | ||
883 | return | 945 | return |
884 | call(["service", "hellsbot", "restart"]) | ||
885 | 946 | ||
886 | 947 | ||
887 | @client.event | 948 | @client.event | ... | ... |
1 | import random | 1 | import random |
2 | import time | 2 | import time |
3 | import pickle | ||
3 | 4 | ||
4 | FIND_PERCENTAGE = 80 | 5 | FIND_PERCENTAGE = 100 |
5 | 6 | SKILL_PERCENT = 80 | |
6 | 7 | ||
7 | class HuntResponse: | 8 | class HuntResponse: |
8 | ERROR = -1 | 9 | ERROR = -1 |
... | @@ -14,6 +15,7 @@ class HuntResponse: | ... | @@ -14,6 +15,7 @@ class HuntResponse: |
14 | self.message = message | 15 | self.message = message |
15 | self.monster = monster | 16 | self.monster = monster |
16 | 17 | ||
18 | exp_to_level = [500, 1250, 2250, 3500, 5000, 6750, 8750, 10950, 13350, 15950, 18750, 21750, 24950, 28350, 31950, 35750, 39750, 43950, 48350, 52950, 57750, 62750, 67850, 73050, 78350, 83750, 89250, 94850, 100550, 106350, 112250, 118250, 124350, 130550, 136850, 143250, 149750, 156350, 163050, 169850, 176750, 183750, 190850, 198050, 205350, 212750, 220250, 227850, 235550] | ||
17 | 19 | ||
18 | class Jobs: | 20 | class Jobs: |
19 | WAR = 1 | 21 | WAR = 1 |
... | @@ -39,6 +41,20 @@ class Jobs: | ... | @@ -39,6 +41,20 @@ class Jobs: |
39 | GEO = 21 | 41 | GEO = 21 |
40 | RUN = 22 | 42 | RUN = 22 |
41 | 43 | ||
44 | TemperamentPosture = { | ||
45 | 4: {"name": "Very Agressive", "message": "Show no mercy!", "value": 4}, | ||
46 | 3: {"name": "Somewhat Agressive", "message": "Give em' a little more bite!", "value": 3}, | ||
47 | 2: {"name": "Somewhat Defensive", "message": "Back off a bit!", "value": 2}, | ||
48 | 1: {"name": "Very Defensive", "message": "Guard! Block! Parry! Hold!", "value": 1} | ||
49 | } | ||
50 | |||
51 | TemperamentAttitude = { | ||
52 | 4: {"name": "Very Wild", "message": "Don't think, kill!", "value": 4}, | ||
53 | 3: {"name": "Somewhat Wild", "message": "Less thinking, more striking!", "value": 3}, | ||
54 | 2: {"name": "Somewhat Tame", "message": "Watch your opponent, then attack!", "value": 2}, | ||
55 | 1: {"name": "Very Tame", "message": "Think, and think again!", "value": 1} | ||
56 | } | ||
57 | |||
42 | PhysicalDamageTypes = { | 58 | PhysicalDamageTypes = { |
43 | 'blunt': ['Hand-to-Hand', 'Club', 'Staff', 'Harlequin Frame', 'Stormwaker Frame', 'Sharpshot Frame'], | 59 | 'blunt': ['Hand-to-Hand', 'Club', 'Staff', 'Harlequin Frame', 'Stormwaker Frame', 'Sharpshot Frame'], |
44 | 'slashing': ['Axe', 'Great Axe', 'Great Sword', 'Sword', 'Scythe', 'Katana', 'Great Katana', 'Valoredge Frame'], | 60 | 'slashing': ['Axe', 'Great Axe', 'Great Sword', 'Sword', 'Scythe', 'Katana', 'Great Katana', 'Valoredge Frame'], |
... | @@ -46,7 +62,7 @@ PhysicalDamageTypes = { | ... | @@ -46,7 +62,7 @@ PhysicalDamageTypes = { |
46 | } | 62 | } |
47 | 63 | ||
48 | FeralSkills = { | 64 | FeralSkills = { |
49 | 'Airy Shield': {'type': 'Enhancing', 'sub_type': 'arrow shield', 'shadows': 'ignore', 'range': None, 'aoe': False, 'spell': 'arrow shield'}, | 65 | 'Airy Shield': {'fp_cost': 0, 'type': 'Enhancing', 'sub_type': 'arrow shield', 'shadows': 'ignore', 'range': None, 'aoe': False, 'spell': 'arrow shield'}, |
50 | 'Binding Wave': {'type': 'Enfeebling', 'shadows': 'ignore', 'range': 15, 'aoe': True, 'spell': 'bind'}, | 66 | 'Binding Wave': {'type': 'Enfeebling', 'shadows': 'ignore', 'range': 15, 'aoe': True, 'spell': 'bind'}, |
51 | 'Dire Straight': {'type': 'Physical', 'shadows': 'wipe', 'range': None, 'aoe': False}, | 67 | 'Dire Straight': {'type': 'Physical', 'shadows': 'wipe', 'range': None, 'aoe': False}, |
52 | 'Dismemberment': {'type': 'Piercing', 'shadows': 'absorb', 'range': None, 'aoe': False}, # causes the monster to lose a body part | 68 | 'Dismemberment': {'type': 'Piercing', 'shadows': 'absorb', 'range': None, 'aoe': False}, # causes the monster to lose a body part |
... | @@ -61,36 +77,74 @@ Families = { | ... | @@ -61,36 +77,74 @@ Families = { |
61 | 'base_fp': 50, | 77 | 'base_fp': 50, |
62 | 'fp_per_level': 0.1, | 78 | 'fp_per_level': 0.1, |
63 | 'max_fp': 55, | 79 | 'max_fp': 55, |
64 | 'main_job': Jobs.WAR, | 80 | 'available_main_job': [Jobs.WAR, Jobs.DRG, Jobs.DRK, Jobs.PLD], |
65 | 'support_job': None, | 81 | 'available_support_job': [Jobs.WAR, Jobs.DRG, Jobs.DRK, Jobs.PLD], |
66 | 'innate_feral_skills': ['Sinker Drill', 'Dire Straight', 'Dismemberment', 'Earthshatter'], | 82 | 'innate_feral_skills': ['Sinker Drill', 'Dire Straight', 'Dismemberment', 'Earthshatter'], |
67 | 'type': 'Arcana', | 83 | 'type': 'Arcana', |
68 | 'strong_vs': ['Dark'], | 84 | 'strong_vs': ['Dark'], |
69 | 'charmable': False, | 85 | 'charmable': False, |
70 | 'aspir': False, | 86 | 'aspir': False, |
71 | 'drain': False | 87 | 'drain': False, |
88 | 'temperament_attitude': { | ||
89 | 'initial_value': 4, | ||
90 | 'actions': { | ||
91 | 4: {'use_tp_chance': 100, 'ws': ['Sinker Drill'], 'side_attack_chance': 0, 'range_chance': 0}, | ||
92 | 3: {'use_tp_chance': 75, 'ws': ['Eyes On Me'], 'side_attack_chance': 70, 'range_chance': 10}, | ||
93 | 2: {'use_tp_chance': 50, 'ws': ['Binding Wave', 'Hypnosis'], 'side_attack_chance': 25, 'range_chance': 70}, | ||
94 | 1: {'use_tp_chance': 70, 'ws': ['Binding Wave', 'Hypnosis', 'Magic Barrier', 'Airy Shield'], 'side_attack_chance': 25, 'range_chance': 70} | ||
95 | } | ||
96 | }, | ||
97 | 'temperament_posture': { | ||
98 | 'initial_value': 4, | ||
99 | 'actions': { | ||
100 | 4: {'use_tp_chance': 100, 'ws': ['Eyes On Me'], 'side_attack_chance': 0, 'range_chance': 0}, | ||
101 | 3: {'use_tp_chance': 75, 'ws': ['Eyes On Me'], 'side_attack_chance': 70, 'range_chance': 10}, | ||
102 | 2: {'use_tp_chance': 50, 'ws': ['Binding Wave', 'Hypnosis'], 'side_attack_chance': 25, 'range_chance': 70}, | ||
103 | 1: {'use_tp_chance': 70, 'ws': ['Magic Barrier', 'Airy Shield'], 'side_attack_chance': 25, 'range_chance': 100} | ||
104 | } | ||
105 | } | ||
72 | }, | 106 | }, |
73 | 'ahriman': { | 107 | 'ahriman': { |
74 | 'base_fp': 65, | 108 | 'base_fp': 65, |
75 | 'fp_per_level': 0.3, | 109 | 'fp_per_level': 0.3, |
76 | 'max_fp': 80, | 110 | 'max_fp': 80, |
77 | 'main_job': Jobs.WAR, | 111 | 'available_main_job': [Jobs.BLM, Jobs.RDM, Jobs.WAR], |
78 | 'support_job': Jobs.BLM, | 112 | 'available_support_job': [Jobs.BLM, Jobs.RDM, Jobs.WAR], |
79 | 'innate_feral_skills': ['Binding Wave', 'Magic Barrier', 'Hypnosis', 'Eyes On Me', 'Airy Shield'], | 113 | 'innate_feral_skills': ['Binding Wave', 'Magic Barrier', 'Hypnosis', 'Eyes On Me', 'Airy Shield'], |
80 | 'type': 'Demon', | 114 | 'type': 'Demon', |
81 | 'traits': ['magic defence bonus +25%'], | 115 | 'traits': ['magic defence bonus +25%'], |
82 | 'charmable': False, | 116 | 'charmable': False, |
83 | 'aspir': True, | 117 | 'aspir': True, |
84 | 'drain': True | 118 | 'drain': True, |
119 | 'temperament_attitude': { | ||
120 | 'initial_value': 4, | ||
121 | 'actions': { | ||
122 | 4: {'use_tp_chance': 100, 'ws': ['Eyes On Me'], 'side_attack_chance': 0, 'range_chance': 0}, | ||
123 | 3: {'use_tp_chance': 75, 'ws': ['Eyes On Me'], 'side_attack_chance': 70, 'range_chance': 10}, | ||
124 | 2: {'use_tp_chance': 50, 'ws': ['Binding Wave', 'Hypnosis'], 'side_attack_chance': 25, 'range_chance': 70}, | ||
125 | 1: {'use_tp_chance': 70, 'ws': ['Binding Wave', 'Hypnosis', 'Magic Barrier', 'Airy Shield'], 'side_attack_chance': 25, 'range_chance': 70} | ||
126 | } | ||
127 | }, | ||
128 | 'temperament_posture': { | ||
129 | 'initial_value': 4, | ||
130 | 'actions': { | ||
131 | 4: {'use_tp_chance': 100, 'ws': ['Eyes On Me'], 'side_attack_chance': 0, 'range_chance': 0}, | ||
132 | 3: {'use_tp_chance': 75, 'ws': ['Eyes On Me'], 'side_attack_chance': 70, 'range_chance': 10}, | ||
133 | 2: {'use_tp_chance': 50, 'ws': ['Binding Wave', 'Hypnosis'], 'side_attack_chance': 25, 'range_chance': 70}, | ||
134 | 1: {'use_tp_chance': 70, 'ws': ['Magic Barrier', 'Airy Shield'], 'side_attack_chance': 25, 'range_chance': 100} | ||
135 | } | ||
136 | } | ||
85 | } | 137 | } |
86 | } | 138 | } |
87 | 139 | ||
88 | Monsters = { | 140 | Monsters = { |
89 | 'Mechanical Menace': { | 141 | 'Mechanical Menace': { |
142 | 'initial_level': 9, | ||
90 | 'family': 'acrolith', | 143 | 'family': 'acrolith', |
91 | 'zone': 'Abyssea - Uleguerand' | 144 | 'zone': 'Abyssea - Uleguerand' |
92 | }, | 145 | }, |
93 | 'Floating Eye': { | 146 | 'Floating Eye': { |
147 | 'initial_level': 3, | ||
94 | 'family': 'ahriman', | 148 | 'family': 'ahriman', |
95 | 'zone': 'Ranguemont Pass' | 149 | 'zone': 'Ranguemont Pass' |
96 | } | 150 | } |
... | @@ -120,8 +174,27 @@ class Pankration: | ... | @@ -120,8 +174,27 @@ class Pankration: |
120 | 174 | ||
121 | def hunt_monster(self, zone): | 175 | def hunt_monster(self, zone): |
122 | if random.randint(1, 100) < FIND_PERCENTAGE: | 176 | if random.randint(1, 100) < FIND_PERCENTAGE: |
177 | monster_data = Monsters[random.choice(self.get_monsters(zone))] | ||
178 | print(monster_data) | ||
179 | family_name = monster_data['family'] | ||
180 | level = monster_data['initial_level'] | ||
181 | family = Families[family_name] | ||
182 | main_job = random.choice(family['available_main_job']) | ||
183 | support_job = random.choice(family['available_support_job']) | ||
184 | feral_skills = [] | ||
185 | skills = random.sample(family['innate_feral_skills'], 3) | ||
186 | if random.randint(1, 100) < SKILL_PERCENT: | ||
187 | feral_skills.append(skills[0]) | ||
188 | if random.randint(1, 100) < SKILL_PERCENT: | ||
189 | feral_skills.append(skills[1]) | ||
190 | if random.randint(1, 100) < SKILL_PERCENT: | ||
191 | feral_skills.append(skills[2]) | ||
192 | dicipline_level = 1 | ||
193 | |||
194 | monster = Monster(family, level, main_job, support_job, feral_skills, | ||
195 | [], dicipline_level) | ||
123 | return HuntResponse(HuntResponse.SUCCESS, "You captured the monster!", | 196 | return HuntResponse(HuntResponse.SUCCESS, "You captured the monster!", |
124 | random.choice(self.get_monsters(zone))) | 197 | monster) |
125 | else: | 198 | else: |
126 | return HuntResponse(HuntResponse.FAILURE, "You were unable to capture a monster's soul.", | 199 | return HuntResponse(HuntResponse.FAILURE, "You were unable to capture a monster's soul.", |
127 | None) | 200 | None) |
... | @@ -130,26 +203,77 @@ class Pankration: | ... | @@ -130,26 +203,77 @@ class Pankration: |
130 | return "" | 203 | return "" |
131 | 204 | ||
132 | class Monster: | 205 | class Monster: |
133 | def __init__(self, family, level, main_job, support_job, fp_capacity, innate_feral_skills, | 206 | def __init__(self, family, level, main_job, support_job, innate_feral_skills, |
134 | eqipped_feral_skills, dicipline_level, temperament): | 207 | equipped_feral_skills, dicipline_level): |
135 | self.family = family | 208 | self.family = family |
136 | self.level = level | 209 | self.level = level |
137 | self.main_job = main_job | 210 | self.main_job = main_job |
138 | self.support_job = support_job | 211 | self.support_job = support_job |
139 | self.fp_capacity = fp_capacity | ||
140 | self.innate_feral_skills = innate_feral_skills | 212 | self.innate_feral_skills = innate_feral_skills |
141 | self.equipped_feral_skills = eqipped_feral_skills | 213 | self.equipped_feral_skills = equipped_feral_skills |
142 | self.discipline_level = dicipline_level | 214 | self.discipline_level = dicipline_level |
143 | self.temperament = temperament | 215 | self.temperament_posture = family['temperament_posture']['initial_value'] |
144 | 216 | self.temperament_attitude = family['temperament_attitude']['initial_value'] | |
145 | def calculate_fp_gain(self): | 217 | self.pre_fight_command = {"temperament_posture": None, "temperament_attitude": None} |
218 | self.exp = exp_to_level[level] + 1 | ||
219 | |||
220 | def __str__(self): | ||
221 | return "Family: {}\nLevel: {}\nMain Job: {}\nSupport Job: {}\nInnate Feral Skills: {}\nEquipped Feral Skills: {}\nDicipline Level: {}\nTemperament...".format(self.family, self.level, self.main_job, self.support_job, self.innate_feral_skills, self.equipped_feral_skills, self.discipline_level) | ||
222 | |||
223 | def get_fp(self): | ||
224 | return int(self.level / self.family['fp_per_level']) | ||
225 | |||
226 | def add_xp(self, exp_to_add): | ||
227 | self.exp += exp_to_add | ||
228 | for i in range(self.level, 50): | ||
229 | if self.exp > exp_to_level[i]: | ||
230 | if i > self.level: | ||
231 | # We leveled up! | ||
232 | print("Start level: {} New Level: {}".format(self.level, i)) | ||
233 | else: | ||
234 | print("Just another brick in the wall...") | ||
235 | else: | ||
236 | break | ||
237 | # calc level based on xp | ||
238 | # stop at 50 | ||
146 | pass | 239 | pass |
147 | 240 | ||
148 | def set_strategy(self, strategy_type): | 241 | def get_current_posture(self): |
149 | if strategy_type not in self.monster_data['strategies']: | 242 | return TemperamentPosture(self.temperament_posture) |
150 | return False | 243 | |
244 | def get_current_attitude(self): | ||
245 | return TemperamentAttitude(self.temperament_attitude) | ||
246 | |||
247 | def get_dicipline_level(self): | ||
248 | if self.dicipline_level < 2: | ||
249 | return "Defiant" | ||
250 | elif self.dicipline_level < 5: | ||
251 | return "Disrespectful" | ||
252 | elif self.dicipline_level < 7: | ||
253 | return "Disobedient" | ||
254 | else: | ||
255 | return "Obedient" | ||
256 | |||
257 | # This should ONLY be executed at the start of battle. | ||
258 | def set_strategy(self, temperament_posture, temperament_attitude): | ||
259 | distance_from_nature = abs(self.temperament_posture - temperament_posture) | ||
260 | distance_from_nature += abs(self.temperament_attitude - temperament_attitude) | ||
261 | |||
262 | if distance_from_nature == 0: | ||
263 | chance_of_listening = self.discipline_level | ||
264 | else: | ||
265 | chance_of_listening = float(float(self.discipline_level) / (float(distance_from_nature)/10)) | ||
266 | |||
267 | chance_of_listening = abs(float((float(chance_of_listening)-1)/(20-1))) | ||
268 | |||
269 | if random.randint(1, 100) > chance_of_listening * 100: | ||
270 | print("DO ACTION:") | ||
271 | # adjust dicipline_level | ||
272 | # move temperament | ||
151 | else: | 273 | else: |
152 | self.strategy = strategy_type | 274 | #continue action |
275 | #if severe request then reduce dicipline_level | ||
276 | pass | ||
153 | 277 | ||
154 | class Battle: | 278 | class Battle: |
155 | pass | 279 | pass |
... | @@ -169,8 +293,12 @@ print(str(hunt_response.result)) | ... | @@ -169,8 +293,12 @@ print(str(hunt_response.result)) |
169 | time.sleep(0.5) | 293 | time.sleep(0.5) |
170 | if hunt_response.result == HuntResponse.SUCCESS: | 294 | if hunt_response.result == HuntResponse.SUCCESS: |
171 | print(hunt_response.message) | 295 | print(hunt_response.message) |
172 | monster = Monsters[hunt_response.monster] | 296 | monster = hunt_response.monster |
173 | print("The Soul Plate Shows: \n\n{}\n{}{}".format(hunt_response.monster)) | 297 | print("The Soul Plate Shows: \n\n{}".format(monster)) |
298 | print(monster.set_strategy(4, 3)) | ||
299 | print(monster.set_strategy(1, 1)) | ||
300 | print(monster.set_strategy(1, 2)) | ||
301 | monster.add_xp(2900) | ||
174 | else: | 302 | else: |
175 | print(hunt_response.message) | 303 | print(hunt_response.message) |
176 | 304 | ... | ... |
-
Please register or sign in to post a comment