df
This commit is contained in:
parent
823160ebff
commit
0d14e7a88a
2 changed files with 32 additions and 48 deletions
|
@ -25,55 +25,51 @@ class Slots:
|
|||
for word in in_text.split():
|
||||
if self.command_word in word:
|
||||
try:
|
||||
wager = word[len(self.casino_word):]
|
||||
wager_value = int(wager, base=10)
|
||||
wager = word[len(self.command_word):]
|
||||
wager_value = int(wager)
|
||||
except: break
|
||||
|
||||
if (wager_value < self.minimum_bet): wager_is_valid = False
|
||||
elif (wager_value > self.maximum_bet): wager_is_valid = False
|
||||
elif (wager_value > from_user.coins): wager_is_valid = False
|
||||
else: wager_is_valid = True
|
||||
if (wager_value < self.minimum_bet): break
|
||||
elif (wager_value > self.maximum_bet): break
|
||||
elif (wager_value > from_user.coins): break
|
||||
|
||||
if wager_is_valid:
|
||||
from_user.coins -= wager_value
|
||||
from_user.coins -= wager_value
|
||||
|
||||
payout = self.determine_payout()
|
||||
symbols = self.build_symbols(payout)
|
||||
text = self.build_text(wager_value, payout, from_user, "Coins")
|
||||
reward = wager_value * payout
|
||||
payout = self.determine_payout()
|
||||
symbols = self.build_symbols(payout)
|
||||
text = self.build_text(wager_value, payout, from_user, "Coins")
|
||||
reward = wager_value * payout
|
||||
|
||||
from_user.coins += reward
|
||||
self.db.add(from_user)
|
||||
from_user.coins += reward
|
||||
self.db.add(from_user)
|
||||
|
||||
from_comment.slots_result = f'{symbols} {text}'
|
||||
self.db.add(from_comment)
|
||||
from_comment.slots_result = f'{symbols} {text}'
|
||||
self.db.add(from_comment)
|
||||
|
||||
if self.casino_word in in_text:
|
||||
for word in in_text.split():
|
||||
if self.casino_word in word:
|
||||
try:
|
||||
wager = word[len(self.casino_word):]
|
||||
wager_value = int(wager, base=10)
|
||||
wager_value = int(wager)
|
||||
except: break
|
||||
|
||||
if (wager_value < self.minimum_bet): wager_is_valid = False
|
||||
elif (wager_value > self.maximum_bet): wager_is_valid = False
|
||||
elif (wager_value > from_user.procoins): wager_is_valid = False
|
||||
else: wager_is_valid = True
|
||||
if (wager_value < self.minimum_bet): break
|
||||
elif (wager_value > self.maximum_bet): break
|
||||
elif (wager_value > from_user.procoins): break
|
||||
|
||||
if wager_is_valid:
|
||||
from_user.procoins -= wager_value
|
||||
from_user.procoins -= wager_value
|
||||
|
||||
payout = self.determine_payout()
|
||||
symbols = self.build_symbols(payout)
|
||||
text = self.build_text(wager_value, payout, from_user, "Marseybux")
|
||||
reward = wager_value * payout
|
||||
payout = self.determine_payout()
|
||||
symbols = self.build_symbols(payout)
|
||||
text = self.build_text(wager_value, payout, from_user, "Marseybux")
|
||||
reward = wager_value * payout
|
||||
|
||||
from_user.procoins += reward
|
||||
self.db.add(from_user)
|
||||
from_user.procoins += reward
|
||||
self.db.add(from_user)
|
||||
|
||||
from_comment.slots_result = f'{symbols} {text}'
|
||||
self.db.add(from_comment)
|
||||
from_comment.slots_result = f'{symbols} {text}'
|
||||
self.db.add(from_comment)
|
||||
|
||||
|
||||
def determine_payout(self):
|
||||
|
@ -94,22 +90,9 @@ class Slots:
|
|||
|
||||
shuffle(all_symbols)
|
||||
|
||||
if for_payout == 0:
|
||||
return "".join([all_symbols[0], all_symbols[1], all_symbols[2]])
|
||||
elif for_payout == 1:
|
||||
indices = shuffle([0, 1, 2])
|
||||
symbol_set = ["", "", ""]
|
||||
[match_a, match_b, nonmatch] = indices
|
||||
[matching_symbol, other_symbol] = all_symbols
|
||||
symbol_set[match_a] = matching_symbol
|
||||
symbol_set[match_b] = matching_symbol
|
||||
symbol_set[nonmatch] = other_symbol
|
||||
|
||||
return "".join(symbol_set)
|
||||
else:
|
||||
relevantSymbols = shuffle(self.payout_to_symbols[for_payout])
|
||||
symbol = relevantSymbols[0]
|
||||
return "".join([symbol, symbol, symbol])
|
||||
if for_payout == 0: return "".join([all_symbols[0], all_symbols[1], all_symbols[2]])
|
||||
elif for_payout == 1: return "".join([all_symbols[0], all_symbols[0], all_symbols[2]])
|
||||
else: return "".join([all_symbols[0], all_symbols[0], all_symbols[0]])
|
||||
|
||||
def build_text(self, wager_value, result, user, currency):
|
||||
if result == 0:
|
||||
|
|
|
@ -255,7 +255,7 @@ def api_comment(v):
|
|||
if ban.reason: reason += f" {ban.reason}"
|
||||
return {"error": reason}, 401
|
||||
|
||||
if parent_post.id not in (37696,37697,37749,37833,37838):
|
||||
if parent_post.id not in (37696,37697,37749,37833,37838) and not body.startswith('!slots') and not body.startswith('!casino'):
|
||||
existing = g.db.query(Comment.id).filter(Comment.author_id == v.id,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.parent_comment_id == parent_comment_id,
|
||||
|
@ -579,6 +579,7 @@ def api_comment(v):
|
|||
slots = Slots(g)
|
||||
slots.check_for_slots_command(body, v, c)
|
||||
|
||||
print('hey bro', flush=True)
|
||||
g.db.commit()
|
||||
|
||||
if request.headers.get("Authorization"): return c.json
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue