2022-05-30 02:59:22 +00:00
|
|
|
from math import floor
|
2024-02-21 20:08:33 +00:00
|
|
|
import random
|
2022-11-15 09:19:08 +00:00
|
|
|
|
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
|
|
|
|
2024-02-21 20:08:33 +00:00
|
|
|
seed = random.randint(1, 1000)
|
2023-04-29 21:27:45 +00:00
|
|
|
is_special = seed == 1000
|
|
|
|
is_standard = seed >= 990
|
|
|
|
amount = 0
|
|
|
|
|
|
|
|
if is_special:
|
2024-02-21 20:08:33 +00:00
|
|
|
amount = random.randint(special_min, special_max)
|
2023-04-29 21:27:45 +00:00
|
|
|
elif is_standard:
|
2024-02-21 20:08:33 +00:00
|
|
|
amount = random.randint(standard_min, standard_max)
|
|
|
|
if random.randint(1, 100) > 90:
|
2023-04-29 21:27:45 +00:00
|
|
|
amount = -amount
|
|
|
|
|
|
|
|
|
|
|
|
if amount != 0:
|
|
|
|
if amount > 0:
|
|
|
|
active_lottery = get_active_lottery()
|
2024-02-21 20:08:33 +00:00
|
|
|
lottery_tickets_seed = random.randint(1, 100)
|
2023-04-29 21:27:45 +00:00
|
|
|
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
|
|
|
|
|
2024-03-02 17:24:07 +00:00
|
|
|
user.pay_account('coins', amount, f"Found treasure in {from_comment.textlink}")
|
2023-04-29 21:27:45 +00:00
|
|
|
from_comment.treasure_amount = str(amount)
|