Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions agb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Nutzungsbedingungen (AGB) - ManagerX</title>
<meta name="description" content="Nutzungsbedingungen von ManagerX" />

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/web/entries/agb.tsx"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions datenschutz.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Datenschutz - ManagerX</title>
<meta name="description" content="Datenschutzbestimmungen von ManagerX" />

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/web/entries/datenschutz.tsx"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions examples/bot/embeds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# How Works Embeds?

import discord
from discord import slash_command
import ezcord

class Embeds(ezcord.Cog):
def __init__(self, bot):
self.bot = bot

@slash_command(name="embed", description="Embeds")
async def embed(self, ctx):
embed = discord.Embed(
title="Hello World!", # Embed Title
description="This is a embed", # Embed Description
color=discord.Color.blue() # Embed Color
)
embed.set_author(
name="Embeds", # Embed Author Name
icon_url=self.bot.user.avatar.url # Embed Author Icon
)
embed.set_footer(
text="Embeds", # Embed Footer Text
icon_url=self.bot.user.avatar.url # Embed Footer Icon
)
embed.set_thumbnail(
url=self.bot.user.avatar.url # Embed Thumbnail
)
embed.set_image(
url=self.bot.user.avatar.url # Embed Image
)
await ctx.respond(embed=embed)

def setup(bot):
bot.add_cog(Embeds(bot)) # Add the Cog to the Bot
18 changes: 18 additions & 0 deletions impressum.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Impressum - ManagerX</title>
<meta name="description" content="Impressum von ManagerX" />

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/web/entries/impressum.tsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/api/dashboard/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Wir erstellen einen Router, den wir später in die Haupt-App einbinden
router = APIRouter(
prefix="/api/v1/managerx",
prefix="/v1/managerx",
tags=["dashboard"]
)

Expand Down
30 changes: 28 additions & 2 deletions src/bot/cogs/fun/4gewinnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
ROWS = 6
COLUMNS = 7
DEFAULT_TIMEOUT = 300 # 5 Minuten
ACTIVE_AI_GAMES = 0
MAX_AI_GAMES = 5

# Improved difficulty levels with better depth and strategy
DIFFICULTY_CONFIG = {
Expand Down Expand Up @@ -489,7 +491,7 @@ async def callback(self, interaction: discord.Interaction):
)

