一些赌博类/工具的集合
项目描述
gamble 是一个简单的库,实现了一些常见赌博相关类的集合
特性
- 骰子,骰子,d-符号
- 牌,牌组,手牌
- 扑克牌等级,手牌比较
使用方法
安装
pip install gamble
基本用法
骰子
import gamble
# create dice, defaults to 2 6-sided dice
dice = gamble.Dice()
# roll
dice.roll()
>>> 6
dice.rolls
>>> 1
# max, min
dice.max
>>> 12
dice.min
>>> 2
# d-notation for dice constructor
dice = gamble.Dice('d20+8')
# max, min
dice.max
>>> 28
dice.min
>>> 9
# parts
dice.parts
>>> [<d20 Die>, 8]
# roll_many
dice.roll_many(2)
>>> [8, 4]
# max_of, min_of
dice.max_of(3)
>>> (11, [7, 3, 11])
dice.min_of(3)
>>> (2, [2, 9, 4])
牌
import gamble
# create a deck, defaults to the standard 52 card deck, no jokers
# the deck will be shuffled by default, unless you pass shuffle=False
deck = gamble.Deck()
deck.cards_left
>>> 52
deck.top
>>> <Card:7♠>
deck.bottom
>>> <Card:9♠>
deck.shuffle() # you can also pass times=(int) to shuffle more than once
card = deck.draw() # you can also pass times=(int) to draw a list of cards
>>> <Card:A♠>
# the unicode cards icons are implemented as well!
card.unicode
>>> "🂡"
# draw a poker hand, default size 5
hand = deck.draw_hand(). # you can pass size=(int) to draw a different size hand
>>> <Hand[5](straight flush) [A♠, 2♠, 3♠, 4♠, 5♠]>
hand.rank
>>> Rank(name='straight flush', value=8)
# arbitrary hand, from text notation
new_hand = gamble.Hand.get("2c,3c,4c,Kc,Kh")
>>> <Hand[5](pair) [2♣, 3♣, 4♣, K♣, K♥]>
new_hand.rank
>>> Rank(name='pair', value=1)
hand > new_hand
>>> True
待办事项
- 手牌等于/大于/小于方法
- 当手牌非常相似时的手牌等级
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分发
gamble-0.14.0.tar.gz (10.7 kB 查看哈希值)
构建分发
gamble-0.14.0-py3-none-any.whl (10.9 kB 查看哈希值)
关闭
gamble-0.14.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4da99572a6e879e8fb5ec0ab0c5362955f0e37d2b17781a37297c05178678dcd |
|
MD5 | 9f488a32e525c2315ccfbd916b4d6184 |
|
BLAKE2b-256 | fdd18028feed00060499672e9f9b3d3bc611685fbcad60667373554137c69f64 |
关闭
gamble-0.14.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 31d2a68626d0180b78b02780054ea6a525bb6506fbd5c613ac792ce991906399 |
|
MD5 | 71bb7f521094bf6f427b19b2eac61da6 |
|
BLAKE2b-256 | 2dc149ea9d265167a82ad3a977060be7a97dc19fa1159ec50f7cbfb7d96beed8 |