Compare commits
78 Commits
d743e5610a
...
Pokies
| Author | SHA1 | Date | |
|---|---|---|---|
| 41f5f8e2b8 | |||
| e544b505f5 | |||
| 4122817fae | |||
| c6ee83e51a | |||
| 13eb629a16 | |||
| 543b57603e | |||
| a5d86f822c | |||
| 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 |
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
|
||||
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
# Use a full Python runtime image to ensure necessary build tools are available.
|
||||
FROM python
|
||||
|
||||
# Set the working directory to organize application files.
|
||||
WORKDIR /app
|
||||
|
||||
# Copy requirements file to allow pip to find dependencies during build.
|
||||
COPY requirements.txt /app/
|
||||
|
||||
# Install Python dependencies for the application to run correctly.
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
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
|
||||
@@ -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:
|
||||
|
||||
@@ -4,7 +4,6 @@ from Ledger import Ledger
|
||||
#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?)
|
||||
#TODO Card counting.
|
||||
|
||||
# Game States
|
||||
INIT = 0
|
||||
|
||||
63
src/py/slots/Slots.py
Normal file
63
src/py/slots/Slots.py
Normal file
@@ -0,0 +1,63 @@
|
||||
from Wheel import Wheel
|
||||
from random import random
|
||||
from time import sleep
|
||||
|
||||
class SlotMachine():
|
||||
def __init__(self, screen_w=3, screen_h=3):
|
||||
jackpot = 0
|
||||
self.wheels=[]
|
||||
for i in range(screen_w):
|
||||
wheel = Wheel(size=screen_h)
|
||||
self.wheels.append(wheel)
|
||||
|
||||
def spin(self, wSpins=1):
|
||||
for _ in range(wSpins):
|
||||
for wheel in self.wheels:
|
||||
wheel.spin()
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
string = ""
|
||||
# Create an empty matrix with the sole purpose of transposing it
|
||||
matrix = [[],[],[]]
|
||||
|
||||
for i, wheel in enumerate(self.wheels):
|
||||
for icon in wheel.icons:
|
||||
matrix[i].append(icon)
|
||||
|
||||
# Use Zip function to transpose unpacked matrix (*matrix unpacks it)
|
||||
matrix = zip(*matrix)
|
||||
|
||||
for row in matrix:
|
||||
for icon in row:
|
||||
string += str(icon) + " "
|
||||
string += "\n"
|
||||
|
||||
return string
|
||||
|
||||
|
||||
def main():
|
||||
machine = SlotMachine()
|
||||
win = False
|
||||
result = []
|
||||
machine.spin(wSpins=3)
|
||||
while win == False:
|
||||
machine.spin()
|
||||
result = machine.wheels
|
||||
first_icon = result[0].icons[1]
|
||||
|
||||
if all(wheel.icons[1] == first_icon for wheel in result):
|
||||
|
||||
win = True
|
||||
|
||||
print(machine)
|
||||
sleep(1)
|
||||
|
||||
print("Woohoo!")
|
||||
|
||||
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
40
src/py/slots/Wheel.py
Normal file
40
src/py/slots/Wheel.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import random as rand
|
||||
|
||||
|
||||
"""
|
||||
Wheel Class for implementing a wheel that spins in a poker machine
|
||||
"""
|
||||
class Wheel():
|
||||
def __init__(self, size=3, num_icons = 3):
|
||||
self.size=size
|
||||
self.icons = list(range(size))
|
||||
self.num_icons = num_icons
|
||||
|
||||
def spin(self, offset=1):
|
||||
new_icons = list(range(self.size))
|
||||
# Loop through each icon and move it one space up
|
||||
# Uses modulus to loop final icon to first position
|
||||
for i, icon in enumerate(self.icons):
|
||||
new_icons[(i + offset) % len(new_icons)] = icon
|
||||
|
||||
# Randomise the first element
|
||||
new_icons[0] = rand.randint(0, self.num_icons - 1)
|
||||
|
||||
self.icons = new_icons
|
||||
|
||||
def __str__(self):
|
||||
string = ""
|
||||
for icon in self.icons:
|
||||
# Print wheel out with spaces between items
|
||||
string += str(icon) + " "
|
||||
return string
|
||||
|
||||
|
||||
def main():
|
||||
# wheel = Wheel()
|
||||
# print(wheel)
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
src/py/slots/__pycache__/Wheel.cpython-313.pyc
Normal file
BIN
src/py/slots/__pycache__/Wheel.cpython-313.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user