restore slot gambling in comments
parent
85abc39632
commit
f09ec0ca17
|
@ -64,6 +64,8 @@ class Comment(Base):
|
||||||
ban_reason = Column(String)
|
ban_reason = Column(String)
|
||||||
wordle_result = Column(String)
|
wordle_result = Column(String)
|
||||||
treasure_amount = Column(String)
|
treasure_amount = Column(String)
|
||||||
|
slots_result = Column(String)
|
||||||
|
casino_game_id = Column(Integer, ForeignKey("casino_games.id"))
|
||||||
|
|
||||||
oauth_app = relationship("OauthApp")
|
oauth_app = relationship("OauthApp")
|
||||||
post = relationship("Submission", back_populates="comments")
|
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")
|
awards = relationship("AwardRelationship", order_by="AwardRelationship.awarded_utc.desc()", back_populates="comment")
|
||||||
flags = relationship("CommentFlag", order_by="CommentFlag.created_utc")
|
flags = relationship("CommentFlag", order_by="CommentFlag.created_utc")
|
||||||
options = relationship("CommentOption", order_by="CommentOption.id")
|
options = relationship("CommentOption", order_by="CommentOption.id")
|
||||||
|
casino_game = relationship("Casino_Game")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs:
|
if "created_utc" not in kwargs:
|
||||||
|
|
|
@ -45,6 +45,7 @@ def casino_slot_pull(gambler, wager_value, currency):
|
||||||
casino_game.kind = 'slots'
|
casino_game.kind = 'slots'
|
||||||
casino_game.game_state = json.dumps(game_state)
|
casino_game.game_state = json.dumps(game_state)
|
||||||
g.db.add(casino_game)
|
g.db.add(casino_game)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
return casino_game.id, casino_game.game_state
|
return casino_game.id, casino_game.game_state
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -368,6 +368,35 @@ def comment(v):
|
||||||
parent_post.comment_count += 1
|
parent_post.comment_count += 1
|
||||||
g.db.add(parent_post)
|
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()
|
g.db.flush()
|
||||||
|
|
||||||
if v.client: return c.json
|
if v.client: return c.json
|
||||||
|
|
|
@ -202,6 +202,13 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% 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 %}
|
{% if c.wordle_result %}
|
||||||
{{c.wordle_html(v) | safe}}
|
{{c.wordle_html(v) | safe}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue