mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-06 04:10:02 +08:00
update 0.0.6.0
This commit is contained in:
@@ -1,21 +1,30 @@
|
||||
from configs.config import MAX_SIGN_GOLD
|
||||
from typing import Union
|
||||
from .config import PROB_DATA
|
||||
from configs.config import Config
|
||||
import random
|
||||
|
||||
|
||||
PROB_DATA = None
|
||||
|
||||
|
||||
def random_event(impression: float) -> 'Union[str, int], str':
|
||||
"""
|
||||
签到随机事件
|
||||
:param impression: 好感度
|
||||
:return: 额外奖励 和 类型
|
||||
"""
|
||||
global PROB_DATA
|
||||
if not PROB_DATA:
|
||||
PROB_DATA = {
|
||||
Config.get_config("sign_in", "SIGN_CARD3_PROB"): '好感度双倍加持卡Ⅲ',
|
||||
Config.get_config("sign_in", "SIGN_CARD2_PROB"): '好感度双倍加持卡Ⅱ',
|
||||
Config.get_config("sign_in", "SIGN_CARD1_PROB"): '好感度双倍加持卡Ⅰ'
|
||||
}
|
||||
rand = random.random() - impression / 1000
|
||||
for prob in PROB_DATA.keys():
|
||||
if rand <= prob:
|
||||
return PROB_DATA[prob], 'props'
|
||||
gold = random.randint(1, random.randint(1, int(1 if impression < 1 else impression)))
|
||||
gold = MAX_SIGN_GOLD if gold > MAX_SIGN_GOLD else gold
|
||||
max_sign_gold = Config.get_config("sign_in", "MAX_SIGN_GOLD")
|
||||
gold = max_sign_gold if gold > max_sign_gold else gold
|
||||
return gold, 'gold'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user