2022-05-30 02:59:22 +00:00
|
|
|
from math import floor
|
2022-11-15 09:19:08 +00:00
|
|
|
from random import randint
|
|
|
|
|
2022-12-11 23:44:34 +00:00
|
|
|
from files.helpers.config.const import *
|
2022-05-30 02:59:22 +00:00
|
|
|
from files.helpers.lottery import *
|
2022-02-14 20:29:36 +00:00
|
|
|
|
|
|
|
special_min = 100
|
2022-03-17 08:59:44 +00:00
|
|
|
special_max = 200
|
2022-06-01 00:23:19 +00:00
|
|
|
standard_min = 12
|
2022-02-14 20:29:36 +00:00
|
|
|
standard_max = 100
|
2022-05-30 02:59:22 +00:00
|
|
|
lotterizer_rate = 33
|
2022-02-14 20:29:36 +00:00
|
|
|
|
2022-12-09 05:55:18 +00:00
|
|
|
def check_for_treasure(from_comment, in_text):
|
2022-05-30 09:32:45 +00:00
|
|
|
user = from_comment.author
|
|
|
|
|
2022-08-26 21:00:17 +00:00
|
|
|
if not FEATURES['GAMBLING']: return
|
2022-05-30 09:32:45 +00:00
|
|
|
|
2023-04-29 21:27:45 +00:00
|
|
|
seed = randint(1, 1000)
|
|
|
|
is_special = seed == 1000
|
|
|
|
is_standard = seed >= 990
|
|
|
|
amount = 0
|
|
|
|
|
|
|
|
if is_special:
|
|
|
|
amount = randint(special_min, special_max)
|
|
|
|
elif is_standard:
|
|
|
|
amount = randint(standard_min, standard_max)
|
|
|
|
if randint(1, 100) > 90:
|
|
|
|
amount = -amount
|
|
|
|
|
|
|
|
|
|
|
|
if amount != 0:
|
|
|
|
if amount > 0:
|
|
|
|
active_lottery = get_active_lottery()
|
|
|
|
lottery_tickets_seed = randint(1, 100)
|
|
|
|
lottery_tickets_instead = lottery_tickets_seed <= lotterizer_rate
|
|
|
|
|
|
|
|
if active_lottery and lottery_tickets_instead:
|
|
|
|
ticket_count = floor(amount / LOTTERY_TICKET_COST)
|
|
|
|
grant_lottery_tickets_to_user(user, ticket_count)
|
|
|
|
from_comment.treasure_amount = f'l{ticket_count}'
|
|
|
|
return
|
|
|
|
|
|
|
|
user.pay_account('coins', amount)
|
|
|
|
from_comment.treasure_amount = str(amount)
|