示例#1
0
 async def _run(self):
     database.set_settings_candy_chance(self.message.guild.id,
                                        self.candy.id, self.amount)
     candy = database.get_candy(self.message.guild.id)
     new_chance = utils.chance_value_to_percent(candy)[self.candy]
     await self.send(
         f"{self.candy} chance has been changed to {new_chance:.2f}%")
示例#2
0
文件: chance.py 项目: axc450/candybot
 async def _run(self):
     candy = self.args["candy"]
     amount = self.args["amount"]
     database.set_settings_candy_chance(self.server.id, candy.id, amount)
     candy = database.get_candy(self.server.id)
     new_chance = utils.chance_value_to_percent(candy)[candy]
     await self.send(f"{candy} chance has been changed to {new_chance:.2f}%"
                     )
示例#3
0
 async def _run(self):
     candy = database.get_candy(self.message.guild.id)
     candy_chance = utils.chance_value_to_percent(candy)
     lines = [f"{x.emoji} {x.name} {candy_chance[x]:.2f}%" for x in candy]
     await self.send("\n".join(lines))
示例#4
0
 def test_chance_value_to_percent(self):
     test_input = [Mock(chance=2), Mock(chance=3), Mock(chance=5)]
     expected = {test_input[0]: 20, test_input[1]: 30, test_input[2]: 50}
     self.assertEqual(utils.chance_value_to_percent(test_input), expected)
示例#5
0
 def test_chance_value_to_percent_empty(self):
     test_input = []
     expected = {}
     self.assertEqual(utils.chance_value_to_percent(test_input), expected)
示例#6
0
 def test_chance_value_to_percent_all_zero(self):
     test_input = [Mock(chance=0), Mock(chance=0), Mock(chance=0)]
     expected = {test_input[0]: 0, test_input[1]: 0, test_input[2]: 0}
     self.assertEqual(utils.chance_value_to_percent(test_input), expected)