class Connect4View(View):
def __init__(self, player1, player2, messages, is_ai_mode=False, difficulty="medium"):
def __init__(self, player1, player2, messages, is_ai_mode=False, difficulty="medium", on_cleanup=None):
super().__init__(timeout=DEFAULT_TIMEOUT)
self.player1 = player1
self.player2 = player2
Expand All @@ -504,6 +506,8 @@ def __init__(self, player1, player2, messages, is_ai_mode=False, difficulty="med
self.move_count = 0
self.move_history: List[tuple] = []
self.game_ended = False
self.on_cleanup = on_cleanup
self.cleaned_up = False

for col in range(COLUMNS):
self.add_item(Connect4Button(col, self))
Expand Down Expand Up @@ -673,13 +677,21 @@ async def end_game(self, interaction: discord.Interaction, winner: bool, board_s
else:
await interaction.response.edit_message(embed=embed, view=self)

if self.on_cleanup and not self.cleaned_up:
self.on_cleanup()
self.cleaned_up = True

self.stop()

async def on_timeout(self):
"""Wird aufgerufen wenn das Timeout erreicht wird"""
self.game_ended = True
for child in self.children:
child.disabled = True

if self.on_cleanup and not self.cleaned_up:
self.on_cleanup()
self.cleaned_up = True

# ───────────────────────────────────────────────
# >> Cog
Expand Down Expand Up @@ -712,8 +724,22 @@ async def connect4(

# AI mode
if opponent is None:
global ACTIVE_AI_GAMES
if ACTIVE_AI_GAMES >= MAX_AI_GAMES:
await ctx.respond(
"Tut uns leid, unsere KI wird gerade stark beansprucht. Bitte warte einen Moment damit unsere CPU last nicht in das Unendliche geht",
ephemeral=True
)
return

ACTIVE_AI_GAMES += 1

def cleanup():
global ACTIVE_AI_GAMES
ACTIVE_AI_GAMES -= 1

ai_user = ctx.guild.me
view = Connect4View(ctx.author, ai_user, messages, is_ai_mode=True, difficulty=difficulty)
view = Connect4View(ctx.author, ai_user, messages, is_ai_mode=True, difficulty=difficulty, on_cleanup=cleanup)

difficulty_info = DIFFICULTY_CONFIG.get(difficulty, DIFFICULTY_CONFIG["medium"])
difficulty_emoji = {"easy": "😊", "medium": "🤔", "hard": "😈"}
Expand Down
30 changes: 28 additions & 2 deletions src/bot/cogs/fun/tictactoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# >> Constants
# ───────────────────────────────────────────────
DEFAULT_TIMEOUT = 120
ACTIVE_AI_GAMES = 0
MAX_AI_GAMES = 5

DIFFICULTY_CONFIG = {
"easy": {
Expand Down Expand Up @@ -344,7 +346,7 @@ async def callback(self, interaction: discord.Interaction):
await interaction.response.edit_message(content=next_turn_msg, view=view)

class TicTacToeView(View):
def __init__(self, player1, player2, messages, is_ai_mode=False, difficulty="medium"):
def __init__(self, player1, player2, messages, is_ai_mode=False, difficulty="medium", on_cleanup=None):
super().__init__(timeout=DEFAULT_TIMEOUT)
self.player1 = player1
self.player2 = player2
Expand All @@ -356,6 +358,8 @@ def __init__(self, player1, player2, messages, is_ai_mode=False, difficulty="med
self.difficulty = difficulty
self.ai = TicTacToeAI(difficulty) if is_ai_mode else None
self.game_ended = False
self.on_cleanup = on_cleanup
self.cleaned_up = False

for x in range(3):
for y in range(3):
Expand Down Expand Up @@ -477,13 +481,21 @@ async def end_game(self, interaction: discord.Interaction, winner: Optional[str]
else:
await interaction.response.edit_message(embed=embed, view=self)

if self.on_cleanup and not self.cleaned_up:
self.on_cleanup()
self.cleaned_up = True

self.stop()

async def on_timeout(self):
"""Wird aufgerufen wenn das Timeout erreicht wird"""
self.game_ended = True
for child in self.children:
child.disabled = True

if self.on_cleanup and not self.cleaned_up:
self.on_cleanup()
self.cleaned_up = True

# ───────────────────────────────────────────────
# >> Cog
Expand Down Expand Up @@ -514,8 +526,22 @@ async def tictactoe(

# AI mode
if opponent is None:
global ACTIVE_AI_GAMES
if ACTIVE_AI_GAMES >= MAX_AI_GAMES:
await ctx.respond(
"Tut uns leid, unsere KI wird gerade stark beansprucht. Bitte warte einen Moment damit unsere CPU last nicht in das Unendliche geht",
ephemeral=True
)
return

ACTIVE_AI_GAMES += 1

def cleanup():
global ACTIVE_AI_GAMES
ACTIVE_AI_GAMES -= 1

ai_user = ctx.guild.me
view = TicTacToeView(ctx.author, ai_user, messages, is_ai_mode=True, difficulty=difficulty)
view = TicTacToeView(ctx.author, ai_user, messages, is_ai_mode=True, difficulty=difficulty, on_cleanup=cleanup)

difficulty_info = DIFFICULTY_CONFIG.get(difficulty, DIFFICULTY_CONFIG["medium"])
difficulty_emoji = {"easy": "😊", "medium": "🤔", "hard": "😈"}
Expand Down
18 changes: 18 additions & 0 deletions src/web/entries/agb.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import Nutzungsbedingungen from "../pages/Nutzungsbedingungen";
import "../index.css";

const queryClient = new QueryClient();

createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<Nutzungsbedingungen />
</BrowserRouter>
</QueryClientProvider>
</React.StrictMode>
);
18 changes: 18 additions & 0 deletions src/web/entries/datenschutz.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import Datenschutz from "../pages/Datenschutz";
import "../index.css";

const queryClient = new QueryClient();

createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<Datenschutz />
</BrowserRouter>
</QueryClientProvider>
</React.StrictMode>
);
18 changes: 18 additions & 0 deletions src/web/entries/impressum.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import Impressum from "../pages/Impressum";
import "../index.css";

const queryClient = new QueryClient();

createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<Impressum />
</BrowserRouter>
</QueryClientProvider>
</React.StrictMode>
);
8 changes: 8 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ export default defineConfig(({ mode }) => ({
// Optimierung für sauberen Code
minify: "esbuild",
reportCompressedSize: false,
rollupOptions: {
input: {
main: path.resolve(__dirname, "index.html"),
datenschutz: path.resolve(__dirname, "datenschutz.html"),
impressum: path.resolve(__dirname, "impressum.html"),
agb: path.resolve(__dirname, "agb.html"),
},
},
},
}));