Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import belot
- from discord.ext.commands import Bot
- from random import randint
- import asyncio
- BOT_PREFIX = "-"
- TOKEN = "NDM3MjIyNjEzMzc5NzEwOTg2.Dby6zw.LQpRp1lYWw6ab2nTBEa1ZLK8Ohw"
- games = list()
- client = Bot(command_prefix=BOT_PREFIX)
- @client.event
- async def on_ready():
- print("Logged in as")
- print(client.user.name)
- print(client.user.id)
- print('------')
- @client.command(pass_context = True)
- async def create_game(ctx):
- for game in games:
- if game.server == ctx.message.server:
- await client.say("Only one game can run on a server at once.")
- return
- games.append(belot.Game(ctx.message.server, ctx.message.author))
- await client.say("@everyone A new game of Belote has been created by <@{}>.".format(ctx.message.author.id))
- @client.command(pass_context = True)
- async def join(ctx):
- for game in games:
- if belot.game_player_search(game, ctx.message.author):
- await client.say("<@{}> You are already participating in a game.".format(ctx.message.author.id))
- return
- for game in games:
- if game.server == ctx.message.server:
- if len(game.players) < 4:
- await client.say("<@{}> You have joined the game.".format(ctx.message.author.id))
- await client.send_message(destination = ctx.message.author, content = "You have joined a game of Belote ({})".format(ctx.message.server.name))
- game.players.append(belot.Player(ctx.message.author))
- return
- else:
- await client.say("The game is full.")
- return
- await client.say("No game running on this server.")
- @client.command(pass_context = True)
- async def start_game(ctx):
- for game in games:
- if belot.game_player_search(game, ctx.message.author):
- if len(game.players) == 4:
- game.start_game()
- return
- else:
- await client.say("Not enough players in the game.")
- return
- await client.say("You aren't participating in any games.")
- return
- async def drawgame(game):
- await client.wait_until_ready()
- for player in game:
- msg = str()
- for card in player.hand():
- msg += str(card)+"\n"
- await client.send_message(destination=player.user, content=msg)
- return
- async def gameloop():
- await client.wait_until_ready()
- for game in games:
- if game.update == True:
- if game.state == "Open":
- pass
- elif game.state == "Deal":
- for i in range(0,6):
- for player in game.players:
- player.add_card(game.deck.draw())
- await drawgame(game)
- game.state = "Bid"
- elif game.state == "Bid":
- for player in game.players:
- await client.send_message(destination = player.user, content="plati 300 kn za punu verziju")
- return
- await asyncio.sleep(1)
- client.loop.create_task(gameloop())
- client.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement