hopkins / slack-against-humanity
一个 Slack webhook 集成,让您的团队玩“反人类”卡牌游戏
Requires
- hopkins/gamesbase: dev-develop
- illuminate/database: 5.*
- illuminate/routing: 5.*
- illuminate/support: 5.*
- maknz/slack: ^1.7.0
This package is not auto-updated.
Last update: 2024-09-14 16:29:27 UTC
README
Slack Against Humanity 是一款基于 Slack/Hubot 的流行卡牌游戏“反人类”的实现。命令通过自定义 Slash 命令、Github 的 Hubot 或两者的组合在 Slack 频道发出,然后传递给此包。卡牌将被分发,法官将在随机选择,谁玩什么牌将保持秘密直到游戏结束(如果他们赢了)!
- 这是“反人类”。如果您容易受到冒犯,这款游戏不适合您。
- 所有命令都通过针对 Web API 的 GET 和 POST 请求发出
- 763 张包含的卡牌!
- 103 张 黑卡
- 660 张 白卡
- 每轮随机选择一位法官
- 可以随时进入和退出游戏
- Laravel 5.x 兼容性
- 识别谁实际上在玩或不在玩
- 还有更多功能正在开发中。
任何想要玩游戏的人都需要进入。每次发牌时都会进行检查,每个新轮次都会有 3 个人在玩。CAH 有两个人玩会很无聊。不喜欢你的牌?太糟糕了,这里不允许作弊。
一旦发牌,就会随机选择一位法官,并随机选择一张黑卡。除了法官外,所有人都需要从手中玩一张白卡。
每个玩家玩一张牌后,都会进行检查,看是否所有可以玩的人都玩了。如果他们玩了,就到了选择赢家的时候!只有法官可以决定赢家。
然后,所有玩过牌的人都会发一张新牌。然后一切重新开始。
#安装
目前,此包期望您已经在自己的环境中设置了 Maknz/Slack。这包括设置 facade Slack::
以及在 Slack 中设置一个 #cards 频道。
在您的 composer.json
中要求此包,并更新 composer。
"hopkins/slack-against-humanity": "~0.5"
更新 composer 后,将 ServiceProvider 添加到 app/config/app.php
中的 providers 数组中
'Hopkins\SlackAgainstHumanity\Providers\SahServiceProvider',
运行 artisan 命令以将迁移和文件引入您的源数据库
php artisan vendor:publish
创建一个新的 CardsController,它扩展了包中的控制器
<?php namespace Idop\Http\Controllers; use Hopkins\SlackAgainstHumanity\Game\BaseCardsController; class CardsController extends BaseCardsController{}
您还需要将以下内容添加到您的 routes.php
文件中
Route::group(['prefix' => 'cards'], function () { Route::get('deal', 'CardsController@deal'); Route::get('start', 'CardsController@start'); Route::get('show', 'CardsController@show'); Route::post('play', 'CardsController@play'); Route::post('choose', 'CardsController@choose'); Route::get('quit', 'CardsController@quit'); });
玩家可以使用公共消息触发所有这些端点,除了 Route::post('play',...)
。这需要在秘密中进行。一个 自定义 Slash 命令 非常适合这个。
我们使用我们的 hubot,Sterling,来玩其他命令。CoffeeScript 代码相当简单,易于实现。
# Description: # Cards Against Humanity! # # Dependencies: # None # # Commands: # hubot cards deal - adds you to the current cards game # hubot cards quit - removes you from the current cards game # hubot cards show - messages you your cards again incase you forgot # /cards {id} - plays the id of your chosen card for the current round (a slack slash command is taking care of it though) # hubot cards choose {id} - The current round's judge chooses the best card against the pre determined black card # hubot cards status - Returns the current rounds judge, and any players who have not yet played a card # # Author: # michael-hopkins url = "http://idop.appit.ventures/cards/" module.exports = (sterling) -> sterling.respond /cards deal/i, (msg) -> data = {'user_name': msg.message.user.name,'room': msg.message.user.room} sterling.http(url+"deal").query(data).get() (err, res, body) -> sterling.respond /cards start/i, (msg) -> data = {'user_name': msg.message.user.name,'room': msg.message.user.room} sterling.http(url+"start").query(data).get() (err, res, body) -> sterling.respond /cards quit/i, (msg) -> data = {'user_name': msg.message.user.name,'room': msg.message.user.room} sterling.http(url+"quit").query(data).get() (err, res, body) -> sterling.respond /cards show/i, (msg) -> data = {'user_name': msg.message.user.name,'room': msg.message.user.room} sterling.http(url+"show").query(data).get() (err, res, body) -> sterling.respond /cards choose (.*)/i, (msg) -> cardId = msg.match[1] data = {'user_name': msg.message.user.name,'room': msg.message.user.room,'cardId': cardId} sterling.http(url+"choose").query(data).get() (err, res, body) -> sterling.respond /cards status/i, (msg) -> data = {'user_name': msg.message.user.name,'room': msg.message.user.room} sterling.http(url+"status").query(data).get() (err, res, body) ->
"路线图"
- 添加测试以验证完整功能的包
- 需要每个玩家提供 2 张(或更多)卡牌的黑卡
- 使用图像处理库生成实际的“卡牌”而不是仅消息
- 删除或构建 maknz/flash 的依赖项,而不是依赖于它已经实现
- 添加配置以指定在哪个房间中播放SAH,而不是假设
#cards
- 自动化控制器和路由,这样用户就不需要干预
许可证
本项目使用DBAD许可证。尽情享受吧。