async def start(self, ctx, minutes_to_start : float = 30):
        game = Game.create(guild_id = ctx.guild.id)

        join_emoji = "⬆️"

        message = await game.log(f"React with an {join_emoji} to join. In {minutes_to_start} minutes the game will start.")
        await message.add_reaction(join_emoji)

        await asyncio.sleep(minutes_to_start * 60)

        message = await message.channel.fetch_message(message.id)

        join_reaction = None

        for reaction in message.reactions:
            if str(reaction.emoji) == join_emoji:
                join_reaction = reaction
                break

        members = [x for x in await join_reaction.users().flatten() if not x.bot]
        random.shuffle(members)


        if len(members) < 1:
            await message.edit(content = "Not enough players")
            game.delete_instance()
            return

        players = []
        for member in members:
            players.append(Player.create(user_id = member.id, game = game))

        game.start()
Пример #2
0
    def test_player_factory(self):
        number = 1
        name = 'Miss Garbanzo'
        trail_options = [
            'Active Volcano to the Left',
            'Inactive Void of Once-Active Volcano to the Right'
        ]
        supplies = ['Vicodin', 'Revolver', 'Single Bullet', 'Garlic']
        calamities = ['Yellowstone explodes', 'Your gallstones explode']

        p: Player = Player.create(number, name, supplies, trail_options,
                                  calamities)

        self.assertEqual(number, p.number)
        self.assertEqual(name, p.name)
        for trail, supply in zip(trail_options, supplies):
            self.assertEqual(1, p.trail_options.get(trail))
            self.assertEqual(1, p.supplies.get(supply))