2deabd3e by Barry

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

1 parent 9968068c
......@@ -104,15 +104,15 @@ class Blackjack:
def is_win(self):
if self.player_hand.is_blackjack() and not self.dealer_hand.is_blackjack():
return (int(self.bet + self.bet * 1.5), 'Blackjack! You win: {}')
elif self.player_points > 21:
return (0, 'You Bust. Total Winnings: {}')
# Resolve blackjack before dealer draws.
self.dealer_draw()
self.dealer_points = self.dealer_hand.get_points()
self.player_points = self.player_hand.get_points()
# TODO: Check for blackjack Ace + 10 pt
if self.player_points > 21:
return (0, 'You Bust. Total Winnings: {}')
elif self.dealer_points > 21:
if self.dealer_points > 21:
return (int(self.bet * 2), 'Dealer Busts. Total Winnings {}')
elif self.dealer_hand.is_blackjack():
return (0, 'You lose. Total Winnings: {}')
......
No preview for this file type
......@@ -288,7 +288,7 @@ def db_get_all_members():
member_conn = sqlite3.connect('db.sqlite3')
c = member_conn.cursor()
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()
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()
member_conn.close()
members_list = []
for member in results:
......@@ -302,9 +302,9 @@ def db_get_member(discord_id=None, username=None):
c = member_conn.cursor()
result = None
if discord_id:
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()
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()
if username:
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()
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()
member_conn.close()
return dict_factory(c, result)
......@@ -490,6 +490,7 @@ Minigames:
!buyticket - Purchases a raffle ticket for 100 credits
!raffle - Shows information about the current raffle
!ticketrank - Shows the percentage of the tickets on the system
Spam:
!youtube <search term> - Returns the first video from the search results for the search term.
!gif <search term> - Returns the first gif from the search results.
......@@ -672,6 +673,27 @@ Stuff:
client.send_message(message.channel, "{} has been given {} credits.".format(member['member_name'], 100))
return
if message.content.startswith('!ticketrank'):
# if message.author.id != '78767557628133376':
# client.send_message(message.channel, "You are not Hellsbreath. Use !gimmecredits to get a few extra if you run out.")
# return
members = db_get_all_members()
if len(members) < 0:
client.send_message(message.channel, "There was a problem looking up your information.")
else:
ticket_count = 0
for member in members:
log(member)
ticket_count += member['tickets']
log("Ticket Count: {}".format(ticket_count))
out_string = ""
for member in members:
if member['tickets'] > 0:
percent = (float(member['tickets']) / float(ticket_count)) * 100.0
out_string += "{} - {}%\n".format(member['member_name'], int(percent))
client.send_message(message.channel, out_string)
return
if message.content.startswith('!raffle'):
client.send_message(message.channel, """Current Raffle Item:
......