2deabd3e by Barry

Added ticket rank, fixed a bust bug for dealer in blackjack.

1 parent 9968068c
...@@ -104,15 +104,15 @@ class Blackjack: ...@@ -104,15 +104,15 @@ class Blackjack:
104 def is_win(self): 104 def is_win(self):
105 if self.player_hand.is_blackjack() and not self.dealer_hand.is_blackjack(): 105 if self.player_hand.is_blackjack() and not self.dealer_hand.is_blackjack():
106 return (int(self.bet + self.bet * 1.5), 'Blackjack! You win: {}') 106 return (int(self.bet + self.bet * 1.5), 'Blackjack! You win: {}')
107 elif self.player_points > 21:
108 return (0, 'You Bust. Total Winnings: {}')
107 # Resolve blackjack before dealer draws. 109 # Resolve blackjack before dealer draws.
108 self.dealer_draw() 110 self.dealer_draw()
109 self.dealer_points = self.dealer_hand.get_points() 111 self.dealer_points = self.dealer_hand.get_points()
110 self.player_points = self.player_hand.get_points() 112 self.player_points = self.player_hand.get_points()
111 113
112 # TODO: Check for blackjack Ace + 10 pt 114 # TODO: Check for blackjack Ace + 10 pt
113 if self.player_points > 21: 115 if self.dealer_points > 21:
114 return (0, 'You Bust. Total Winnings: {}')
115 elif self.dealer_points > 21:
116 return (int(self.bet * 2), 'Dealer Busts. Total Winnings {}') 116 return (int(self.bet * 2), 'Dealer Busts. Total Winnings {}')
117 elif self.dealer_hand.is_blackjack(): 117 elif self.dealer_hand.is_blackjack():
118 return (0, 'You lose. Total Winnings: {}') 118 return (0, 'You lose. Total Winnings: {}')
......
No preview for this file type
...@@ -288,7 +288,7 @@ def db_get_all_members(): ...@@ -288,7 +288,7 @@ def db_get_all_members():
288 member_conn = sqlite3.connect('db.sqlite3') 288 member_conn = sqlite3.connect('db.sqlite3')
289 289
290 c = member_conn.cursor() 290 c = member_conn.cursor()
291 results = c.execute("SELECT member_id, member_name, discord_id, discord_mention, is_afk, afk_at, status, prev_status, status_change_at, current_game FROM members;").fetchall() 291 results = c.execute("SELECT member_id, member_name, discord_id, discord_mention, is_afk, afk_at, status, prev_status, status_change_at, current_game, credits, tickets FROM members;").fetchall()
292 member_conn.close() 292 member_conn.close()
293 members_list = [] 293 members_list = []
294 for member in results: 294 for member in results:
...@@ -302,9 +302,9 @@ def db_get_member(discord_id=None, username=None): ...@@ -302,9 +302,9 @@ def db_get_member(discord_id=None, username=None):
302 c = member_conn.cursor() 302 c = member_conn.cursor()
303 result = None 303 result = None
304 if discord_id: 304 if discord_id:
305 result = c.execute("SELECT member_id, member_name, discord_id, discord_mention, is_afk, afk_at, status, prev_status, status_change_at, current_game FROM members WHERE discord_id = ?;", (discord_id,)).fetchone() 305 result = c.execute("SELECT member_id, member_name, discord_id, discord_mention, is_afk, afk_at, status, prev_status, status_change_at, current_game, credits, tickets FROM members WHERE discord_id = ?;", (discord_id,)).fetchone()
306 if username: 306 if username:
307 result = c.execute("SELECT member_id, member_name, discord_id, discord_mention, is_afk, afk_at, status, prev_status, status_change_at, current_game FROM members WHERE member_name = ?;", (username,)).fetchone() 307 result = c.execute("SELECT member_id, member_name, discord_id, discord_mention, is_afk, afk_at, status, prev_status, status_change_at, current_game, credits, tickets FROM members WHERE member_name = ?;", (username,)).fetchone()
308 member_conn.close() 308 member_conn.close()
309 return dict_factory(c, result) 309 return dict_factory(c, result)
310 310
...@@ -490,6 +490,7 @@ Minigames: ...@@ -490,6 +490,7 @@ Minigames:
490 490
491 !buyticket - Purchases a raffle ticket for 100 credits 491 !buyticket - Purchases a raffle ticket for 100 credits
492 !raffle - Shows information about the current raffle 492 !raffle - Shows information about the current raffle
493 !ticketrank - Shows the percentage of the tickets on the system
493 Spam: 494 Spam:
494 !youtube <search term> - Returns the first video from the search results for the search term. 495 !youtube <search term> - Returns the first video from the search results for the search term.
495 !gif <search term> - Returns the first gif from the search results. 496 !gif <search term> - Returns the first gif from the search results.
...@@ -672,6 +673,27 @@ Stuff: ...@@ -672,6 +673,27 @@ Stuff:
672 client.send_message(message.channel, "{} has been given {} credits.".format(member['member_name'], 100)) 673 client.send_message(message.channel, "{} has been given {} credits.".format(member['member_name'], 100))
673 return 674 return
674 675
676 if message.content.startswith('!ticketrank'):
677 # if message.author.id != '78767557628133376':
678 # client.send_message(message.channel, "You are not Hellsbreath. Use !gimmecredits to get a few extra if you run out.")
679 # return
680 members = db_get_all_members()
681 if len(members) < 0:
682 client.send_message(message.channel, "There was a problem looking up your information.")
683 else:
684 ticket_count = 0
685 for member in members:
686 log(member)
687 ticket_count += member['tickets']
688 log("Ticket Count: {}".format(ticket_count))
689 out_string = ""
690 for member in members:
691 if member['tickets'] > 0:
692 percent = (float(member['tickets']) / float(ticket_count)) * 100.0
693 out_string += "{} - {}%\n".format(member['member_name'], int(percent))
694 client.send_message(message.channel, out_string)
695 return
696
675 if message.content.startswith('!raffle'): 697 if message.content.startswith('!raffle'):
676 client.send_message(message.channel, """Current Raffle Item: 698 client.send_message(message.channel, """Current Raffle Item:
677 699
......