Advertisement
Guest User

BelaBot v0.0.1

a guest
Apr 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.15 KB | None | 0 0
  1. import discord
  2. import belot
  3. from discord.ext.commands import Bot
  4. from random import randint
  5. import asyncio
  6.  
  7. BOT_PREFIX = "-"
  8. TOKEN = "NDM3MjIyNjEzMzc5NzEwOTg2.Dby6zw.LQpRp1lYWw6ab2nTBEa1ZLK8Ohw"
  9.  
  10. games = list()
  11.  
  12. client = Bot(command_prefix=BOT_PREFIX)
  13.  
  14. @client.event
  15. async def on_ready():
  16.     print("Logged in as")
  17.     print(client.user.name)
  18.     print(client.user.id)
  19.     print('------')
  20.  
  21.  
  22. @client.command(pass_context = True)
  23. async def create_game(ctx):
  24.     for game in games:
  25.         if game.server == ctx.message.server:
  26.             await client.say("Only one game can run on a server at once.")
  27.             return
  28.    
  29.     games.append(belot.Game(ctx.message.server, ctx.message.author))
  30.     await client.say("@everyone A new game of Belote has been created by <@{}>.".format(ctx.message.author.id))
  31.  
  32.  
  33.  
  34. @client.command(pass_context = True)
  35. async def join(ctx):
  36.     for game in games:
  37.         if belot.game_player_search(game, ctx.message.author):
  38.             await client.say("<@{}> You are already participating in a game.".format(ctx.message.author.id))
  39.             return
  40.  
  41.     for game in games:
  42.         if game.server == ctx.message.server:
  43.             if len(game.players) < 4:
  44.                 await client.say("<@{}> You have joined the game.".format(ctx.message.author.id))
  45.                 await client.send_message(destination = ctx.message.author, content = "You have joined a game of Belote ({})".format(ctx.message.server.name))
  46.                 game.players.append(belot.Player(ctx.message.author))
  47.                 return
  48.             else:
  49.                 await client.say("The game is full.")
  50.                 return
  51.    
  52.     await client.say("No game running on this server.")
  53.  
  54. @client.command(pass_context = True)
  55. async def start_game(ctx):
  56.     for game in games:
  57.         if belot.game_player_search(game, ctx.message.author):
  58.             if len(game.players) == 4:
  59.                 game.start_game()
  60.                 return
  61.             else:
  62.                 await client.say("Not enough players in the game.")
  63.                 return
  64.  
  65.     await client.say("You aren't participating in any games.")
  66.     return
  67.  
  68. async def drawgame(game):
  69.     await client.wait_until_ready()
  70.     for player in game:
  71.         msg = str()
  72.         for card in player.hand():
  73.             msg += str(card)+"\n"
  74.         await client.send_message(destination=player.user, content=msg)
  75.     return
  76.  
  77.  
  78.  
  79. async def gameloop():
  80.     await client.wait_until_ready()
  81.     for game in games:
  82.         if game.update == True:
  83.  
  84.             if game.state == "Open":
  85.                 pass
  86.  
  87.             elif game.state == "Deal":
  88.                 for i in range(0,6):
  89.                     for player in game.players:
  90.                         player.add_card(game.deck.draw())
  91.                 await drawgame(game)
  92.                 game.state = "Bid"
  93.  
  94.             elif game.state == "Bid":
  95.                 for player in game.players:
  96.                     await client.send_message(destination = player.user, content="plati 300 kn za punu verziju")
  97.                     return
  98.  
  99.     await asyncio.sleep(1)
  100.  
  101.  
  102.  
  103. client.loop.create_task(gameloop())
  104.  
  105. client.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement