def do_heist(self, ctx) -> dict:
"""Actually does the heist.
Returns
-------
dict
With data about if the heist was successful and the amount stolen,
or which members went to jail if it was unsuccessful.
"""
await self.finish.wait()
log.info('Doing the heist')
res = {
'success': False,
'jailed': [],
'saved': [],
}
bot = ctx.bot
jcoin = bot.get_cog('Coins')
if not jcoin:
raise SayException('coins cog not loaded')
target_account = await jcoin.get_account(self.target.id)
if target_account is None:
raise SayException('Guild not found')
if target_account['type'] != 'taxbank':
raise SayException('Account is not a taxbank')
amnt = target_account['amount']
increase_people = len(self.users) * INCREASE_PER_PERSON
chance = BASE_HEIST_CHANCE + ((amnt / self.amount) + increase_people) * HEIST_CONSTANT
# trim it to 60% success
if chance > 6:
chance = 6
result = random.uniform(0, 10)
res['chance'] = chance
res['result'] = result
if result < chance:
res['success'] = True
else:
res['success'] = False
# 50% chance of every person
# in the heist to go to jail
for user_id in self.users:
if random.random() < 0.5:
res['jailed'].append(user_id)
else:
res['saved'].append(user_id)
return res
评论列表
文章目录