Compare commits
83 Commits
3d51687b51
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 180446d121 | |||
| 9113d4b8c1 | |||
| d72a6ef6f2 | |||
| b3b8c2917e | |||
| 0fdf305cd4 | |||
| 01170a3849 | |||
| c088dd276e | |||
| 6f30a23b49 | |||
| adfafa5af0 | |||
| 519528830c | |||
| 0d280777ff | |||
| b7d1ecb8d6 | |||
| 9abaa12dce | |||
| 1ceaa85589 | |||
| 2502b8e70e | |||
| 7bdb6f613c | |||
| 53458625c9 | |||
| 7c1a21d802 | |||
| 17178704a3 | |||
| ffa748f5de | |||
| 24dba9d952 | |||
| 14e64ba038 | |||
| d58d35f354 | |||
| a46962fdcb | |||
| d5ec4ad054 | |||
| 50e100d2ff | |||
| 659de90936 | |||
| ff4d40b81c | |||
| 500c6ee002 | |||
| ff53fd25cd | |||
| e664ad9d03 | |||
| 4465e6a84b | |||
| 0b1b4bc503 | |||
| b1b040f2a5 | |||
| ce7dd4ab94 | |||
| a53903bd36 | |||
| 42555b8920 | |||
| 6ee556ff60 | |||
| acdf1a393c | |||
| 4f7e2373cd | |||
| 28245c231d | |||
| cbce0eec68 | |||
| bc33de6a1f | |||
| ecc6f4cabc | |||
| 2b4dd965f5 | |||
| ac8dd1ad42 | |||
| 3723bc2b82 | |||
| 27c3b7dc48 | |||
| 69fad2c469 | |||
| e433d622f9 | |||
| d0d8e24623 | |||
| 70abd8977b | |||
| cc403c9789 | |||
| 2614ad052c | |||
| 7ef3a32e68 | |||
| b22269a5b8 | |||
| 261f4e87ed | |||
| 0373b51af9 | |||
| 1bc5dd7198 | |||
| adfaafaf67 | |||
| dccfb79ace | |||
| 028cab2de8 | |||
| d40308e1a4 | |||
| 7990cec65c | |||
| a1eca76102 | |||
| b891e3d00b | |||
|
|
61b29eea67 | ||
| 43b53d3ee8 | |||
| 1073882d31 | |||
| 5bdc618d5c | |||
| ab56bd5319 | |||
| 68d366822b | |||
| 692a160972 | |||
| d743e5610a | |||
| 48f9389100 | |||
| 686e5d6617 | |||
| bdf4c32e70 | |||
| b18f0ae688 | |||
| 9501737b43 | |||
| a6bc671231 | |||
| f9785f0e8a | |||
| a7fc6da2cb | |||
| c2ea96445d |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
ledger.db
|
||||
__pycache__/*
|
||||
src/py/__pycache__/*
|
||||
*.drawio
|
||||
57
.woodpecker.yml
Normal file
57
.woodpecker.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
kind: pipeline
|
||||
type: docker # All steps will run in Docker containers.
|
||||
|
||||
name: update-and-restart-discord-bot # A descriptive name for the pipeline.
|
||||
|
||||
when:
|
||||
- branch: main # This pipeline triggers on pushes to the 'main' branch.
|
||||
event: push
|
||||
|
||||
steps:
|
||||
- name: pull-latest-source # Step 1: Pull the latest code from Gitea.
|
||||
image: alpine/git # A lightweight image that includes the 'git' command.
|
||||
volumes:
|
||||
# Mount your bot's source code directory with read-write permissions.
|
||||
# This is crucial for 'git pull' to update the files on your host machine.
|
||||
- /home/gary/Discord/Acrybot:/app:rw # ':rw' ensures read-write access.
|
||||
commands:
|
||||
- echo "--- Pulling latest source code from Git ---"
|
||||
- cd /app # Navigate to the mounted project directory.
|
||||
# Configure Git to trust the mounted directory to avoid 'unsafe repository' warnings.
|
||||
- git config --global --add safe.directory /app
|
||||
- git pull # Pulls the latest changes from the tracking branch.
|
||||
- echo "Source code updated."
|
||||
|
||||
- name: manage-bot-containers # Step 2: Manage your bot's Docker containers.
|
||||
# Changed image to 'docker:latest' to use the unhyphenated 'docker compose'
|
||||
image: docker:latest
|
||||
volumes:
|
||||
# Mount the Docker socket from the host to allow control over host Docker daemon.
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
# Mount your Docker Compose project directory into the container.
|
||||
- /home/gary/Discord/Acrybot:/app
|
||||
environment:
|
||||
# IMPORTANT: Explicitly set the Docker Compose project name to lowercase.
|
||||
# This ensures containers are managed with the 'acrybot' prefix,
|
||||
# matching your existing containers.
|
||||
COMPOSE_PROJECT_NAME: acrybot # Changed to lowercase 'acrybot'
|
||||
commands:
|
||||
- echo "--- Building 'python-app' image without cache to ensure latest code ---"
|
||||
# Explicitly build the image for 'python-app' with --no-cache
|
||||
- docker compose build --no-cache python-app
|
||||
|
||||
- echo "--- Stopping Discord bot service python-app ---"
|
||||
# Stop the specific Discord bot service using the unhyphenated 'docker compose'.
|
||||
- docker compose stop python-app
|
||||
|
||||
- echo "--- Bringing Discord bot service up python-app ---"
|
||||
# Bring the specific Discord bot service back up using the unhyphenated 'docker compose'.
|
||||
# '--build' is no longer needed here as it was already forced by 'docker compose build --no-cache'.
|
||||
- docker compose up -d python-app
|
||||
|
||||
- echo "--- Verifying bot status ---"
|
||||
# Directly check the status of the service using docker compose ps
|
||||
- docker compose ps python-app
|
||||
- echo "--- Logs of Discord bot service ---"
|
||||
# Fetch the logs of the bot service using docker compose logs
|
||||
- docker compose logs python-app
|
||||
16
Dockerfile
16
Dockerfile
@@ -1,11 +1,11 @@
|
||||
FROM python:3
|
||||
# Use a full Python runtime image to ensure necessary build tools are available.
|
||||
FROM python
|
||||
|
||||
RUN pip install discord
|
||||
# Set the working directory to organize application files.
|
||||
WORKDIR /app
|
||||
|
||||
WORKDIR /usr/app/src
|
||||
# Copy requirements file to allow pip to find dependencies during build.
|
||||
COPY requirements.txt /app/
|
||||
|
||||
COPY Acronymbot.py ./
|
||||
COPY BlackJack.py ./
|
||||
COPY Ledger.py ./
|
||||
|
||||
CMD [ "python", "./Acronymbot.py" ]
|
||||
# Install Python dependencies for the application to run correctly.
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
@@ -1,31 +0,0 @@
|
||||
import discord
|
||||
import random
|
||||
|
||||
# Temporary List
|
||||
games = ["Left 4 Dead 2",
|
||||
"Aragami",
|
||||
"Astroneer",
|
||||
"Factorio",
|
||||
"Borderlands",
|
||||
"Stardew Valley",
|
||||
"Viscera Cleanup Detail",
|
||||
"SCP",
|
||||
"Satisfactory",
|
||||
"Backrooms (Alternate Ending)",
|
||||
"Ghost Recon Wildlands"
|
||||
]
|
||||
|
||||
def add_game(game: str):
|
||||
games.append(game)
|
||||
|
||||
def pick_game():
|
||||
|
||||
randomIndex = random.randrange(0, len(games))
|
||||
coinFlip = random.randrange(0, 2)
|
||||
if coinFlip:
|
||||
|
||||
return f"Valorant ({games[randomIndex]})"
|
||||
else:
|
||||
|
||||
return games[randomIndex]
|
||||
|
||||
34
Recycle Bin/Gamepicker.py
Normal file
34
Recycle Bin/Gamepicker.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import discord
|
||||
import random
|
||||
|
||||
# Temporary List
|
||||
# games = ["Left 4 Dead 2",
|
||||
# "Aragami",
|
||||
# "Astroneer",
|
||||
# "Factorio",
|
||||
# "Borderlands",
|
||||
# "Stardew Valley",
|
||||
# "Viscera Cleanup Detail",
|
||||
# "SCP",
|
||||
# "Satisfactory",
|
||||
# "Ghost Recon Wildlands"
|
||||
# ]
|
||||
|
||||
games = ["Plate Up",
|
||||
"Terraria",
|
||||
"Ghost Recon"]
|
||||
|
||||
def add_game(game: str):
|
||||
games.append(game)
|
||||
|
||||
def pick_game():
|
||||
|
||||
randomIndex = random.randrange(0, len(games))
|
||||
coinFlip = random.randrange(0, 2)
|
||||
if coinFlip:
|
||||
|
||||
return f"Valorant ({games[randomIndex]})"
|
||||
else:
|
||||
|
||||
return games[randomIndex]
|
||||
|
||||
20
Recycle Bin/docker-compose.yml
Normal file
20
Recycle Bin/docker-compose.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
version: "3.3"
|
||||
|
||||
networks:
|
||||
net:
|
||||
driver: bridge
|
||||
|
||||
services:
|
||||
acronymbot:
|
||||
build: ./src/py
|
||||
volumes:
|
||||
- "./src/py:/usr/app/src"
|
||||
networks:
|
||||
- "net"
|
||||
depends_on:
|
||||
- database
|
||||
|
||||
database:
|
||||
image: mariadb:latest
|
||||
networks:
|
||||
- "net"
|
||||
@@ -3,7 +3,7 @@ GAMEINFO:
|
||||
ID, NAME, GENRE, GAMEPASS
|
||||
|
||||
WHOOWNSIT (bitmap index):
|
||||
ID, MARCUS, BENSON, ALEX, TIM
|
||||
ID, MARCUS, BENSON, ALEX, TIM, AIDAN
|
||||
|
||||
GAMEFACTORS:
|
||||
ID, BRAINLEVEL, TIMETOPLAY, CAMPAIGN
|
||||
5
Recycle Bin/plan.txt
Normal file
5
Recycle Bin/plan.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Microservices:
|
||||
- Some sort of database for storing the data
|
||||
- Image for the python code that runs the bot
|
||||
- Something to interface the two, like sparkSQL for interacting with the database
|
||||
|
||||
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
# Define the services (containers) that make up your application
|
||||
services:
|
||||
# 'python-app' is the name of your service
|
||||
python-app:
|
||||
# Build the Docker image using the Dockerfile in the current directory
|
||||
build: .
|
||||
# Mount the current directory on the host machine to '/app' inside the container.
|
||||
# This enables real-time code changes during development.
|
||||
volumes:
|
||||
- "/home/gary/Discord/Acrybot:/app"
|
||||
# EXPLICITLY set the entrypoint for your container.
|
||||
# This ensures your Python script runs as the primary process and only once.
|
||||
# Replace 'your_script_name.py' with the actual name of your Python file.
|
||||
entrypoint: ["python", "src/py/Acronymbot.py"]
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
discord
|
||||
mariadb
|
||||
@@ -1,9 +1,9 @@
|
||||
import random
|
||||
import discord
|
||||
import sqlite3
|
||||
from discord import app_commands
|
||||
from BlackJack import BlackJack
|
||||
from Calculator import Calculator
|
||||
from Gamepicker import pick_game
|
||||
|
||||
botIntents = discord.Intents.all()
|
||||
|
||||
@@ -50,7 +50,7 @@ class Buttons(discord.ui.View):
|
||||
|
||||
@tree.command(description="Lmao")
|
||||
async def test(interaction:discord.Interaction):
|
||||
print(f"{interaction.user} used command! Woohoo!")
|
||||
print(f"{interaction.user} used command! BAHHHH!")
|
||||
try:
|
||||
await interaction.response.send_message("Pay $5 for a Mario Moment", view=Buttons())
|
||||
except discord.app_commands.errors.CommandInvokeError:
|
||||
@@ -112,16 +112,110 @@ async def calculator(interaction: discord.Interaction):
|
||||
calculator = Calculator()
|
||||
await interaction.followup.send(content="`" + " " * calculator.MAXIMUMBARSIZE + "0`", view=calculator)
|
||||
|
||||
@tree.command(description="Roll a Dice")
|
||||
@app_commands.choices(dice = [
|
||||
app_commands.Choice(name = 'd4', value=4),
|
||||
app_commands.Choice(name = 'd6', value=6),
|
||||
app_commands.Choice(name = 'd8', value=8),
|
||||
app_commands.Choice(name = 'd10', value=10),
|
||||
app_commands.Choice(name = 'd12', value=12),
|
||||
app_commands.Choice(name = 'd20', value=20),
|
||||
app_commands.Choice(name = 'd100', value=100),
|
||||
])
|
||||
async def roll(interaction: discord.Interaction, dice:app_commands.Choice[int]):
|
||||
|
||||
roll = random.randint(1, dice.value)
|
||||
await interaction.response.send_message(f"{dice.name}: {roll}")
|
||||
|
||||
|
||||
|
||||
"""
|
||||
#### Game Picker ####
|
||||
#### Russian Roulette ####
|
||||
"""
|
||||
@tree.command(description="Pick a game")
|
||||
async def gg(interaction: discord.Interaction):
|
||||
MAXLINELENGTH = 12
|
||||
tooLong = lambda x: len(x) > MAXLINELENGTH
|
||||
tooShort = lambda x: len(x) < MAXLINELENGTH
|
||||
difference = lambda x: MAXLINELENGTH - len(x)
|
||||
sidePad = lambda x: " " * (difference(x) // 2)
|
||||
evenPad = lambda x: sidePad(x) + x + sidePad(x)
|
||||
oddPad = lambda x: evenPad(x) + " "
|
||||
|
||||
game = pick_game()
|
||||
await interaction.response.send_message("Barotrauma")
|
||||
def demon_text_helper(line):
|
||||
if tooShort(line):
|
||||
if difference(line) % 2 == 0:
|
||||
return evenPad(line)
|
||||
else:
|
||||
return oddPad(line)
|
||||
|
||||
return line
|
||||
|
||||
def demon_text(lineOne="", lineTwo="", lineThree=""):
|
||||
|
||||
if tooLong(lineOne) or tooLong(lineTwo) or tooLong(lineThree):
|
||||
print("Line too long lol")
|
||||
|
||||
lineOne = demon_text_helper(lineOne)
|
||||
lineTwo = demon_text_helper(lineTwo)
|
||||
lineThree = demon_text_helper(lineThree)
|
||||
|
||||
|
||||
|
||||
demon = f"``` , , /\ /\ \n\
|
||||
/( /\ )\ _\ \_/ /_ ____________\n\
|
||||
|\_||_/| < \_ _/ > / \ \n\
|
||||
\______/ \|0 0|/ | {lineOne} |\n\
|
||||
_\/_ _(_ ^ _)_ | {lineTwo} |\n\
|
||||
( () ) /`\|V\"\"\"V|/`\ | {lineThree} |\n\
|
||||
{{}} \ \_____/ / <______________/\n\
|
||||
() /\ )=( /\ \n\
|
||||
{{}} / \_/\=/\_/ \ \n```"
|
||||
return demon
|
||||
|
||||
class ShootOrNoShoot(discord.ui.View):
|
||||
def __init__(self, *, timeout=180):
|
||||
super().__init__(timeout=timeout)
|
||||
self.bullets = 6
|
||||
|
||||
@discord.ui.button(label="Shoot", style=discord.ButtonStyle.red)
|
||||
async def shoot(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||
if self.bullets == 0:
|
||||
for child in self.children:
|
||||
child.disabled = True
|
||||
await interaction.response.edit_message(content=f"What?", view=self)
|
||||
|
||||
if random.randrange(0,self.bullets) == 0:
|
||||
for child in self.children:
|
||||
child.disabled = True
|
||||
|
||||
demonDeath = demon_text(lineOne="You died!", lineTwo="Bahahahah!", lineThree=f"Score: {6 - self.bullets}")
|
||||
await interaction.response.edit_message(content=f"{demonDeath}", view=self)
|
||||
|
||||
else:
|
||||
|
||||
self.bullets -= 1
|
||||
button.label = f"Shoot again"
|
||||
demonLife = demon_text(lineOne="You live", lineTwo="This time!!",
|
||||
lineThree=f"({6 - self.bullets}/5) blanks")
|
||||
await interaction.response.edit_message(content=f"{demonLife}", view=self)
|
||||
|
||||
|
||||
|
||||
|
||||
@discord.ui.button(label="PussyOut", style=discord.ButtonStyle.blurple)
|
||||
async def noshoot(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||
for child in self.children:
|
||||
child.disabled = True
|
||||
|
||||
demonPussy = demon_text(lineOne="You are such", lineTwo="a huge pussy", lineThree= "0 bitches 4u")
|
||||
await interaction.response.edit_message(content=f"{demonPussy}", view=self)
|
||||
|
||||
|
||||
@tree.command(description="????")
|
||||
async def rr(interaction: discord.Interaction):
|
||||
await interaction.response.defer()
|
||||
buttons = ShootOrNoShoot()
|
||||
demon = demon_text(lineTwo="Shoot urself")
|
||||
await interaction.followup.send(content=f"{demon}", view=buttons)
|
||||
|
||||
"""
|
||||
#### Fin ####
|
||||
@@ -1,7 +1,6 @@
|
||||
import random
|
||||
from Ledger import Ledger
|
||||
|
||||
#TODO Starting a game with 21 fucks with hidden cards
|
||||
#TODO Look into 5card jack thingo that Tim mentioned
|
||||
#TODO Insurance - If dealer starts with 21, you can bet against it and win your money back
|
||||
#TODO Make each game session more distinct (Embeds?)
|
||||
@@ -29,10 +28,23 @@ class Card():
|
||||
self.value = value
|
||||
self.suit = suit
|
||||
self.hidden = False
|
||||
|
||||
if self.value in range(2,7):
|
||||
self.count_value = 1
|
||||
|
||||
elif self.value in range(7,10):
|
||||
self.count_value = 0
|
||||
|
||||
def turn_card(self):
|
||||
# XOR to flip hidden element
|
||||
self.hidden = self.hidden != True
|
||||
else:
|
||||
self.count_value = -1
|
||||
|
||||
|
||||
|
||||
def hide_card(self):
|
||||
self.hidden = True
|
||||
|
||||
def show_card(self):
|
||||
self.hidden = False
|
||||
|
||||
def get_value(self):
|
||||
return self.value
|
||||
@@ -51,7 +63,7 @@ class Card():
|
||||
strValue = str(self.value)
|
||||
|
||||
string = ""
|
||||
string = f"{suits[self.suit]}{strValue}"
|
||||
string = f"{suits[self.suit]}{strValue}: ({self.count_value})"
|
||||
if self.hidden:
|
||||
string = "??"
|
||||
return string
|
||||
@@ -67,11 +79,11 @@ class Deck():
|
||||
self.discard = []
|
||||
self.joker = joker
|
||||
|
||||
self.deck.extend([Card(x, Card.HEARTS) for x in range(1, 13)])
|
||||
self.deck.extend([Card(x, Card.DIAMONDS) for x in range(1, 13)])
|
||||
self.deck.extend([Card(x, Card.SPADES) for x in range(1, 13)])
|
||||
self.deck.extend([Card(x, Card.CLUBS) for x in range(1, 13)])
|
||||
|
||||
self.deck.extend([Card(x, Card.HEARTS) for x in range(1, 14)])
|
||||
self.deck.extend([Card(x, Card.DIAMONDS) for x in range(1, 14)])
|
||||
self.deck.extend([Card(x, Card.SPADES) for x in range(1, 14)])
|
||||
self.deck.extend([Card(x, Card.CLUBS) for x in range(1, 14)])
|
||||
print(len(self.deck))
|
||||
if joker:
|
||||
self.deck.append(Card(0, 0))
|
||||
|
||||
@@ -113,6 +125,7 @@ class Deck():
|
||||
class Hand():
|
||||
def __init__(self) -> None:
|
||||
self.hand = []
|
||||
self.hidden_cards = []
|
||||
|
||||
def sortHand(self):
|
||||
self.hand.sort()
|
||||
@@ -130,11 +143,26 @@ class Hand():
|
||||
return self.hand[index]
|
||||
|
||||
def hide_card(self, index):
|
||||
self.peek_card(index).turn_card()
|
||||
card = self.peek_card(index)
|
||||
card.hide_card()
|
||||
self.hidden_cards.append(card)
|
||||
|
||||
def show_card(self, index):
|
||||
card = self.peek_card(index)
|
||||
card.show_card()
|
||||
try:
|
||||
self.hidden_cards.remove(card)
|
||||
except ValueError:
|
||||
print("Card not hidden")
|
||||
|
||||
def show_hand(self):
|
||||
extra_count = 0
|
||||
for card in self.hidden_cards:
|
||||
card.show_card()
|
||||
extra_count += card.count_value
|
||||
self.hidden_cards.remove(card)
|
||||
return extra_count
|
||||
|
||||
def __len__(self):
|
||||
return len(self.hand)
|
||||
|
||||
def __str__(self) -> str:
|
||||
string = ""
|
||||
for card in self.hand:
|
||||
@@ -147,11 +175,14 @@ class Hand():
|
||||
aces = 0
|
||||
# Add static values
|
||||
for card in self.hand:
|
||||
if card.hidden:
|
||||
continue
|
||||
if card.value == 1:
|
||||
aces += 1
|
||||
continue
|
||||
if card.value > 10:
|
||||
card.value = 10
|
||||
value += 10
|
||||
continue
|
||||
value += card.value
|
||||
|
||||
# Dynamically add ace value based on ideal rules
|
||||
@@ -174,6 +205,8 @@ class Hand():
|
||||
def __next__(self):
|
||||
return next(self.iter)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.hand)
|
||||
|
||||
class BlackJack:
|
||||
def __init__(self) -> None:
|
||||
@@ -181,34 +214,49 @@ class BlackJack:
|
||||
self.playerHand = Hand()
|
||||
self.dealerHand = Hand()
|
||||
self.ledger = Ledger()
|
||||
self.playing = False
|
||||
self.count = 0
|
||||
|
||||
def deal_card(self, hand):
|
||||
card = self.deck.take_from_deck()
|
||||
hand.add_to_hand(card)
|
||||
self.count += card.count_value
|
||||
|
||||
def deal_hidden_card(self, hand):
|
||||
hand.add_to_hand(self.deck.take_from_deck())
|
||||
# Hide one of the dealers cards
|
||||
self.dealerHand.hide_card(1)
|
||||
|
||||
def game_setup(self):
|
||||
# Deal cards in alternate order
|
||||
self.deck.shuffle()
|
||||
for _ in range(2):
|
||||
for i in range(2):
|
||||
self.deal_card(self.playerHand)
|
||||
self.deal_card(self.dealerHand)
|
||||
if i == 0:
|
||||
self.deal_card(self.dealerHand)
|
||||
else:
|
||||
self.deal_hidden_card(self.dealerHand)
|
||||
|
||||
# Hide one of the dealers cards
|
||||
self.dealerHand.hide_card(1)
|
||||
|
||||
def discard_hand(self, hand):
|
||||
hand.show_hand()
|
||||
for _ in range(len(hand)):
|
||||
card = hand.remove_from_hand(0)
|
||||
self.deck.addToDiscard(card)
|
||||
|
||||
async def show_cards(self, send, displayDealerScore=False):
|
||||
async def show_cards(self, send):
|
||||
# Show Cards to player
|
||||
string = f"Player Hand = {repr(self.playerHand)}: {self.playerHand}\nDealer Hand = ??: {self.dealerHand}"
|
||||
if displayDealerScore:
|
||||
string = f"Player Hand = {repr(self.playerHand)}: {self.playerHand}\nDealer Hand = {repr(self.dealerHand)}: {self.dealerHand}"
|
||||
string = f"Player Hand = {repr(self.playerHand)}: {self.playerHand}\nDealer Hand = {repr(self.dealerHand)}: {self.dealerHand}\nCount = {self.count}"
|
||||
|
||||
await send(string)
|
||||
|
||||
async def play_game(self, ID, bet, recv, send):
|
||||
|
||||
if self.playing:
|
||||
await send("Game in Progress")
|
||||
return
|
||||
else:
|
||||
self.playing = True
|
||||
gameState = INIT
|
||||
|
||||
while gameState != OVER:
|
||||
@@ -219,6 +267,9 @@ class BlackJack:
|
||||
playerStats = self.ledger.read(ID)
|
||||
self.game_setup()
|
||||
gameState = PLAYERTURN
|
||||
|
||||
if int(repr(self.playerHand)) >= 21:
|
||||
gameState = FINISHED
|
||||
|
||||
if gameState == PLAYERTURN:
|
||||
|
||||
@@ -227,17 +278,15 @@ class BlackJack:
|
||||
if playerHit:
|
||||
self.deal_card(self.playerHand)
|
||||
else:
|
||||
#TODO Rename hide_card function
|
||||
self.dealerHand.hide_card(1)
|
||||
gameState = DEALERTURN
|
||||
|
||||
if int(repr(self.playerHand)) >= 21:
|
||||
|
||||
self.dealerHand.hide_card(1)
|
||||
gameState = FINISHED
|
||||
|
||||
if gameState == DEALERTURN:
|
||||
|
||||
extra_count = self.dealerHand.show_hand()
|
||||
self.count += extra_count
|
||||
if int(repr(self.dealerHand)) > int(repr(self.playerHand)):
|
||||
gameState = FINISHED
|
||||
continue
|
||||
@@ -256,7 +305,7 @@ class BlackJack:
|
||||
tie = False
|
||||
playerScore = int(repr(self.playerHand))
|
||||
dealerScore = int(repr(self.dealerHand))
|
||||
await self.show_cards(send, True)
|
||||
await self.show_cards(send)
|
||||
if playerScore == 21:
|
||||
playerBlackJack = True
|
||||
if dealerScore == 21:
|
||||
@@ -308,8 +357,10 @@ class BlackJack:
|
||||
if len(self.deck) < 0.25 * 51:
|
||||
self.deck.return_all_from_discard()
|
||||
self.deck.shuffle()
|
||||
self.count = 0
|
||||
await send("Everyday I'm shuffling")
|
||||
gameState = OVER
|
||||
self.playing = False
|
||||
|
||||
def main():
|
||||
game = BlackJack()
|
||||
@@ -319,6 +370,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
main()
|
||||
11
src/py/Dockerfile
Normal file
11
src/py/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM python:3
|
||||
|
||||
RUN pip install discord \
|
||||
&& pip install mariadb
|
||||
|
||||
WORKDIR /usr/app/src
|
||||
|
||||
VOLUME /usr/app/src
|
||||
# -v flag to mount to this volume. -v [from]:/usr/app/src
|
||||
|
||||
CMD [ "python", "./Acronymbot.py" ]
|
||||
BIN
src/py/__pycache__/BlackJack.cpython-310.pyc
Normal file
BIN
src/py/__pycache__/BlackJack.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/py/__pycache__/Calculator.cpython-310.pyc
Normal file
BIN
src/py/__pycache__/Calculator.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/py/__pycache__/Gamepicker.cpython-310.pyc
Normal file
BIN
src/py/__pycache__/Gamepicker.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/py/__pycache__/Ledger.cpython-310.pyc
Normal file
BIN
src/py/__pycache__/Ledger.cpython-310.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user