You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
"""
随机事件系统
"""
import random
from typing import Optional , Dict
EVENT_TYPES = {
" double_score " : " 双倍加分 " ,
" crazy_thursday " : " 疯狂星期四 " ,
" lucky_star " : " 幸运星 " ,
" normal " : " 普通 "
}
def trigger_random_event ( ) - > Dict [ str , any ] :
"""
触发随机事件
返回事件信息字典:
{
" type " : 事件类型,
" name " : 事件名称,
" multiplier " : 积分倍数,
" description " : 事件描述
}
"""
# 30%概率触发特殊事件
tmp = random . random ( )
print ( " tmp: " , tmp )
if tmp < 1 :
event_type = random . choice ( [ " double_score " , " crazy_thursday " , " lucky_star " ] )
else :
event_type = " normal "
events = {
" double_score " : {
" type " : " double_score " ,
" name " : " 双倍加分 " ,
" multiplier " : 2.0 ,
" description " : " 本次点名积分翻倍! "
} ,
" crazy_thursday " : {
" type " : " crazy_thursday " ,
" name " : " 疯狂星期四 " ,
" multiplier " : 1.5 ,
" description " : " 疯狂星期四! 积分增加50 % ! "
} ,
" lucky_star " : {
" type " : " lucky_star " ,
" name " : " 幸运星 " ,
" multiplier " : 1.2 ,
" description " : " 幸运星降临! 积分增加20 % ! "
} ,
" normal " : {
" type " : " normal " ,
" name " : " 普通 " ,
" multiplier " : 1.0 ,
" description " : " 普通点名 "
}
}
return events [ event_type ]
def should_trigger_crazy_thursday_special ( student_score : float ) - > bool :
"""
疯狂星期四特殊规则: 积分为50的因数的同学被点名几率增加
"""
factors_of_50 = [ 1 , 2 , 5 , 10 , 25 , 50 ]
return student_score in factors_of_50