blackjack

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Blackjack Skill

21点技能

This skill enables the agent to play blackjack with users. The agent acts as the dealer, managing game state, dealing cards, and displaying card images.
该技能支持Agent与用户一起玩21点游戏。Agent扮演发牌员的角色,负责管理游戏状态、发牌以及展示卡牌图片。

Game Rules

游戏规则

  • Standard blackjack rules apply
  • Dealer hits on 16 or below, stands on 17 or above
  • Blackjack (21 with 2 cards) pays 3:2
  • Regular win pays 1:1
  • Ace counts as 1 or 11 (whichever is better)
  • Face cards (J, Q, K) count as 10
  • 适用标准21点规则
  • 发牌员点数16及以下要牌,17及以上停牌
  • 21点(两张牌凑成21点)赔付比例3:2
  • 普通获胜赔付比例1:1
  • A可以计为1点或11点(取对玩家更有利的数值)
  • 花牌(J、Q、K)计为10点

How to Play

游玩方式

When a user wants to play blackjack:
  1. Initialize a new game and deal 2 cards to player and 2 to dealer (one dealer card face down)
  2. Show the cards using the images in the
    assets/cards/
    directory
  3. Present "Hit" and "Stand" buttons (on Telegram) or ask player to type their choice
  4. Continue until player stands or busts
  5. Reveal dealer's hidden card and play dealer's hand
  6. Determine winner and display results
当用户想要玩21点时:
  1. 初始化新游戏,给玩家和发牌员各发2张牌(发牌员的一张牌背面朝上)
  2. 使用
    assets/cards/
    目录下的图片展示卡牌 3.(在Telegram上)展示「Hit(要牌)」和「Stand(停牌)」按钮,或者让玩家输入他们的选择
  3. 持续操作直到玩家停牌或者爆牌
  4. 展示发牌员的暗牌,完成发牌员的回合操作
  5. 判定胜负并展示结果

Telegram Integration

Telegram集成

When playing on Telegram, use inline buttons for better UX:
json
{
  "action": "send",
  "channel": "telegram",
  "target": "user:<id>",
  "text": "Your turn! Total: 16",
  "buttons": [
    [{"text": "🃏 Hit", "data": "hit"}],
    [{"text": "✋ Stand", "data": "stand"}]
  ]
}
For new game prompts:
json
{
  "buttons": [
    [{"text": "🎰 New Game", "data": "newgame"}]
  ]
}
在Telegram上游玩时,使用内联按钮获得更好的用户体验:
json
{
  "action": "send",
  "channel": "telegram",
  "target": "user:<id>",
  "text": "Your turn! Total: 16",
  "buttons": [
    [{"text": "🃏 Hit", "data": "hit"}],
    [{"text": "✋ Stand", "data": "stand"}]
  ]
}
新游戏提示的代码示例:
json
{
  "buttons": [
    [{"text": "🎰 New Game", "data": "newgame"}]
  ]
}

Sending Card Images

发送卡牌图片

Use the MEDIA: prefix to send card images from the assets directory:
Your cards:
MEDIA:assets/cards/ace_spades.png
MEDIA:assets/cards/king_hearts.png
Total: 21 - Blackjack!
使用MEDIA:前缀发送assets目录下的卡牌图片:
Your cards:
MEDIA:assets/cards/ace_spades.png
MEDIA:assets/cards/king_hearts.png
Total: 21 - Blackjack!

Card Image Files

卡牌图片文件

All card images are located in
assets/cards/
with the naming pattern:
  • {rank}_{suit}.png
    (e.g.,
    ace_spades.png
    ,
    10_hearts.png
    ,
    jack_diamonds.png
    )
  • card_back.png
    for face-down cards
Available ranks: ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king Available suits: hearts, diamonds, clubs, spades
所有卡牌图片都存放在
assets/cards/
目录下,命名规则如下:
  • {rank}_{suit}.png
    (例如
    ace_spades.png
    10_hearts.png
    jack_diamonds.png
  • card_back.png
    为背面朝上的卡牌
可用点数:ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king 可用花色:hearts(红桃)、diamonds(方块)、clubs(梅花)、spades(黑桃)

Game State Management

游戏状态管理

Track the following for each game:
  • Player's cards and total
  • Dealer's cards and total
  • Deck state (remaining cards)
  • Game status (in_progress, player_bust, dealer_bust, player_wins, dealer_wins, push)
每场游戏需要追踪以下信息:
  • 玩家的卡牌和总点数
  • 发牌员的卡牌和总点数
  • 牌堆状态(剩余卡牌)
  • 游戏状态(in_progress进行中、player_bust玩家爆牌、dealer_bust发牌员爆牌、player_wins玩家获胜、dealer_wins发牌员获胜、push平局)

Example Interaction

交互示例

User: "Let's play blackjack!"
Agent: "🃏 Starting a new game of Blackjack!
Your cards: MEDIA:assets/cards/7_hearts.png MEDIA:assets/cards/9_diamonds.png Your total: 16
Dealer's cards: MEDIA:assets/cards/king_clubs.png MEDIA:assets/cards/card_back.png Dealer showing: King (10)
Would you like to hit or stand?"
On Telegram, the agent should also send inline buttons for Hit/Stand actions.
用户:"我们来玩21点吧!"
Agent:"🃏 开始新的21点游戏!
你的卡牌: MEDIA:assets/cards/7_hearts.png MEDIA:assets/cards/9_diamonds.png 你的总点数:16
发牌员的卡牌: MEDIA:assets/cards/king_clubs.png MEDIA:assets/cards/card_back.png 发牌员明牌:K(10点)
你想要要牌还是停牌?"
在Telegram上,Agent还应该发送要牌/停牌操作的内联按钮。

Button Callback Handling

按钮回调处理

When user clicks a button, the callback data will be:
  • "hit" - deal another card to player
  • "stand" - end player's turn, reveal dealer cards
  • "newgame" - start a fresh game
Always acknowledge the button press and update game state accordingly.
当用户点击按钮时,回调数据将是:
  • "hit" - 给玩家再发一张牌
  • "stand" - 结束玩家回合,展示发牌员的所有卡牌
  • "newgame" - 开启新一局游戏
始终响应按钮点击并对应更新游戏状态。