diff --git a/app/routes/__pycache__/main_routes.cpython-311.pyc b/app/routes/__pycache__/main_routes.cpython-311.pyc index 506fedf..6d84cda 100644 Binary files a/app/routes/__pycache__/main_routes.cpython-311.pyc and b/app/routes/__pycache__/main_routes.cpython-311.pyc differ diff --git a/app/routes/main_routes.py b/app/routes/main_routes.py index 5909e0a..3524549 100644 --- a/app/routes/main_routes.py +++ b/app/routes/main_routes.py @@ -1,4 +1,4 @@ -from flask import Blueprint, render_template +from flask import Blueprint, jsonify, render_template, request from flask_login import login_required, current_user main_bp = Blueprint("main", __name__) @@ -11,3 +11,54 @@ def home(): @login_required def dashboard(): return render_template('dashboard.html', user=current_user) + +@main_bp.route("/check", methods=["POST"]) +def check(): + data = request.json + board = data["board"] + row = data["row"] + col = data["col"] + + for r in range(len(board)): + c = board[r] + + if c == -1 or r == row: + continue + + # gleiche Spalte + if c == col: + return jsonify({"valid": False}) + + # gleiche Diagonale + if abs(c - col) == abs(r - row): + return jsonify({"valid": False}) + + return jsonify({"valid": True}) + + +@main_bp.route("/solve") +def solve(): + n = 8 + solutions = [] + board = [-1] * n + + def is_safe(row, col): + for r in range(row): + c = board[r] + if c == col or abs(c - col) == abs(r - row): + return False + return True + + def backtrack(row): + if row == n: + solutions.append(board[:]) + return + + for col in range(n): + if is_safe(row, col): + board[row] = col + backtrack(row + 1) + board[row] = -1 + + backtrack(0) + return jsonify(solutions) \ No newline at end of file diff --git a/app/static/css/dashboard.css b/app/static/css/dashboard.css new file mode 100644 index 0000000..76ace99 --- /dev/null +++ b/app/static/css/dashboard.css @@ -0,0 +1,143 @@ +body { + margin: 0; + font-family: Arial, sans-serif; + background: #f5f7fa; +} + +/* 🔝 Navbar */ +.navbar { + display: flex; + justify-content: space-between; + align-items: center; + background: #1e293b; + color: white; + padding: 15px 30px; +} + +.navbar a { + color: white; + margin-left: 15px; + text-decoration: none; +} + +.navbar a:hover { + text-decoration: underline; +} + +/* 📦 Layout */ +.container { + max-width: 900px; + margin: 30px auto; + padding: 10px; +} + +/* 📇 Cards */ +.card { + background: white; + padding: 20px; + margin-bottom: 25px; + border-radius: 12px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); +} + +.game-card { + text-align: center; +} + +/* ♟️ Board */ +.board-grid { + display: grid; + grid-template-columns: 30px repeat(8, 60px); + grid-template-rows: 30px repeat(8, 60px); + margin: 20px auto; + width: max-content; + border: 6px solid #1e293b; + border-radius: 10px; + overflow: hidden; +} + +.label { + display: flex; + align-items: center; + justify-content: center; + font-weight: bold; + background: #aec8eb; + color: #1e293b; +} + + + +.cell { + width: 60px; + height: 60px; + display: flex; + align-items: center; + justify-content: center; + font-size: 30px; + cursor: pointer; + transition: 0.2s; +} + +.cell:hover { + transform: scale(1.05); +} + +.white { + background: #e2e8f0; +} + +.black { + background: #475569; + color: white; +} + +.invalid { + background: #ef4444 !important; +} + +/* 🎛️ Buttons */ +.controls { + margin-top: 15px; +} + +.btn { + padding: 10px 15px; + margin: 5px; + border: none; + border-radius: 8px; + background: #3b82f6; + color: white; + cursor: pointer; +} + +.btn:hover { + background: #2563eb; +} + +.btn.secondary { + background: #64748b; +} + +.btn.secondary:hover { + background: #475569; +} + +.btn.danger { + background: #ef4444; +} + +.btn.danger:hover { + background: #dc2626; +} + +#queenList { + list-style: none; + padding: 0; +} + +#queenList li { + padding: 5px; + background: #f1f5f9; + margin: 4px 0; + border-radius: 6px; +} \ No newline at end of file diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 96397ba..1884b05 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -1,51 +1,208 @@ - - + Dashboard + + -