slack-poker-bot

A bot that deals Texas Hold'em games in Slack

  • 所有者: CharlieHess/slack-poker-bot
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Slack Poker Bot Build Status

A bot that turns Slack into a legitimate Texas Hold'em client. Start a game in any channel or private group with 2-10 players. PokerBot will deal hands, direct message players with their hole cards, query players for their action, determine the winning hand, and handle the pot.


See it in action.

Getting Started

  1. Create a new bot integration
  2. Follow the steps to deploy the bot to Heroku or run it locally
  3. Once the bot is running, start a game with: @<your-bot-name>: deal

One-Click Heroku

Click this button:

Deploy

Manual Heroku

  1. Install Heroku toolbelt
  2. Create a new bot integration (as above)
  3. heroku create
  4. heroku config:set SLACK_POKER_BOT_TOKEN=[Your API token]
  5. git push heroku master

To Run Locally

  1. Create a token.txt file and paste your API token there
  2. npm install
  3. node src/main.js

Directions

  • To start a game, @<your-bot-name>: deal.
  • To end a game, @<your-bot-name>: quit game. The game will end once the current hand finishes.
    Note that any player can end a game at any time with this command, so Be Honorable™.
  • To configure some bot options, @<your-bot-name>: config <name-of-option>=<value>. The supported options are:
timeout: Sets the duration (in seconds) before a player times out. 
Set to 0 to specify no timeout.

So, to start a game without any player timeout, say:

@<your-bot-name>: config timeout=0
@<your-bot-name>: deal

Check the open issues for some planned enhancements.

AI Players

Although this client was built for managing human players in a Slack channel, it has some support for AI players. To add a bot player:

  1. Add a bot class under the ai/ folder
  2. Implement getAction, which is called whenever it is the bot's turn
  3. Modify the addBotPlayers method in src/bot.js to add your bot to every game

Test All The Things

To run tests, simply do:

  1. gulp

The tests produce legible output that matches what users in Slack would see. This is the same test suite that is run on each pull request. This is very helpful when diagnosing a logic bug:

Dependencies

  • NodeJS Slack Client
    node-slack-client abstracts the basics of a Slack bot, including authentication, getting messages from players, and posting messages or attachments to the channel.

  • RxJS
    The majority of this client is written using RxJS. It simplifies many of the complex player polling interactions, that would otherwise be Death By Timers, into very legible code.

  • Imgur / Lightweight Image Processor
    Each card is a separate image, and board images are created on the fly by pasting several cards onto a single canvas (with the help of lwip). The resulting image is than uploaded to imgur, which gives us a single URL that can be passed as an attachment to the Slack API. This route was chosen to avoid uploading 318,505,200 images to the cloud, and allows us to modify the card assets easily.

  • Poker Evaluator
    poker-evaluator is used for evaluating the winning hand when it comes time to show down. Here it has been extended to calculate the best 5-card hand from any 7-card hand.

  • MochaJS
    Most of the tricky client logic is backed up by tests, which were written using MochaJS.

  • Vector Playing Cards

主要指标

概览
名称与所有者CharlieHess/slack-poker-bot
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2015-04-19 00:08:17
推送于2018-08-02 19:11:24
最后一次提交2016-03-23 14:23:18
发布数7
最新版本名称v1.0.1 (发布于 )
第一版名称v0.5 (发布于 )
用户参与
星数1.7k
关注者数38
派生数204
提交数241
已启用问题?
问题数43
打开的问题数16
拉请求数22
打开的拉请求数2
关闭的拉请求数8
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?