fixing blackjack and improving lookup
This commit is contained in:
@ -65,7 +65,7 @@ class Blackjack(CardGame):
|
||||
|
||||
def __init__(self, bot):
|
||||
"""Initialize the class."""
|
||||
super().__init__(bot, "blackjack", DrawBlackjack(bot, self), 4)
|
||||
super().__init__(bot, "blackjack", DrawBlackjack, 4)
|
||||
default_buttons = ["Hit", "Stand", "Double", "Split"]
|
||||
self.default_buttons = [(i, [i, "0"], 1) for i in default_buttons]
|
||||
|
||||
@ -295,7 +295,7 @@ class Blackjack(CardGame):
|
||||
|
||||
return user_hands, all_standing, pre_all_standing
|
||||
|
||||
def _blackjack_finish(self, channel: Messageable):
|
||||
async def _blackjack_finish(self, channel: Messageable):
|
||||
"""
|
||||
Generate the winnings message after the blackjack game ends.
|
||||
|
||||
@ -442,7 +442,7 @@ class Blackjack(CardGame):
|
||||
self.bot.log(log_message, str(channel.id))
|
||||
await self._blackjack_loop(channel, game_round+1, game_id)
|
||||
else:
|
||||
await channel.send(self._blackjack_finish(channel))
|
||||
await channel.send(await self._blackjack_finish(channel))
|
||||
|
||||
async def _get_hand_number(self, ctx: IntCont, command: str,
|
||||
hands_amount: int):
|
||||
@ -776,7 +776,7 @@ class Blackjack(CardGame):
|
||||
|
||||
if len(game["user hands"]) == 0:
|
||||
await ctx.channel.send("No one entered the game. Ending the game.")
|
||||
await ctx.channel.send(self._blackjack_finish(ctx.channel))
|
||||
await ctx.channel.send(await self._blackjack_finish(ctx.channel))
|
||||
return
|
||||
|
||||
game_id = game["game_id"]
|
||||
|
@ -75,7 +75,7 @@ class ConnectFour(BoardGame):
|
||||
|
||||
def __init__(self, bot):
|
||||
"""Initialize the class."""
|
||||
super().__init__(bot, "connectfour", DrawConnectFour(bot))
|
||||
super().__init__(bot, "connectfour", DrawConnectFour)
|
||||
self.get_name = self.bot.database_funcs.get_name
|
||||
# pylint: disable=invalid-name
|
||||
self.AISCORES = {
|
||||
@ -108,7 +108,7 @@ class ConnectFour(BoardGame):
|
||||
await self.bot.defer(ctx)
|
||||
channel = str(ctx.channel_id)
|
||||
|
||||
opponent_info = self._test_opponent(ctx, opponent)
|
||||
opponent_info = await self._test_opponent(ctx, opponent)
|
||||
if not opponent_info:
|
||||
return
|
||||
|
||||
@ -710,7 +710,7 @@ class DrawConnectFour():
|
||||
White, but with the alpha set to win_bar_alpha.
|
||||
"""
|
||||
|
||||
def __init__(self, bot):
|
||||
def __init__(self, bot, game):
|
||||
"""Initialize the class."""
|
||||
self.bot = bot
|
||||
self.get_name = self.bot.database_funcs.get_name
|
||||
|
@ -22,7 +22,7 @@ class GameBase():
|
||||
self.long_strings = self.bot.long_strings
|
||||
self.resources = "gwendolyn/resources/games/"
|
||||
self.game_name = game_name
|
||||
self.draw = drawer
|
||||
self.draw = drawer(bot, self)
|
||||
|
||||
def _get_action_rows(self, buttons: list[tuple[str, list]]):
|
||||
self.bot.log("Generation action rows")
|
||||
@ -100,7 +100,7 @@ class DatabaseGame(GameBase):
|
||||
|
||||
async def _send_image(self, channel: Messageable,
|
||||
buttons: list[tuple[str, list]] = None, delete=True):
|
||||
old_image = super()._send_image(channel, buttons, delete)
|
||||
old_image = await super()._send_image(channel, buttons, delete)
|
||||
with open(self.old_images_path + str(channel.id), "w") as file_pointer:
|
||||
file_pointer.write(str(old_image.id))
|
||||
|
||||
@ -153,7 +153,7 @@ class CardGame(DatabaseGame):
|
||||
return drawn_card
|
||||
|
||||
class BoardGame(GameBase):
|
||||
def _test_opponent(self, ctx: IntCont, opponent: Union[int, User]):
|
||||
async def _test_opponent(self, ctx: IntCont, opponent: Union[int, User]):
|
||||
if isinstance(opponent, int):
|
||||
# Opponent is Gwendolyn
|
||||
if opponent in range(1, 6):
|
||||
|
Reference in New Issue
Block a user