2022-05-30 02:59:22 +00:00
|
|
|
from random import randint
|
|
|
|
from math import floor
|
|
|
|
from files.helpers.const import *
|
|
|
|
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
|
|
|
|
|
|
|
def check_for_treasure(in_text, from_comment):
|
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
|
|
|
|
2022-09-04 20:53:34 +00:00
|
|
|
if '!wordle' not in in_text:
|
2022-05-30 02:59:22 +00:00
|
|
|
seed = randint(1, 1000)
|
2022-02-14 20:29:36 +00:00
|
|
|
is_special = seed == 1000
|
|
|
|
is_standard = seed >= 990
|
|
|
|
amount = 0
|
|
|
|
|
|
|
|
if is_special:
|
2022-05-30 02:59:22 +00:00
|
|
|
amount = randint(special_min, special_max)
|
2022-02-14 20:29:36 +00:00
|
|
|
elif is_standard:
|
2022-05-30 02:59:22 +00:00
|
|
|
amount = randint(standard_min, standard_max)
|
|
|
|
if randint(1, 100) > 90:
|
2022-04-03 15:34:21 +00:00
|
|
|
if amount > user.coins: amount = user.coins
|
|
|
|
amount = -amount
|
|
|
|
|
2022-02-14 20:29:36 +00:00
|
|
|
|
|
|
|
if amount != 0:
|
2022-05-30 02:59:22 +00:00
|
|
|
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.coins += amount
|
2022-09-29 05:43:29 +00:00
|
|
|
from_comment.treasure_amount = str(amount)
|