2021-11-23 21:44:59 +08:00
|
|
|
import random
|
2023-02-18 18:46:54 +08:00
|
|
|
from typing import Tuple, Union
|
2021-11-23 21:44:59 +08:00
|
|
|
|
2023-02-18 18:46:54 +08:00
|
|
|
from configs.config import Config
|
2021-11-23 21:44:59 +08:00
|
|
|
|
|
|
|
|
PROB_DATA = None
|
|
|
|
|
|
|
|
|
|
|
2023-02-18 18:46:54 +08:00
|
|
|
def random_event(impression: float) -> Tuple[Union[str, int], str]:
|
2021-11-23 21:44:59 +08:00
|
|
|
"""
|
|
|
|
|
签到随机事件
|
|
|
|
|
:param impression: 好感度
|
|
|
|
|
:return: 额外奖励 和 类型
|
|
|
|
|
"""
|
|
|
|
|
global PROB_DATA
|
|
|
|
|
if not PROB_DATA:
|
|
|
|
|
PROB_DATA = {
|
2023-02-18 18:46:54 +08:00
|
|
|
Config.get_config("sign_in", "SIGN_CARD3_PROB"): "好感度双倍加持卡Ⅲ",
|
|
|
|
|
Config.get_config("sign_in", "SIGN_CARD2_PROB"): "好感度双倍加持卡Ⅱ",
|
|
|
|
|
Config.get_config("sign_in", "SIGN_CARD1_PROB"): "好感度双倍加持卡Ⅰ",
|
2021-11-23 21:44:59 +08:00
|
|
|
}
|
|
|
|
|
rand = random.random() - impression / 1000
|
|
|
|
|
for prob in PROB_DATA.keys():
|
|
|
|
|
if rand <= prob:
|
2023-02-18 18:46:54 +08:00
|
|
|
return PROB_DATA[prob], "props"
|
|
|
|
|
gold = random.randint(
|
|
|
|
|
1, random.randint(1, int(1 if impression < 1 else impression))
|
|
|
|
|
)
|
2021-11-23 21:44:59 +08:00
|
|
|
max_sign_gold = Config.get_config("sign_in", "MAX_SIGN_GOLD")
|
|
|
|
|
gold = max_sign_gold if gold > max_sign_gold else gold
|
2023-02-18 18:46:54 +08:00
|
|
|
return gold, "gold"
|