Add blackjack plugin.

This commit is contained in:
oddluck 2019-12-06 10:22:40 +00:00
parent ecd39b4d15
commit dfca8a08fc
4 changed files with 377 additions and 401 deletions

View File

@ -1,22 +1,3 @@
Ordinary BlackJack game.
Forked from https://github.com/kg-bot/SupyBot/tree/master/plugins/BlackJack
Player can play only one instance of the game in same time.
Player must have enough chips to backup his stake.
When the player places bet and starts a game chips are taken away from him, if he wins
initial stake and bonus are added back to his account.
Each dealer and player are dealt two cards in the begining.
We make a check for blackjack after first two cards are dealt.
If nobody has blackjack we must wait for the player to hit/double or stand.
Player can decide what to do until he stands or he's busted.
When the player stands we start to deal cards to dealer until he reaches 17 or higher.
If the dealer is busted then player winns the game and we calculate the prize.
If the dealer is not busted and he's reached 17 we compare player and dealer score and calculate winner.
This plugin is pretty basic to start, but I plan on improving it.

View File

@ -41,14 +41,16 @@ import supybot.world as world
__version__ = ""
# XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.authors.unknown
__author__ = supybot.Author('KgBot', 'KgBot', '')
__maintainer__ = getattr(supybot.authors, 'oddluck',
supybot.Author('oddluck', 'oddluck', 'oddluck@riseup.net'))
# This is a dictionary mapping supybot.Author instances to lists of
# contributions.
__contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/BlackJack/download'
__url__ = 'https://github.com/oddluck/limnoria-plugins/'
from . import config
from . import plugin

View File

@ -1,11 +1,2 @@
{
"donvitocorleone": {
"chips": 577
},
"kg-bot": {
"chips": 560
},
"crazy_hospy": {
"chips": 936
}
}

View File

@ -198,6 +198,7 @@ class BlackJack(callbacks.Plugin):
if player in self.players.keys():
if self.players[player]["score"] == 21 and self.players[player]["bankScore"] != 21:
self._playerWins(irc, player, True)
self.players[player]["waitingAction"] = False
elif self.players[player]["bankScore"] == 21 and self.players[player]["score"] != 21:
self._bankWins(irc, player)
else:
@ -224,16 +225,16 @@ class BlackJack(callbacks.Plugin):
if self._isScheduled(game_name):
irc.reply("You can play only one instance of the game in same time.")
# If player does not have chips he can't play, logical.
elif chips == "NoChipsFile" or chips == False or chips == None:
irc.reply("You can't play blackjack because you don't have enough chips. If you think this is some mistake notify admins.")
if chips == "NoChipsFile" or chips == False or chips == None:
chipsClass = Chips()
chipsClass._addChips(player, stake)
chips = stake
if stake >= self.minStake and stake <= self.maxStake and stake <= chips:
# Now is good time to add new player and actually start a game.
self._addNewPlayer(player, stake)
self._startNewGame(irc, player)
else:
# If player has enough chips to backup his stake we can start a game.
if stake >= self.minStake and stake <= self.maxStake and stake <= chips:
# Now is good time to add new player and actually start a game.
self._addNewPlayer(player, stake)
self._startNewGame(irc, player)
else:
irc.reply("Something is wrong with your stake, maybe it's too high or too low, or maybe you don't have enough chips.")
irc.reply("Something is wrong with your stake, maybe it's too high or too low, or maybe you don't have enough chips.")
blackjack = wrap(blackjack, ["int"])
def _startNewGame(self, irc, player):
@ -365,3 +366,4 @@ Class = BlackJack
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: