rDrama/files/classes/treasure.py

35 lines
833 B
Python
Raw Normal View History

import random
class Treasure:
2022-01-29 05:06:08 +00:00
special_min = 100
special_max = 1000
2022-02-05 08:42:54 +00:00
standard_min = 10
2022-01-29 05:06:08 +00:00
standard_max = 100
2022-01-29 05:06:08 +00:00
def __init__(self, g):
self.db = g.db
2022-01-29 05:06:08 +00:00
def check_for_treasure(self, in_text, from_comment):
2022-02-04 15:49:43 +00:00
if '!slots' not in in_text and '!blackjack' not in in_text:
2022-01-29 05:06:08 +00:00
seed = random.randint(1, 1000)
2022-02-04 15:50:36 +00:00
is_special = seed == 1000
is_standard = seed >= 990
2022-01-29 05:06:08 +00:00
amount = 0
2022-01-29 05:06:08 +00:00
if is_special:
amount = random.randint(self.special_min, self.special_max)
elif is_standard:
amount = random.randint(self.standard_min, self.standard_max)
2022-02-04 15:50:21 +00:00
if random.randint(1, 100) > 75: amount = -amount
2022-01-29 05:06:08 +00:00
if amount != 0:
user = from_comment.author
user.coins += amount
2022-02-04 15:50:21 +00:00
if user.coins < 0: user.coins = 0
2022-01-29 05:06:08 +00:00
from_comment.treasure_amount = str(amount)
2022-01-29 05:06:08 +00:00
self.db.add(user)
self.db.add(from_comment)
2022-02-04 15:50:21 +00:00
self.db.commit()