restore slot gambling in comments

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-30 02:36:23 +02:00
parent 85abc39632
commit f09ec0ca17
4 changed files with 40 additions and 0 deletions

View File

@ -64,6 +64,8 @@ class Comment(Base):
ban_reason = Column(String)
wordle_result = Column(String)
treasure_amount = Column(String)
slots_result = Column(String)
casino_game_id = Column(Integer, ForeignKey("casino_games.id"))
oauth_app = relationship("OauthApp")
post = relationship("Submission", back_populates="comments")
@ -73,6 +75,7 @@ class Comment(Base):
awards = relationship("AwardRelationship", order_by="AwardRelationship.awarded_utc.desc()", back_populates="comment")
flags = relationship("CommentFlag", order_by="CommentFlag.created_utc")
options = relationship("CommentOption", order_by="CommentOption.id")
casino_game = relationship("Casino_Game")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs:

View File

@ -45,6 +45,7 @@ def casino_slot_pull(gambler, wager_value, currency):
casino_game.kind = 'slots'
casino_game.game_state = json.dumps(game_state)
g.db.add(casino_game)
g.db.flush()
return casino_game.id, casino_game.game_state
else:

View File

@ -368,6 +368,35 @@ def comment(v):
parent_post.comment_count += 1
g.db.add(parent_post)
if FEATURES['GAMBLING'] and '!slots' in c.body:
if v.rehab:
abort(403, "You are under Rehab award effect!")
if '!slotsmb' in c.body:
command_word = '!slotsmb'
currency = 'procoins'
else:
command_word = '!slots'
currency = 'coins'
wager = c.body.split(command_word)[1].split()[0]
try:
wager = int(wager)
except:
abort(400, "Invalid wager.")
if wager < 100:
abort(400, f"Wager must be 100 {currency} or more")
if (currency == "coins" and wager > v.coins) or (currency == "procoins" and wager > v.procoins):
abort(400, f"Not enough {currency} to make that bet")
game_id, game_state = casino_slot_pull(v, wager, currency)
c.casino_game_id = game_id
g.db.flush()
if v.client: return c.json

View File

@ -202,6 +202,13 @@
{% endif %}
{% endif %}
{% if c.slots_result %}
<em style="position: relative; top: 2px; margin-left: 0.5rem">{{c.slots_result}}</em>
{% elif c.casino_game_id %}
{% set game_state = c.casino_game.game_state_json %}
<em style="position: relative; top: 2px; margin-left: 0.5rem">{{game_state['symbols'].replace(',','')}} {{game_state['text']}}</em>
{% endif %}
{% if c.wordle_result %}
{{c.wordle_html(v) | safe}}
{% endif %}