change reward mechanism
This commit is contained in:
parent
f580777aec
commit
c2bea64ca6
1 changed files with 22 additions and 10 deletions
32
tgmsbot.py
32
tgmsbot.py
|
@ -199,25 +199,37 @@ def gen_reward(user, negative=True):
|
||||||
# Negative rewards
|
# Negative rewards
|
||||||
def restrict_mining(player):
|
def restrict_mining(player):
|
||||||
if player.immunity_cards >= 1:
|
if player.immunity_cards >= 1:
|
||||||
player.immunity_cards -= 1
|
if player.immunity_cards >= 10:
|
||||||
ret = "用去一张免疫卡,还剩{}张".format(player.immunity_cards)
|
lost_cards = randint(2,4)
|
||||||
|
elif player.immunity_cards >= 5:
|
||||||
|
lost_cards = randint(1,3)
|
||||||
|
else:
|
||||||
|
lost_cards = 1
|
||||||
|
player.immunity_cards -= lost_cards
|
||||||
|
ret = "用去{}张免疫卡,还剩{}张".format(lost_cards, player.immunity_cards)
|
||||||
else:
|
else:
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
seconds = randint(30, 120)
|
seconds = randint(30, 120)
|
||||||
player.restricted_until = now + seconds
|
player.restricted_until = now + seconds
|
||||||
ret = "被限制扫雷{}秒".format(seconds)
|
ret = "没有免疫卡了,被限制扫雷{}秒".format(seconds)
|
||||||
player.save()
|
player.save()
|
||||||
return ret
|
return ret
|
||||||
# Positive rewards
|
# Positive rewards
|
||||||
def give_immunity_cards(player):
|
def give_immunity_cards(player):
|
||||||
if player.immunity_cards >= 3 and choice((True, False)):
|
rewarded_cards = 0
|
||||||
action = "没收"
|
if player.immunity_cards <= 3:
|
||||||
player.immunity_cards -= 1
|
rewarded_cards = randint(1, 2)
|
||||||
else:
|
elif player.immunity_cards <= 10:
|
||||||
action = "奖励"
|
if randint(1, 5) == 5:
|
||||||
player.immunity_cards += 1
|
rewarded_cards = 1
|
||||||
|
elif randint(1, 10) == 10:
|
||||||
|
rewarded_cards = 1
|
||||||
|
player.immunity_cards += rewarded_cards
|
||||||
player.save()
|
player.save()
|
||||||
return "被{}了一张免疫卡,共有{}张".format(action, player.immunity_cards)
|
if rewarded_cards == 0:
|
||||||
|
return "共有{}张免疫卡".format(player.immunity_cards)
|
||||||
|
else:
|
||||||
|
return "被奖励了{}张免疫卡,共有{}张".format(rewarded_cards, player.immunity_cards)
|
||||||
|
|
||||||
player = get_player(user.id)
|
player = get_player(user.id)
|
||||||
if negative:
|
if negative:
|
||||||
|
|
Loading…
Reference in a new issue