Compare commits
7 Commits
worktree-a
...
v3.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef54ac201a | ||
|
|
0c0588f920 | ||
|
|
420928f11e | ||
|
|
bc9445f06e | ||
|
|
ea34ddf8e4 | ||
|
|
5408867921 | ||
|
|
a8b521f7f7 |
@@ -75,6 +75,9 @@ SECRET_KEY=
|
|||||||
# Enable invite-only mode (requires invitation to register)
|
# Enable invite-only mode (requires invitation to register)
|
||||||
INVITE_ONLY=true
|
INVITE_ONLY=true
|
||||||
|
|
||||||
|
# Allow visitors to request an invite from the login page (only relevant when INVITE_ONLY=true)
|
||||||
|
INVITE_REQUEST_ENABLED=false
|
||||||
|
|
||||||
# Metered open signups (public beta)
|
# Metered open signups (public beta)
|
||||||
# 0 = disabled (invite-only enforced), -1 = unlimited, N = max open signups per day
|
# 0 = disabled (invite-only enforced), -1 = unlimited, N = max open signups per day
|
||||||
# When set > 0, users can register without an invite code up to the daily limit.
|
# When set > 0, users can register without an invite code up to the daily limit.
|
||||||
|
|||||||
51
.gitea/workflows/deploy-prod.yml
Normal file
51
.gitea/workflows/deploy-prod.yml
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
name: Deploy Production
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Release tag to deploy (e.g. v3.3.0)'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: git.adlee.work/alee/golfgame
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Deploy to production
|
||||||
|
uses: appleboy/ssh-action@v1
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.PROD_HOST }}
|
||||||
|
username: root
|
||||||
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
envs: IMAGE
|
||||||
|
script: |
|
||||||
|
cd /opt/golfgame
|
||||||
|
|
||||||
|
# Pull the same image that passed staging
|
||||||
|
docker login git.adlee.work -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
docker pull $IMAGE:${{ github.event.inputs.tag }}
|
||||||
|
|
||||||
|
# Tag it so compose uses it
|
||||||
|
docker tag $IMAGE:${{ github.event.inputs.tag }} golfgame-app:latest
|
||||||
|
|
||||||
|
# Update code (for compose file / env changes)
|
||||||
|
git fetch origin && git checkout ${{ github.event.inputs.tag }}
|
||||||
|
|
||||||
|
# Restart app
|
||||||
|
docker compose -f docker-compose.prod.yml up -d app
|
||||||
|
|
||||||
|
# Wait for healthy
|
||||||
|
echo "Waiting for health check..."
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
if docker compose -f docker-compose.prod.yml ps app | grep -q "healthy"; then
|
||||||
|
echo "Production deploy successful — ${{ github.event.inputs.tag }}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "CRITICAL: app not healthy after 60s"
|
||||||
|
docker compose -f docker-compose.prod.yml logs --tail=30 app
|
||||||
|
exit 1
|
||||||
70
.gitea/workflows/deploy-staging.yml
Normal file
70
.gitea/workflows/deploy-staging.yml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
name: Build & Deploy Staging
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: git.adlee.work/alee/golfgame
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Log in to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.adlee.work
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ env.IMAGE }}:${{ github.ref_name }}
|
||||||
|
${{ env.IMAGE }}:latest
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Deploy to staging
|
||||||
|
uses: appleboy/ssh-action@v1
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.STAGING_HOST }}
|
||||||
|
username: root
|
||||||
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
envs: IMAGE
|
||||||
|
script: |
|
||||||
|
cd /opt/golfgame
|
||||||
|
|
||||||
|
# Pull the pre-built image
|
||||||
|
docker login git.adlee.work -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
docker pull $IMAGE:${{ github.ref_name }}
|
||||||
|
|
||||||
|
# Tag it so compose uses it
|
||||||
|
docker tag $IMAGE:${{ github.ref_name }} golfgame-app:latest
|
||||||
|
|
||||||
|
# Update code (for compose file / env changes)
|
||||||
|
git fetch origin && git checkout ${{ github.ref_name }}
|
||||||
|
|
||||||
|
# Restart app (no --build, image is pre-built)
|
||||||
|
docker compose -f docker-compose.staging.yml up -d app
|
||||||
|
|
||||||
|
# Wait for healthy
|
||||||
|
echo "Waiting for health check..."
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
if docker compose -f docker-compose.staging.yml ps app | grep -q "healthy"; then
|
||||||
|
echo "Staging deploy successful — ${{ github.ref_name }}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "WARNING: app not healthy after 60s"
|
||||||
|
docker compose -f docker-compose.staging.yml logs --tail=20 app
|
||||||
|
exit 1
|
||||||
24
.gitignore
vendored
24
.gitignore
vendored
@@ -136,7 +136,31 @@ celerybeat.pid
|
|||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
.envrc
|
.envrc
|
||||||
|
|
||||||
|
# Private keys and certificates
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
*.p12
|
||||||
|
*.pfx
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
|
|
||||||
|
# Service credentials
|
||||||
|
credentials.json
|
||||||
|
service-account.json
|
||||||
|
*-credentials.json
|
||||||
|
|
||||||
|
# SSH keys
|
||||||
|
id_rsa
|
||||||
|
id_ecdsa
|
||||||
|
id_ed25519
|
||||||
|
|
||||||
|
# Other sensitive files
|
||||||
|
*.secrets
|
||||||
|
.htpasswd
|
||||||
.venv
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
|
|||||||
304
.secrets.baseline
Normal file
304
.secrets.baseline
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
{
|
||||||
|
"version": "1.5.0",
|
||||||
|
"plugins_used": [
|
||||||
|
{
|
||||||
|
"name": "ArtifactoryDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AWSKeyDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AzureStorageKeyDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Base64HighEntropyString",
|
||||||
|
"limit": 4.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BasicAuthDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "CloudantDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "DiscordBotTokenDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GitHubTokenDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GitLabTokenDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "HexHighEntropyString",
|
||||||
|
"limit": 3.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "IbmCloudIamDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "IbmCosHmacDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "IPPublicDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "JwtTokenDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "KeywordDetector",
|
||||||
|
"keyword_exclude": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MailchimpDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "NpmDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "OpenAIDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "PrivateKeyDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "PypiTokenDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SendGridDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SlackDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SoftlayerDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SquareOAuthDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "StripeDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "TelegramBotTokenDetector"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "TwilioKeyDetector"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filters_used": [
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.common.is_baseline_file",
|
||||||
|
"filename": ".secrets.baseline"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
|
||||||
|
"min_level": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_lock_file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_sequential_string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_swagger_file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.heuristic.is_templated_secret"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "detect_secrets.filters.regex.should_exclude_file",
|
||||||
|
"pattern": [
|
||||||
|
"\\.env\\.example$",
|
||||||
|
"server/\\.env\\.example$"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"results": {
|
||||||
|
"INSTALL.md": [
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "INSTALL.md",
|
||||||
|
"hashed_secret": "365e24291fd19bba10a0d8504c0ed90d5c8bef7f",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 75
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Basic Auth Credentials",
|
||||||
|
"filename": "INSTALL.md",
|
||||||
|
"hashed_secret": "4f4944a7117fd2e95169da2b40af33b68a65a161",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 114
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "INSTALL.md",
|
||||||
|
"hashed_secret": "c35bdb821a941808a150db95d0f934f449bbff17",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 182
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Basic Auth Credentials",
|
||||||
|
"filename": "INSTALL.md",
|
||||||
|
"hashed_secret": "c35bdb821a941808a150db95d0f934f449bbff17",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 225
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "INSTALL.md",
|
||||||
|
"hashed_secret": "001c1654cb8dff7c4ddb1ae6d2203d0dd15a6096",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 391
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "INSTALL.md",
|
||||||
|
"hashed_secret": "53fe8c55272f9c3ceebb5e6058788e8981a359cb",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 397
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"docker-compose.dev.yml": [
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "docker-compose.dev.yml",
|
||||||
|
"hashed_secret": "4f4944a7117fd2e95169da2b40af33b68a65a161",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 44
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"docs/v2/V2_BUILD_PLAN.md": [
|
||||||
|
{
|
||||||
|
"type": "Basic Auth Credentials",
|
||||||
|
"filename": "docs/v2/V2_BUILD_PLAN.md",
|
||||||
|
"hashed_secret": "e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 301
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scripts/docker-build.sh": [
|
||||||
|
{
|
||||||
|
"type": "Basic Auth Credentials",
|
||||||
|
"filename": "scripts/docker-build.sh",
|
||||||
|
"hashed_secret": "9d4e1e23bd5b727046a9e3b4b7db57bd8d6ee684",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 40
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scripts/install.sh": [
|
||||||
|
{
|
||||||
|
"type": "Basic Auth Credentials",
|
||||||
|
"filename": "scripts/install.sh",
|
||||||
|
"hashed_secret": "4f4944a7117fd2e95169da2b40af33b68a65a161",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 156
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Basic Auth Credentials",
|
||||||
|
"filename": "scripts/install.sh",
|
||||||
|
"hashed_secret": "7205a0abf00d1daec13c63ece029057c974795a9",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 267
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"server/RULES.md": [
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "server/RULES.md",
|
||||||
|
"hashed_secret": "a6778f1880744bd1a342a8e3789135412d8f9da2",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 904
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "server/RULES.md",
|
||||||
|
"hashed_secret": "aafdc23870ecbcd3d557b6423a8982134e17927e",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 949
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"server/config.py": [
|
||||||
|
{
|
||||||
|
"type": "Basic Auth Credentials",
|
||||||
|
"filename": "server/config.py",
|
||||||
|
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 124
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"server/game_analyzer.py": [
|
||||||
|
{
|
||||||
|
"type": "Basic Auth Credentials",
|
||||||
|
"filename": "server/game_analyzer.py",
|
||||||
|
"hashed_secret": "4f4944a7117fd2e95169da2b40af33b68a65a161",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 617
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"server/test_auth.py": [
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "server/test_auth.py",
|
||||||
|
"hashed_secret": "cbfdac6008f9cab4083784cbd1874f76618d2a97",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 39
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "server/test_auth.py",
|
||||||
|
"hashed_secret": "f0578f1e7174b1a41c4ea8c6e17f7a8a3b88c92a",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 51
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "server/test_auth.py",
|
||||||
|
"hashed_secret": "8be52126a6fde450a7162a3651d589bb51e9579d",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 65
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "server/test_auth.py",
|
||||||
|
"hashed_secret": "74913f5cd5f61ec0bcfdb775414c2fb3d161b620",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 75
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "server/test_auth.py",
|
||||||
|
"hashed_secret": "9d4e1e23bd5b727046a9e3b4b7db57bd8d6ee684",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 92
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "server/test_auth.py",
|
||||||
|
"hashed_secret": "1e99b09f6eb835305555cc43c3e0768b1a39226b",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 104
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generated_at": "2026-04-05T13:26:03Z"
|
||||||
|
}
|
||||||
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -203,4 +203,4 @@ From testing (1000+ games):
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
GPL-3.0-or-later — see [LICENSE](LICENSE) for the full text.
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
<a href="#" data-panel="users" class="nav-link">Users</a>
|
<a href="#" data-panel="users" class="nav-link">Users</a>
|
||||||
<a href="#" data-panel="games" class="nav-link">Games</a>
|
<a href="#" data-panel="games" class="nav-link">Games</a>
|
||||||
<a href="#" data-panel="invites" class="nav-link">Invites</a>
|
<a href="#" data-panel="invites" class="nav-link">Invites</a>
|
||||||
|
<a href="#" data-panel="invite-requests" class="nav-link">Requests</a>
|
||||||
<a href="#" data-panel="audit" class="nav-link">Audit Log</a>
|
<a href="#" data-panel="audit" class="nav-link">Audit Log</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-user">
|
<div class="nav-user">
|
||||||
@@ -191,6 +192,35 @@
|
|||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Invite Requests Panel -->
|
||||||
|
<section id="invite-requests-panel" class="panel hidden">
|
||||||
|
<h2>Invite Requests</h2>
|
||||||
|
<div class="panel-toolbar">
|
||||||
|
<div class="filter-bar">
|
||||||
|
<select id="request-status-filter">
|
||||||
|
<option value="pending">Pending</option>
|
||||||
|
<option value="">All</option>
|
||||||
|
<option value="approved">Approved</option>
|
||||||
|
<option value="denied">Denied</option>
|
||||||
|
</select>
|
||||||
|
<button id="request-filter-btn" class="btn">Filter</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table id="invite-requests-table" class="data-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Message</th>
|
||||||
|
<th>Submitted</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Audit Log Panel -->
|
<!-- Audit Log Panel -->
|
||||||
<section id="audit-panel" class="panel hidden">
|
<section id="audit-panel" class="panel hidden">
|
||||||
<h2>Audit Log</h2>
|
<h2>Audit Log</h2>
|
||||||
@@ -207,12 +237,15 @@
|
|||||||
<option value="end_game">End Game</option>
|
<option value="end_game">End Game</option>
|
||||||
<option value="create_invite">Create Invite</option>
|
<option value="create_invite">Create Invite</option>
|
||||||
<option value="revoke_invite">Revoke Invite</option>
|
<option value="revoke_invite">Revoke Invite</option>
|
||||||
|
<option value="approve_invite_request">Approve Request</option>
|
||||||
|
<option value="deny_invite_request">Deny Request</option>
|
||||||
</select>
|
</select>
|
||||||
<select id="audit-target-filter">
|
<select id="audit-target-filter">
|
||||||
<option value="">All Targets</option>
|
<option value="">All Targets</option>
|
||||||
<option value="user">Users</option>
|
<option value="user">Users</option>
|
||||||
<option value="game">Games</option>
|
<option value="game">Games</option>
|
||||||
<option value="invite_code">Invites</option>
|
<option value="invite_code">Invites</option>
|
||||||
|
<option value="invite_request">Invite Requests</option>
|
||||||
</select>
|
</select>
|
||||||
<button id="audit-filter-btn" class="btn">Filter</button>
|
<button id="audit-filter-btn" class="btn">Filter</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
/**
|
/**
|
||||||
* Golf Admin Dashboard
|
* Golf Admin Dashboard
|
||||||
* JavaScript for admin interface functionality
|
* JavaScript for admin interface functionality
|
||||||
@@ -197,6 +198,9 @@ function showPanel(panelId) {
|
|||||||
case 'invites':
|
case 'invites':
|
||||||
loadInvites();
|
loadInvites();
|
||||||
break;
|
break;
|
||||||
|
case 'invite-requests':
|
||||||
|
loadInviteRequests();
|
||||||
|
break;
|
||||||
case 'audit':
|
case 'audit':
|
||||||
loadAuditLog();
|
loadAuditLog();
|
||||||
break;
|
break;
|
||||||
@@ -642,6 +646,80 @@ async function promptRevokeInvite(code) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Invite Requests
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
async function loadInviteRequests() {
|
||||||
|
const status = document.getElementById('request-status-filter').value;
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (status) params.set('status', status);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await apiRequest(`/api/admin/invite-requests?${params}`);
|
||||||
|
const tbody = document.querySelector('#invite-requests-table tbody');
|
||||||
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
|
if (data.requests.length === 0) {
|
||||||
|
tbody.innerHTML = '<tr><td colspan="6" class="text-muted">No invite requests</td></tr>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.requests.forEach(req => {
|
||||||
|
const statusBadge = req.status === 'approved'
|
||||||
|
? '<span class="badge badge-success">Approved</span>'
|
||||||
|
: req.status === 'denied'
|
||||||
|
? '<span class="badge badge-danger">Denied</span>'
|
||||||
|
: '<span class="badge badge-warning">Pending</span>';
|
||||||
|
|
||||||
|
const actions = req.status === 'pending'
|
||||||
|
? `<button class="btn btn-small btn-primary" data-action="approve-request" data-id="${req.id}">Approve</button>
|
||||||
|
<button class="btn btn-small btn-danger" data-action="deny-request" data-id="${req.id}">Deny</button>`
|
||||||
|
: `<span class="text-muted">${req.reviewed_by_username || '-'}</span>`;
|
||||||
|
|
||||||
|
tbody.innerHTML += `
|
||||||
|
<tr>
|
||||||
|
<td>${escapeHtml(req.name)}</td>
|
||||||
|
<td>${escapeHtml(req.email)}</td>
|
||||||
|
<td>${req.message ? escapeHtml(req.message).substring(0, 80) : '<span class="text-muted">-</span>'}</td>
|
||||||
|
<td>${formatDate(req.created_at)}</td>
|
||||||
|
<td>${statusBadge}</td>
|
||||||
|
<td>${actions}</td>
|
||||||
|
</tr>`;
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
showToast('Failed to load invite requests: ' + error.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleApproveRequest(requestId) {
|
||||||
|
if (!confirm('Approve this invite request? An invite code will be created and emailed to the requester.')) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await apiRequest(`/api/admin/invite-requests/${requestId}/approve`, {
|
||||||
|
method: 'POST',
|
||||||
|
});
|
||||||
|
showToast(`Request approved! Invite code: ${data.code}`, 'success');
|
||||||
|
loadInviteRequests();
|
||||||
|
} catch (error) {
|
||||||
|
showToast('Failed to approve request: ' + error.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDenyRequest(requestId) {
|
||||||
|
if (!confirm('Deny this invite request? The requester will be notified.')) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await apiRequest(`/api/admin/invite-requests/${requestId}/deny`, {
|
||||||
|
method: 'POST',
|
||||||
|
});
|
||||||
|
showToast('Request denied', 'success');
|
||||||
|
loadInviteRequests();
|
||||||
|
} catch (error) {
|
||||||
|
showToast('Failed to deny request: ' + error.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Auth
|
// Auth
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
@@ -785,6 +863,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
document.getElementById('create-invite-btn').addEventListener('click', handleCreateInvite);
|
document.getElementById('create-invite-btn').addEventListener('click', handleCreateInvite);
|
||||||
document.getElementById('include-expired').addEventListener('change', loadInvites);
|
document.getElementById('include-expired').addEventListener('change', loadInvites);
|
||||||
|
|
||||||
|
// Invite requests panel
|
||||||
|
document.getElementById('request-filter-btn').addEventListener('click', loadInviteRequests);
|
||||||
|
|
||||||
// Audit panel
|
// Audit panel
|
||||||
document.getElementById('audit-filter-btn').addEventListener('click', () => {
|
document.getElementById('audit-filter-btn').addEventListener('click', () => {
|
||||||
auditPage = 0;
|
auditPage = 0;
|
||||||
@@ -825,6 +906,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
else if (action === 'end-game') promptEndGame(btn.dataset.id);
|
else if (action === 'end-game') promptEndGame(btn.dataset.id);
|
||||||
else if (action === 'copy-invite') copyInviteLink(btn.dataset.code);
|
else if (action === 'copy-invite') copyInviteLink(btn.dataset.code);
|
||||||
else if (action === 'revoke-invite') promptRevokeInvite(btn.dataset.code);
|
else if (action === 'revoke-invite') promptRevokeInvite(btn.dataset.code);
|
||||||
|
else if (action === 'approve-request') handleApproveRequest(parseInt(btn.dataset.id));
|
||||||
|
else if (action === 'deny-request') handleDenyRequest(parseInt(btn.dataset.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check auth on load
|
// Check auth on load
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
// AnimationQueue - Sequences card animations properly
|
// AnimationQueue - Sequences card animations properly
|
||||||
// Ensures animations play in order without overlap
|
// Ensures animations play in order without overlap
|
||||||
|
|
||||||
|
|||||||
142
client/app.js
142
client/app.js
@@ -81,6 +81,7 @@ class GolfGame {
|
|||||||
this.initCardTooltips();
|
this.initCardTooltips();
|
||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
this.initMobileDetection();
|
this.initMobileDetection();
|
||||||
|
this.initDesktopScorecard();
|
||||||
this.checkUrlParams();
|
this.checkUrlParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,9 +112,11 @@ class GolfGame {
|
|||||||
this.isMobile = e.matches;
|
this.isMobile = e.matches;
|
||||||
document.body.classList.toggle('mobile-portrait', e.matches);
|
document.body.classList.toggle('mobile-portrait', e.matches);
|
||||||
setAppHeight();
|
setAppHeight();
|
||||||
// Close any open drawers on layout change
|
// Close any open drawers/overlays on layout change
|
||||||
if (!e.matches) {
|
if (!e.matches) {
|
||||||
this.closeDrawers();
|
this.closeDrawers();
|
||||||
|
} else {
|
||||||
|
this.closeDesktopScorecard();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mql.addEventListener('change', update);
|
mql.addEventListener('change', update);
|
||||||
@@ -154,6 +157,31 @@ class GolfGame {
|
|||||||
if (bottomBar) bottomBar.classList.remove('hidden');
|
if (bottomBar) bottomBar.classList.remove('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initDesktopScorecard() {
|
||||||
|
if (!this.desktopScorecardBtn) return;
|
||||||
|
|
||||||
|
this.desktopScorecardBtn.addEventListener('click', () => {
|
||||||
|
const isOpen = this.desktopScorecardOverlay.classList.contains('open');
|
||||||
|
if (isOpen) {
|
||||||
|
this.closeDesktopScorecard();
|
||||||
|
} else {
|
||||||
|
this.desktopScorecardOverlay.classList.add('open');
|
||||||
|
this.desktopScorecardBtn.classList.add('active');
|
||||||
|
this.desktopScorecardBackdrop.classList.add('visible');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.desktopScorecardBackdrop.addEventListener('click', () => {
|
||||||
|
this.closeDesktopScorecard();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDesktopScorecard() {
|
||||||
|
if (this.desktopScorecardOverlay) this.desktopScorecardOverlay.classList.remove('open');
|
||||||
|
if (this.desktopScorecardBtn) this.desktopScorecardBtn.classList.remove('active');
|
||||||
|
if (this.desktopScorecardBackdrop) this.desktopScorecardBackdrop.classList.remove('visible');
|
||||||
|
}
|
||||||
|
|
||||||
initAudio() {
|
initAudio() {
|
||||||
// Initialize audio context on first user interaction
|
// Initialize audio context on first user interaction
|
||||||
const initCtx = () => {
|
const initCtx = () => {
|
||||||
@@ -544,6 +572,13 @@ class GolfGame {
|
|||||||
this.gameUsername = document.getElementById('game-username');
|
this.gameUsername = document.getElementById('game-username');
|
||||||
this.gameLogoutBtn = document.getElementById('game-logout-btn');
|
this.gameLogoutBtn = document.getElementById('game-logout-btn');
|
||||||
this.authBar = document.getElementById('auth-bar');
|
this.authBar = document.getElementById('auth-bar');
|
||||||
|
|
||||||
|
// Desktop scorecard overlay elements
|
||||||
|
this.desktopScorecardBtn = document.getElementById('desktop-scorecard-btn');
|
||||||
|
this.desktopScorecardOverlay = document.getElementById('desktop-scorecard-overlay');
|
||||||
|
this.desktopScorecardBackdrop = document.getElementById('desktop-scorecard-backdrop');
|
||||||
|
this.desktopStandingsList = document.getElementById('desktop-standings-list');
|
||||||
|
this.desktopScoreTable = document.getElementById('desktop-score-table')?.querySelector('tbody');
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvents() {
|
bindEvents() {
|
||||||
@@ -1464,12 +1499,8 @@ class GolfGame {
|
|||||||
this.swapAnimationCardEl = handCardEl;
|
this.swapAnimationCardEl = handCardEl;
|
||||||
this.swapAnimationHandCardEl = handCardEl;
|
this.swapAnimationHandCardEl = handCardEl;
|
||||||
|
|
||||||
// Hide originals and UI during animation
|
// Hide discard button during animation (held card hidden later by onStart)
|
||||||
handCardEl.classList.add('swap-out');
|
|
||||||
this.discardBtn.classList.add('hidden');
|
this.discardBtn.classList.add('hidden');
|
||||||
if (this.heldCardFloating) {
|
|
||||||
this.heldCardFloating.style.visibility = 'hidden';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store drawn card data before clearing
|
// Store drawn card data before clearing
|
||||||
const drawnCardData = this.drawnCard;
|
const drawnCardData = this.drawnCard;
|
||||||
@@ -1492,6 +1523,12 @@ class GolfGame {
|
|||||||
{
|
{
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
wasHandFaceDown: false,
|
wasHandFaceDown: false,
|
||||||
|
onStart: () => {
|
||||||
|
handCardEl.classList.add('swap-out');
|
||||||
|
if (this.heldCardFloating) {
|
||||||
|
this.heldCardFloating.style.visibility = 'hidden';
|
||||||
|
}
|
||||||
|
},
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
handCardEl.classList.remove('swap-out');
|
handCardEl.classList.remove('swap-out');
|
||||||
if (this.heldCardFloating) {
|
if (this.heldCardFloating) {
|
||||||
@@ -1555,6 +1592,12 @@ class GolfGame {
|
|||||||
{
|
{
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
wasHandFaceDown: true,
|
wasHandFaceDown: true,
|
||||||
|
onStart: () => {
|
||||||
|
if (handCardEl) handCardEl.classList.add('swap-out');
|
||||||
|
if (this.heldCardFloating) {
|
||||||
|
this.heldCardFloating.style.visibility = 'hidden';
|
||||||
|
}
|
||||||
|
},
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
if (handCardEl) handCardEl.classList.remove('swap-out');
|
if (handCardEl) handCardEl.classList.remove('swap-out');
|
||||||
if (this.heldCardFloating) {
|
if (this.heldCardFloating) {
|
||||||
@@ -2887,9 +2930,6 @@ class GolfGame {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide the source card during animation
|
|
||||||
sourceCardEl.classList.add('swap-out');
|
|
||||||
|
|
||||||
// Use unified swap animation
|
// Use unified swap animation
|
||||||
if (window.cardAnimations) {
|
if (window.cardAnimations) {
|
||||||
const heldRect = window.cardAnimations.getHoldingRect();
|
const heldRect = window.cardAnimations.getHoldingRect();
|
||||||
@@ -2902,6 +2942,9 @@ class GolfGame {
|
|||||||
{
|
{
|
||||||
rotation: sourceRotation,
|
rotation: sourceRotation,
|
||||||
wasHandFaceDown: !wasFaceUp,
|
wasHandFaceDown: !wasFaceUp,
|
||||||
|
onStart: () => {
|
||||||
|
sourceCardEl.classList.add('swap-out');
|
||||||
|
},
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
if (sourceCardEl) sourceCardEl.classList.remove('swap-out');
|
if (sourceCardEl) sourceCardEl.classList.remove('swap-out');
|
||||||
this.opponentSwapAnimation = null;
|
this.opponentSwapAnimation = null;
|
||||||
@@ -4347,6 +4390,11 @@ class GolfGame {
|
|||||||
`;
|
`;
|
||||||
this.scoreTable.appendChild(tr);
|
this.scoreTable.appendChild(tr);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Mirror to desktop overlay
|
||||||
|
if (this.desktopScoreTable) {
|
||||||
|
this.desktopScoreTable.innerHTML = this.scoreTable.innerHTML;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStandings() {
|
updateStandings() {
|
||||||
@@ -4384,7 +4432,7 @@ class GolfGame {
|
|||||||
return `<div class="rank-row ${holesRank === 0 && p.rounds_won > 0 ? 'leader' : ''}"><span class="rank-pos">${medal}</span><span class="rank-name">${name}</span><span class="rank-val">${p.rounds_won} wins</span></div>`;
|
return `<div class="rank-row ${holesRank === 0 && p.rounds_won > 0 ? 'leader' : ''}"><span class="rank-pos">${medal}</span><span class="rank-name">${name}</span><span class="rank-val">${p.rounds_won} wins</span></div>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
this.standingsList.innerHTML = `
|
const standingsContent = `
|
||||||
<div class="standings-section">
|
<div class="standings-section">
|
||||||
<div class="standings-title">By Score</div>
|
<div class="standings-title">By Score</div>
|
||||||
${pointsHtml}
|
${pointsHtml}
|
||||||
@@ -4394,6 +4442,10 @@ class GolfGame {
|
|||||||
${holesHtml}
|
${holesHtml}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
this.standingsList.innerHTML = standingsContent;
|
||||||
|
if (this.desktopStandingsList) {
|
||||||
|
this.desktopStandingsList.innerHTML = standingsContent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCard(card, clickable, selected) {
|
renderCard(card, clickable, selected) {
|
||||||
@@ -4473,6 +4525,11 @@ class GolfGame {
|
|||||||
this.scoreTable.appendChild(tr);
|
this.scoreTable.appendChild(tr);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Mirror to desktop overlay
|
||||||
|
if (this.desktopScoreTable) {
|
||||||
|
this.desktopScoreTable.innerHTML = this.scoreTable.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
// Show rankings announcement only for final results
|
// Show rankings announcement only for final results
|
||||||
const existingAnnouncement = document.getElementById('rankings-announcement');
|
const existingAnnouncement = document.getElementById('rankings-announcement');
|
||||||
if (existingAnnouncement) existingAnnouncement.remove();
|
if (existingAnnouncement) existingAnnouncement.remove();
|
||||||
@@ -4810,6 +4867,15 @@ class AuthManager {
|
|||||||
this.resetPasswordConfirm = document.getElementById('reset-password-confirm');
|
this.resetPasswordConfirm = document.getElementById('reset-password-confirm');
|
||||||
this.resetError = document.getElementById('reset-error');
|
this.resetError = document.getElementById('reset-error');
|
||||||
this.resetSuccess = document.getElementById('reset-success');
|
this.resetSuccess = document.getElementById('reset-success');
|
||||||
|
this.requestInviteContainer = document.getElementById('request-invite-container');
|
||||||
|
this.requestInviteForm = document.getElementById('request-invite-form');
|
||||||
|
this.requestInviteName = document.getElementById('request-invite-name');
|
||||||
|
this.requestInviteEmail = document.getElementById('request-invite-email');
|
||||||
|
this.requestInviteMessage = document.getElementById('request-invite-message');
|
||||||
|
this.requestInviteError = document.getElementById('request-invite-error');
|
||||||
|
this.requestInviteSuccess = document.getElementById('request-invite-success');
|
||||||
|
this.requestBackSignup = document.getElementById('request-back-signup');
|
||||||
|
this.requestBackLogin = document.getElementById('request-back-login');
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvents() {
|
bindEvents() {
|
||||||
@@ -4840,6 +4906,15 @@ class AuthManager {
|
|||||||
});
|
});
|
||||||
this.forgotForm?.addEventListener('submit', (e) => this.handleForgotPassword(e));
|
this.forgotForm?.addEventListener('submit', (e) => this.handleForgotPassword(e));
|
||||||
this.resetForm?.addEventListener('submit', (e) => this.handleResetPassword(e));
|
this.resetForm?.addEventListener('submit', (e) => this.handleResetPassword(e));
|
||||||
|
this.requestInviteForm?.addEventListener('submit', (e) => this.handleRequestInvite(e));
|
||||||
|
this.requestBackSignup?.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
this.showForm('signup');
|
||||||
|
});
|
||||||
|
this.requestBackLogin?.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
this.showForm('login');
|
||||||
|
});
|
||||||
|
|
||||||
// Check URL for reset token or invite code on page load
|
// Check URL for reset token or invite code on page load
|
||||||
this.checkResetToken();
|
this.checkResetToken();
|
||||||
@@ -4865,6 +4940,7 @@ class AuthManager {
|
|||||||
this.signupFormContainer.classList.add('hidden');
|
this.signupFormContainer.classList.add('hidden');
|
||||||
this.forgotFormContainer?.classList.add('hidden');
|
this.forgotFormContainer?.classList.add('hidden');
|
||||||
this.resetFormContainer?.classList.add('hidden');
|
this.resetFormContainer?.classList.add('hidden');
|
||||||
|
this.requestInviteContainer?.classList.add('hidden');
|
||||||
this.clearErrors();
|
this.clearErrors();
|
||||||
|
|
||||||
if (form === 'login') {
|
if (form === 'login') {
|
||||||
@@ -4879,6 +4955,9 @@ class AuthManager {
|
|||||||
} else if (form === 'reset') {
|
} else if (form === 'reset') {
|
||||||
this.resetFormContainer?.classList.remove('hidden');
|
this.resetFormContainer?.classList.remove('hidden');
|
||||||
this.resetPassword?.focus();
|
this.resetPassword?.focus();
|
||||||
|
} else if (form === 'request-invite') {
|
||||||
|
this.requestInviteContainer?.classList.remove('hidden');
|
||||||
|
this.requestInviteName?.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4895,6 +4974,8 @@ class AuthManager {
|
|||||||
if (this.forgotSuccess) this.forgotSuccess.textContent = '';
|
if (this.forgotSuccess) this.forgotSuccess.textContent = '';
|
||||||
if (this.resetError) this.resetError.textContent = '';
|
if (this.resetError) this.resetError.textContent = '';
|
||||||
if (this.resetSuccess) this.resetSuccess.textContent = '';
|
if (this.resetSuccess) this.resetSuccess.textContent = '';
|
||||||
|
if (this.requestInviteError) this.requestInviteError.textContent = '';
|
||||||
|
if (this.requestInviteSuccess) this.requestInviteSuccess.textContent = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleLogin(e) {
|
async handleLogin(e) {
|
||||||
@@ -5031,7 +5112,17 @@ class AuthManager {
|
|||||||
if (invite_required) {
|
if (invite_required) {
|
||||||
this.signupInviteCode.required = true;
|
this.signupInviteCode.required = true;
|
||||||
this.signupInviteCode.placeholder = 'Invite Code (required)';
|
this.signupInviteCode.placeholder = 'Invite Code (required)';
|
||||||
if (this.inviteCodeHint) this.inviteCodeHint.textContent = '';
|
if (this.inviteCodeHint) {
|
||||||
|
if (this.signupInfo.invite_request_enabled) {
|
||||||
|
this.inviteCodeHint.innerHTML = 'Don\'t have one? <a href="#" id="show-request-invite">Request an invite</a>';
|
||||||
|
document.getElementById('show-request-invite')?.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
this.showForm('request-invite');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.inviteCodeHint.textContent = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (open_signups_enabled) {
|
} else if (open_signups_enabled) {
|
||||||
this.signupInviteCode.required = false;
|
this.signupInviteCode.required = false;
|
||||||
this.signupInviteCode.placeholder = 'Invite Code (optional)';
|
this.signupInviteCode.placeholder = 'Invite Code (optional)';
|
||||||
@@ -5108,4 +5199,33 @@ class AuthManager {
|
|||||||
this.resetError.textContent = 'Connection error';
|
this.resetError.textContent = 'Connection error';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async handleRequestInvite(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.clearErrors();
|
||||||
|
|
||||||
|
const name = this.requestInviteName.value.trim();
|
||||||
|
const email = this.requestInviteEmail.value.trim();
|
||||||
|
const message = this.requestInviteMessage.value.trim() || null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/auth/request-invite', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ name, email, message }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
this.requestInviteError.textContent = data.detail || 'Request failed';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.requestInviteSuccess.textContent = data.message;
|
||||||
|
this.requestInviteForm.reset();
|
||||||
|
} catch (err) {
|
||||||
|
this.requestInviteError.textContent = 'Connection error';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
// CardAnimations - Unified anime.js-based animation system
|
// CardAnimations - Unified anime.js-based animation system
|
||||||
// Replaces draw-animations.js and handles ALL card animations
|
// Replaces draw-animations.js and handles ALL card animations
|
||||||
|
|
||||||
@@ -1105,7 +1106,7 @@ class CardAnimations {
|
|||||||
// heldRect: position of the held card (or null to use default holding position)
|
// heldRect: position of the held card (or null to use default holding position)
|
||||||
// options: { rotation, wasHandFaceDown, onComplete }
|
// options: { rotation, wasHandFaceDown, onComplete }
|
||||||
animateUnifiedSwap(handCardData, heldCardData, handRect, heldRect, options = {}) {
|
animateUnifiedSwap(handCardData, heldCardData, handRect, heldRect, options = {}) {
|
||||||
const { rotation = 0, wasHandFaceDown = false, onComplete } = options;
|
const { rotation = 0, wasHandFaceDown = false, onComplete, onStart } = options;
|
||||||
const T = window.TIMING?.swap || { lift: 100, arc: 320, settle: 100 };
|
const T = window.TIMING?.swap || { lift: 100, arc: 320, settle: 100 };
|
||||||
const discardRect = this.getDiscardRect();
|
const discardRect = this.getDiscardRect();
|
||||||
|
|
||||||
@@ -1137,15 +1138,15 @@ class CardAnimations {
|
|||||||
delete el.dataset.animating;
|
delete el.dataset.animating;
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
this._runUnifiedSwap(handCardData, heldCardData, handRect, heldRect, discardRect, T, rotation, wasHandFaceDown, onComplete);
|
this._runUnifiedSwap(handCardData, heldCardData, handRect, heldRect, discardRect, T, rotation, wasHandFaceDown, onComplete, onStart);
|
||||||
}, 350);
|
}, 350);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._runUnifiedSwap(handCardData, heldCardData, handRect, heldRect, discardRect, T, rotation, wasHandFaceDown, onComplete);
|
this._runUnifiedSwap(handCardData, heldCardData, handRect, heldRect, discardRect, T, rotation, wasHandFaceDown, onComplete, onStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
_runUnifiedSwap(handCardData, heldCardData, handRect, heldRect, discardRect, T, rotation, wasHandFaceDown, onComplete) {
|
_runUnifiedSwap(handCardData, heldCardData, handRect, heldRect, discardRect, T, rotation, wasHandFaceDown, onComplete, onStart) {
|
||||||
// Create the two traveling cards
|
// Create the two traveling cards
|
||||||
const travelingHand = this.createCardFromData(handCardData, handRect, rotation);
|
const travelingHand = this.createCardFromData(handCardData, handRect, rotation);
|
||||||
const travelingHeld = this.createCardFromData(heldCardData, heldRect, 0);
|
const travelingHeld = this.createCardFromData(heldCardData, heldRect, 0);
|
||||||
@@ -1154,6 +1155,9 @@ class CardAnimations {
|
|||||||
document.body.appendChild(travelingHand);
|
document.body.appendChild(travelingHand);
|
||||||
document.body.appendChild(travelingHeld);
|
document.body.appendChild(travelingHeld);
|
||||||
|
|
||||||
|
// Now that overlays cover the originals, hide them
|
||||||
|
if (onStart) onStart();
|
||||||
|
|
||||||
this.playSound('card');
|
this.playSound('card');
|
||||||
|
|
||||||
// If hand card was face-down, flip it first
|
// If hand card was face-down, flip it first
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
// CardManager - Manages persistent card DOM elements
|
// CardManager - Manages persistent card DOM elements
|
||||||
// Cards are REAL elements that exist in ONE place and move between locations
|
// Cards are REAL elements that exist in ONE place and move between locations
|
||||||
|
|
||||||
|
|||||||
@@ -322,38 +322,38 @@
|
|||||||
<div class="game-table">
|
<div class="game-table">
|
||||||
<div id="opponents-row" class="opponents-row"></div>
|
<div id="opponents-row" class="opponents-row"></div>
|
||||||
|
|
||||||
<div class="player-row">
|
<div class="table-center">
|
||||||
<div class="table-center">
|
<div class="deck-area">
|
||||||
<div class="deck-area">
|
<!-- Held card slot (left of deck) -->
|
||||||
<!-- Held card slot (left of deck) -->
|
<div id="held-card-slot" class="held-card-slot hidden">
|
||||||
<div id="held-card-slot" class="held-card-slot hidden">
|
<div id="held-card-display" class="card card-front">
|
||||||
<div id="held-card-display" class="card card-front">
|
<span id="held-card-content"></span>
|
||||||
<span id="held-card-content"></span>
|
|
||||||
</div>
|
|
||||||
<span class="held-label">Holding</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="pile-wrapper">
|
<span class="held-label">Holding</span>
|
||||||
<span class="pile-label">DRAW</span>
|
</div>
|
||||||
<div id="deck" class="card card-back"></div>
|
<div class="pile-wrapper">
|
||||||
</div>
|
<span class="pile-label">DRAW</span>
|
||||||
<div class="pile-wrapper">
|
<div id="deck" class="card card-back"></div>
|
||||||
<span class="pile-label">DISCARD</span>
|
</div>
|
||||||
<div class="discard-stack">
|
<div class="pile-wrapper">
|
||||||
<div id="discard" class="card">
|
<span class="pile-label">DISCARD</span>
|
||||||
<span id="discard-content"></span>
|
<div class="discard-stack">
|
||||||
</div>
|
<div id="discard" class="card">
|
||||||
<!-- Floating held card (appears larger over discard when holding) -->
|
<span id="discard-content"></span>
|
||||||
<div id="held-card-floating" class="card card-front held-card-floating hidden">
|
|
||||||
<span id="held-card-floating-content"></span>
|
|
||||||
</div>
|
|
||||||
<button id="discard-btn" class="btn btn-small hidden">Discard</button>
|
|
||||||
<button id="skip-flip-btn" class="btn btn-small btn-secondary hidden">Skip Flip</button>
|
|
||||||
<button id="knock-early-btn" class="btn btn-small btn-danger hidden">Knock!</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Floating held card (appears larger over discard when holding) -->
|
||||||
|
<div id="held-card-floating" class="card card-front held-card-floating hidden">
|
||||||
|
<span id="held-card-floating-content"></span>
|
||||||
|
</div>
|
||||||
|
<button id="discard-btn" class="btn btn-small hidden">Discard</button>
|
||||||
|
<button id="skip-flip-btn" class="btn btn-small btn-secondary hidden">Skip Flip</button>
|
||||||
|
<button id="knock-early-btn" class="btn btn-small btn-danger hidden">Knock!</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="player-row">
|
||||||
<div class="player-section">
|
<div class="player-section">
|
||||||
<div class="player-area">
|
<div class="player-area">
|
||||||
<h4 id="player-header"><span class="player-name">You</span><span id="your-score" class="player-showing">0</span></h4>
|
<h4 id="player-header"><span class="player-name">You</span><span id="your-score" class="player-showing">0</span></h4>
|
||||||
@@ -427,6 +427,26 @@
|
|||||||
|
|
||||||
<!-- Drawer backdrop for mobile -->
|
<!-- Drawer backdrop for mobile -->
|
||||||
<div id="drawer-backdrop" class="drawer-backdrop"></div>
|
<div id="drawer-backdrop" class="drawer-backdrop"></div>
|
||||||
|
|
||||||
|
<!-- Desktop scorecard button + overlay -->
|
||||||
|
<button id="desktop-scorecard-btn">Scorecard</button>
|
||||||
|
<div id="desktop-scorecard-overlay" class="side-panel desktop-scorecard-overlay">
|
||||||
|
<h4>Current Standings</h4>
|
||||||
|
<div id="desktop-standings-list" class="standings-list"></div>
|
||||||
|
<h4>Scores</h4>
|
||||||
|
<table id="desktop-score-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Player</th>
|
||||||
|
<th>Hole</th>
|
||||||
|
<th>Tot</th>
|
||||||
|
<th>W</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id="desktop-scorecard-backdrop" class="desktop-scorecard-backdrop"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Rules Screen -->
|
<!-- Rules Screen -->
|
||||||
@@ -911,6 +931,28 @@ TOTAL: 0 + 8 + 16 = 24 points</pre>
|
|||||||
</form>
|
</form>
|
||||||
<p class="auth-switch">Already have an account? <a href="#" id="show-login">Login</a></p>
|
<p class="auth-switch">Already have an account? <a href="#" id="show-login">Login</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Request Invite Form -->
|
||||||
|
<div id="request-invite-container" class="hidden">
|
||||||
|
<h3>Request an Invite</h3>
|
||||||
|
<p class="auth-hint">Registration is invite-only. Request access and we'll get back to you.</p>
|
||||||
|
<form id="request-invite-form">
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" id="request-invite-name" placeholder="Your name" required maxlength="100">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="email" id="request-invite-email" placeholder="Email" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<textarea id="request-invite-message" placeholder="Why do you want to join? (optional)" rows="3" maxlength="500"></textarea>
|
||||||
|
</div>
|
||||||
|
<p id="request-invite-error" class="error"></p>
|
||||||
|
<p id="request-invite-success" class="success"></p>
|
||||||
|
<button type="submit" class="btn btn-primary btn-full">Request Invite</button>
|
||||||
|
</form>
|
||||||
|
<p class="auth-switch">Already have an invite? <a href="#" id="request-back-signup">Sign up</a></p>
|
||||||
|
<p class="auth-switch">Already have an account? <a href="#" id="request-back-login">Login</a></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
/**
|
/**
|
||||||
* Leaderboard component for Golf game.
|
* Leaderboard component for Golf game.
|
||||||
* Handles leaderboard display, metric switching, and player stats modal.
|
* Handles leaderboard display, metric switching, and player stats modal.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
// Golf Card Game - Replay Viewer
|
// Golf Card Game - Replay Viewer
|
||||||
|
|
||||||
class ReplayViewer {
|
class ReplayViewer {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
// StateDiffer - Detects what changed between game states
|
// StateDiffer - Detects what changed between game states
|
||||||
// Generates movement instructions for the animation queue
|
// Generates movement instructions for the animation queue
|
||||||
|
|
||||||
|
|||||||
228
client/style.css
228
client/style.css
@@ -1024,13 +1024,13 @@ input::placeholder {
|
|||||||
|
|
||||||
/* Card Styles */
|
/* Card Styles */
|
||||||
.card {
|
.card {
|
||||||
width: clamp(65px, 5.5vw, 100px);
|
width: clamp(65px, 7vw, 135px);
|
||||||
height: clamp(91px, 7.7vw, 140px);
|
height: clamp(91px, 9.8vw, 189px);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: clamp(2rem, 2.5vw, 3.2rem);
|
font-size: clamp(2rem, 3vw, 3.8rem);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
/* No CSS transition - hover effects handled by anime.js */
|
/* No CSS transition - hover effects handled by anime.js */
|
||||||
@@ -1151,7 +1151,7 @@ input::placeholder {
|
|||||||
/* Card Grid */
|
/* Card Grid */
|
||||||
.card-grid {
|
.card-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, clamp(65px, 5.5vw, 100px));
|
grid-template-columns: repeat(3, clamp(65px, 7vw, 135px));
|
||||||
gap: clamp(8px, 0.8vw, 14px);
|
gap: clamp(8px, 0.8vw, 14px);
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
@@ -1161,18 +1161,22 @@ input::placeholder {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 25px;
|
justify-content: space-between;
|
||||||
|
gap: 15px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Player row - deck/discard and player cards side by side */
|
/* Player row - local player cards */
|
||||||
.player-row {
|
.player-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 25px;
|
gap: clamp(15px, 2vh, 35px);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
padding-bottom: clamp(10px, 2vh, 30px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.opponents-row {
|
.opponents-row {
|
||||||
@@ -1180,9 +1184,9 @@ input::placeholder {
|
|||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
gap: clamp(12px, 1.8vw, 35px);
|
gap: clamp(12px, 6vw, 120px);
|
||||||
min-height: clamp(120px, 14vw, 200px);
|
min-height: clamp(120px, 18vw, 280px);
|
||||||
padding: 8px 20px 0;
|
padding: 15px 20px 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1234,7 +1238,62 @@ input::placeholder {
|
|||||||
transform: rotate(8deg);
|
transform: rotate(8deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 5 opponents: deeper arch with graduated rotation toward center */
|
/* 5 opponents: tighter spacing to fit single row on wide screens */
|
||||||
|
.opponents-row:has(.opponent-area:first-child:nth-last-child(5)) {
|
||||||
|
gap: clamp(6px, 2vw, 50px);
|
||||||
|
}
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5),
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) ~ .opponent-area {
|
||||||
|
flex-shrink: 1;
|
||||||
|
}
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) .card-grid,
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) ~ .opponent-area .card-grid {
|
||||||
|
grid-template-columns: repeat(3, clamp(38px, 4vw, 85px));
|
||||||
|
gap: clamp(2px, 0.4vw, 6px);
|
||||||
|
}
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) .card,
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) ~ .opponent-area .card {
|
||||||
|
width: clamp(38px, 4vw, 85px);
|
||||||
|
height: clamp(53px, 5.6vw, 119px);
|
||||||
|
font-size: clamp(0.9rem, 1.3vw, 2.2rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 5 opponents mid-width: wrap into 2 arch rows (3 + 2) */
|
||||||
|
@media (min-width: 750px) and (max-width: 1220px) {
|
||||||
|
.opponents-row:has(.opponent-area:first-child:nth-last-child(5)) {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: clamp(6px, 1.5vw, 20px);
|
||||||
|
row-gap: clamp(4px, 1vw, 16px);
|
||||||
|
}
|
||||||
|
/* Force 3+2 split: each item ~30% so 3 fit per row */
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5),
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) ~ .opponent-area {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
/* Row 1 arch: 3 opponents */
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
transform: rotate(-5deg);
|
||||||
|
}
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) ~ .opponent-area:nth-child(2) {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) ~ .opponent-area:nth-child(3) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
transform: rotate(5deg);
|
||||||
|
}
|
||||||
|
/* Row 2 arch: 2 opponents */
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) ~ .opponent-area:nth-child(4) {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
transform: rotate(-3deg);
|
||||||
|
}
|
||||||
|
.opponents-row .opponent-area:first-child:nth-last-child(5) ~ .opponent-area:nth-child(5) {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
transform: rotate(3deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.opponents-row .opponent-area:first-child:nth-last-child(5) {
|
.opponents-row .opponent-area:first-child:nth-last-child(5) {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
transform: rotate(-10deg);
|
transform: rotate(-10deg);
|
||||||
@@ -1367,9 +1426,9 @@ input::placeholder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.deck-area .card {
|
.deck-area .card {
|
||||||
width: clamp(80px, 7vw, 120px);
|
width: clamp(80px, 8.5vw, 150px);
|
||||||
height: clamp(112px, 9.8vw, 168px);
|
height: clamp(112px, 11.9vw, 210px);
|
||||||
font-size: clamp(2.4rem, 3.2vw, 4rem);
|
font-size: clamp(2.4rem, 3.5vw, 4.5rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
#discard {
|
#discard {
|
||||||
@@ -1771,14 +1830,14 @@ input::placeholder {
|
|||||||
|
|
||||||
.opponent-area .card-grid {
|
.opponent-area .card-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, clamp(45px, 4vw, 75px));
|
grid-template-columns: repeat(3, clamp(45px, 5vw, 100px));
|
||||||
gap: clamp(4px, 0.4vw, 8px);
|
gap: clamp(4px, 0.5vw, 8px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.opponent-area .card {
|
.opponent-area .card {
|
||||||
width: clamp(45px, 4vw, 75px);
|
width: clamp(45px, 5vw, 100px);
|
||||||
height: clamp(63px, 5.6vw, 105px);
|
height: clamp(63px, 7vw, 140px);
|
||||||
font-size: clamp(1.3rem, 1.5vw, 2.2rem);
|
font-size: clamp(1.3rem, 1.8vw, 2.6rem);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1929,6 +1988,7 @@ input::placeholder {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-height: calc(100vh - 50px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Side Panels - positioned in bottom corners */
|
/* Side Panels - positioned in bottom corners */
|
||||||
@@ -1953,6 +2013,88 @@ input::placeholder {
|
|||||||
right: 15px;
|
right: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Desktop: hide side panels by default, show via scorecard button */
|
||||||
|
.side-panel.left-panel,
|
||||||
|
.side-panel.right-panel {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desktop scorecard button - bottom right corner */
|
||||||
|
#desktop-scorecard-btn {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 15px;
|
||||||
|
right: 15px;
|
||||||
|
z-index: 99;
|
||||||
|
background: linear-gradient(145deg, rgba(15, 50, 35, 0.92) 0%, rgba(8, 30, 20, 0.95) 100%);
|
||||||
|
border: 1px solid rgba(244, 164, 96, 0.35);
|
||||||
|
color: #f4a460;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.15em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#desktop-scorecard-btn:hover {
|
||||||
|
background: linear-gradient(145deg, rgba(20, 60, 40, 0.95) 0%, rgba(12, 40, 28, 0.97) 100%);
|
||||||
|
border-color: rgba(244, 164, 96, 0.6);
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 10px rgba(244, 164, 96, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
#desktop-scorecard-btn:active {
|
||||||
|
transform: scale(0.96);
|
||||||
|
}
|
||||||
|
|
||||||
|
#desktop-scorecard-btn.active {
|
||||||
|
background: linear-gradient(135deg, #f4a460, #e8935a);
|
||||||
|
color: #1a472a;
|
||||||
|
border-color: transparent;
|
||||||
|
box-shadow: 0 2px 12px rgba(244, 164, 96, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desktop scorecard overlay — combines standings + scores */
|
||||||
|
.side-panel.desktop-scorecard-overlay {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 55px;
|
||||||
|
right: 15px;
|
||||||
|
left: auto;
|
||||||
|
width: 280px;
|
||||||
|
max-height: 70vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 100;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
background: linear-gradient(145deg, rgba(15, 50, 35, 0.95) 0%, rgba(8, 30, 20, 0.97) 100%);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
border: 1px solid rgba(244, 164, 96, 0.25);
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.side-panel.desktop-scorecard-overlay.open {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desktop scorecard backdrop */
|
||||||
|
.desktop-scorecard-backdrop {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 98;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-scorecard-backdrop.visible {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.side-panel > h4 {
|
.side-panel > h4 {
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -3596,7 +3738,24 @@ input::placeholder {
|
|||||||
color: rgba(255, 255, 255, 0.4);
|
color: rgba(255, 255, 255, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-auth input:focus {
|
.modal-auth textarea {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px 15px;
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-family: inherit;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-auth textarea::placeholder {
|
||||||
|
color: rgba(255, 255, 255, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-auth input:focus,
|
||||||
|
.modal-auth textarea:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
border-color: #f4a460;
|
border-color: #f4a460;
|
||||||
}
|
}
|
||||||
@@ -3612,6 +3771,15 @@ input::placeholder {
|
|||||||
color: rgba(255, 255, 255, 0.45);
|
color: rgba(255, 255, 255, 0.45);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-hint a {
|
||||||
|
color: #f4a460;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-hint a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
.auth-switch {
|
.auth-switch {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
@@ -5336,12 +5504,16 @@ body.mobile-portrait .opponents-row {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- Mobile: Player row gets remaining space, centered vertically --- */
|
/* --- Mobile: Table center and player row share remaining space --- */
|
||||||
|
body.mobile-portrait .table-center {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
body.mobile-portrait .player-row {
|
body.mobile-portrait .player-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-evenly;
|
justify-content: center;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex: 1 1 0%;
|
flex: 1 1 0%;
|
||||||
@@ -5503,6 +5675,18 @@ body.mobile-portrait .real-card .card-face-back {
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Hide desktop scorecard button and backdrop on mobile */
|
||||||
|
body.mobile-portrait #desktop-scorecard-btn,
|
||||||
|
body.mobile-portrait .desktop-scorecard-backdrop {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Re-enable side panels on mobile (overrides desktop hide) */
|
||||||
|
body.mobile-portrait .side-panel.left-panel,
|
||||||
|
body.mobile-portrait .side-panel.right-panel {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Mobile: Side panels become bottom drawers --- */
|
/* --- Mobile: Side panels become bottom drawers --- */
|
||||||
body.mobile-portrait .side-panel {
|
body.mobile-portrait .side-panel {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
|
restart: unless-stopped
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@@ -39,6 +40,7 @@ services:
|
|||||||
- BASE_URL=${BASE_URL:-https://golf.example.com}
|
- BASE_URL=${BASE_URL:-https://golf.example.com}
|
||||||
- RATE_LIMIT_ENABLED=true
|
- RATE_LIMIT_ENABLED=true
|
||||||
- INVITE_ONLY=true
|
- INVITE_ONLY=true
|
||||||
|
- INVITE_REQUEST_ENABLED=true
|
||||||
- DAILY_OPEN_SIGNUPS=${DAILY_OPEN_SIGNUPS:-0}
|
- DAILY_OPEN_SIGNUPS=${DAILY_OPEN_SIGNUPS:-0}
|
||||||
- DAILY_SIGNUPS_PER_IP=${DAILY_SIGNUPS_PER_IP:-3}
|
- DAILY_SIGNUPS_PER_IP=${DAILY_SIGNUPS_PER_IP:-3}
|
||||||
- BOOTSTRAP_ADMIN_USERNAME=${BOOTSTRAP_ADMIN_USERNAME:-}
|
- BOOTSTRAP_ADMIN_USERNAME=${BOOTSTRAP_ADMIN_USERNAME:-}
|
||||||
@@ -50,10 +52,6 @@ services:
|
|||||||
redis:
|
redis:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 1
|
|
||||||
restart_policy:
|
|
||||||
condition: on-failure
|
|
||||||
max_attempts: 3
|
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: 256M
|
memory: 256M
|
||||||
@@ -64,7 +62,7 @@ services:
|
|||||||
- web
|
- web
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.docker.network=golfgame_web"
|
- "traefik.docker.network=traefik_web"
|
||||||
- "traefik.http.routers.golf.rule=Host(`${DOMAIN:-golf.example.com}`)"
|
- "traefik.http.routers.golf.rule=Host(`${DOMAIN:-golf.example.com}`)"
|
||||||
- "traefik.http.routers.golf.entrypoints=websecure"
|
- "traefik.http.routers.golf.entrypoints=websecure"
|
||||||
- "traefik.http.routers.golf.tls=true"
|
- "traefik.http.routers.golf.tls=true"
|
||||||
@@ -84,6 +82,7 @@ services:
|
|||||||
- "traefik.http.services.golf.loadbalancer.sticky.cookie.name=golf_server"
|
- "traefik.http.services.golf.loadbalancer.sticky.cookie.name=golf_server"
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
|
restart: unless-stopped
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: golf
|
POSTGRES_DB: golf
|
||||||
@@ -106,6 +105,7 @@ services:
|
|||||||
memory: 64M
|
memory: 64M
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
|
restart: unless-stopped
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
command: redis-server --appendonly yes --maxmemory 32mb --maxmemory-policy allkeys-lru
|
command: redis-server --appendonly yes --maxmemory 32mb --maxmemory-policy allkeys-lru
|
||||||
volumes:
|
volumes:
|
||||||
@@ -124,45 +124,14 @@ services:
|
|||||||
reservations:
|
reservations:
|
||||||
memory: 16M
|
memory: 16M
|
||||||
|
|
||||||
traefik:
|
|
||||||
image: traefik:v3.6
|
|
||||||
environment:
|
|
||||||
- DOCKER_API_VERSION=1.44
|
|
||||||
command:
|
|
||||||
- "--api.dashboard=true"
|
|
||||||
- "--api.insecure=true"
|
|
||||||
- "--accesslog=true"
|
|
||||||
- "--log.level=WARN"
|
|
||||||
- "--providers.docker=true"
|
|
||||||
- "--providers.docker.exposedbydefault=false"
|
|
||||||
- "--entrypoints.web.address=:80"
|
|
||||||
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
|
|
||||||
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
|
|
||||||
- "--entrypoints.websecure.address=:443"
|
|
||||||
- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
|
|
||||||
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
|
|
||||||
- "--certificatesresolvers.letsencrypt.acme.email=${ACME_EMAIL}"
|
|
||||||
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
- "443:443"
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
||||||
- letsencrypt:/letsencrypt
|
|
||||||
networks:
|
|
||||||
- web
|
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: 64M
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
redis_data:
|
redis_data:
|
||||||
letsencrypt:
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
internal:
|
internal:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
web:
|
web:
|
||||||
driver: bridge
|
name: traefik_web
|
||||||
|
external: true
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ services:
|
|||||||
- BASE_URL=${BASE_URL:-https://staging.golfcards.club}
|
- BASE_URL=${BASE_URL:-https://staging.golfcards.club}
|
||||||
- RATE_LIMIT_ENABLED=false
|
- RATE_LIMIT_ENABLED=false
|
||||||
- INVITE_ONLY=true
|
- INVITE_ONLY=true
|
||||||
|
- INVITE_REQUEST_ENABLED=false
|
||||||
- DAILY_OPEN_SIGNUPS=${DAILY_OPEN_SIGNUPS:-0}
|
- DAILY_OPEN_SIGNUPS=${DAILY_OPEN_SIGNUPS:-0}
|
||||||
- DAILY_SIGNUPS_PER_IP=${DAILY_SIGNUPS_PER_IP:-3}
|
- DAILY_SIGNUPS_PER_IP=${DAILY_SIGNUPS_PER_IP:-3}
|
||||||
- BOOTSTRAP_ADMIN_USERNAME=${BOOTSTRAP_ADMIN_USERNAME:-}
|
- BOOTSTRAP_ADMIN_USERNAME=${BOOTSTRAP_ADMIN_USERNAME:-}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ version = "3.1.6"
|
|||||||
description = "6-Card Golf card game with AI opponents"
|
description = "6-Card Golf card game with AI opponents"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
license = {text = "MIT"}
|
license = {text = "GPL-3.0-or-later"}
|
||||||
authors = [
|
authors = [
|
||||||
{name = "alee"}
|
{name = "alee"}
|
||||||
]
|
]
|
||||||
@@ -13,7 +13,7 @@ classifiers = [
|
|||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
"Framework :: FastAPI",
|
"Framework :: FastAPI",
|
||||||
"Intended Audience :: End Users/Desktop",
|
"Intended Audience :: End Users/Desktop",
|
||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
"Programming Language :: Python :: 3.12",
|
"Programming Language :: Python :: 3.12",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""AI personalities for CPU players in Golf."""
|
"""AI personalities for CPU players in Golf."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Authentication and user management for Golf game.
|
Authentication and user management for Golf game.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Centralized configuration for Golf game server.
|
Centralized configuration for Golf game server.
|
||||||
|
|
||||||
@@ -148,6 +149,9 @@ class ServerConfig:
|
|||||||
SECRET_KEY: str = ""
|
SECRET_KEY: str = ""
|
||||||
INVITE_ONLY: bool = True
|
INVITE_ONLY: bool = True
|
||||||
|
|
||||||
|
# Allow visitors to request an invite (shown on login page when invite-only)
|
||||||
|
INVITE_REQUEST_ENABLED: bool = False
|
||||||
|
|
||||||
# Metered open signups (public beta)
|
# Metered open signups (public beta)
|
||||||
# 0 = disabled (invite-only), -1 = unlimited, N = max per day
|
# 0 = disabled (invite-only), -1 = unlimited, N = max per day
|
||||||
DAILY_OPEN_SIGNUPS: int = 0
|
DAILY_OPEN_SIGNUPS: int = 0
|
||||||
@@ -202,6 +206,7 @@ class ServerConfig:
|
|||||||
ROOM_IDLE_TIMEOUT_SECONDS=get_env_int("ROOM_IDLE_TIMEOUT_SECONDS", 300),
|
ROOM_IDLE_TIMEOUT_SECONDS=get_env_int("ROOM_IDLE_TIMEOUT_SECONDS", 300),
|
||||||
SECRET_KEY=get_env("SECRET_KEY", ""),
|
SECRET_KEY=get_env("SECRET_KEY", ""),
|
||||||
INVITE_ONLY=get_env_bool("INVITE_ONLY", True),
|
INVITE_ONLY=get_env_bool("INVITE_ONLY", True),
|
||||||
|
INVITE_REQUEST_ENABLED=get_env_bool("INVITE_REQUEST_ENABLED", False),
|
||||||
DAILY_OPEN_SIGNUPS=get_env_int("DAILY_OPEN_SIGNUPS", 0),
|
DAILY_OPEN_SIGNUPS=get_env_int("DAILY_OPEN_SIGNUPS", 0),
|
||||||
DAILY_SIGNUPS_PER_IP=get_env_int("DAILY_SIGNUPS_PER_IP", 3),
|
DAILY_SIGNUPS_PER_IP=get_env_int("DAILY_SIGNUPS_PER_IP", 3),
|
||||||
BOOTSTRAP_ADMIN_USERNAME=get_env("BOOTSTRAP_ADMIN_USERNAME", ""),
|
BOOTSTRAP_ADMIN_USERNAME=get_env("BOOTSTRAP_ADMIN_USERNAME", ""),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Card value constants for 6-Card Golf.
|
Card value constants for 6-Card Golf.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Game logic for 6-Card Golf.
|
Game logic for 6-Card Golf.
|
||||||
|
|
||||||
@@ -782,9 +783,17 @@ class Game:
|
|||||||
for i, player in enumerate(self.players):
|
for i, player in enumerate(self.players):
|
||||||
if player.id == player_id:
|
if player.id == player_id:
|
||||||
removed = self.players.pop(i)
|
removed = self.players.pop(i)
|
||||||
# Adjust dealer_idx if needed after removal
|
if self.players:
|
||||||
if self.players and self.dealer_idx >= len(self.players):
|
# Adjust dealer_idx if needed after removal
|
||||||
self.dealer_idx = 0
|
if self.dealer_idx >= len(self.players):
|
||||||
|
self.dealer_idx = 0
|
||||||
|
# Adjust current_player_index after removal
|
||||||
|
if i < self.current_player_index:
|
||||||
|
# Removed player was before current: shift back
|
||||||
|
self.current_player_index -= 1
|
||||||
|
elif self.current_player_index >= len(self.players):
|
||||||
|
# Removed player was at/after current and index is now OOB
|
||||||
|
self.current_player_index = 0
|
||||||
self._emit("player_left", player_id=player_id, reason=reason)
|
self._emit("player_left", player_id=player_id, reason=reason)
|
||||||
return removed
|
return removed
|
||||||
return None
|
return None
|
||||||
@@ -807,6 +816,8 @@ class Game:
|
|||||||
def current_player(self) -> Optional[Player]:
|
def current_player(self) -> Optional[Player]:
|
||||||
"""Get the player whose turn it currently is."""
|
"""Get the player whose turn it currently is."""
|
||||||
if self.players:
|
if self.players:
|
||||||
|
if self.current_player_index >= len(self.players):
|
||||||
|
self.current_player_index = self.current_player_index % len(self.players)
|
||||||
return self.players[self.current_player_index]
|
return self.players[self.current_player_index]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Game Analyzer for 6-Card Golf AI decisions.
|
Game Analyzer for 6-Card Golf AI decisions.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""WebSocket message handlers for the Golf card game.
|
"""WebSocket message handlers for the Golf card game.
|
||||||
|
|
||||||
Each handler corresponds to a single message type from the client.
|
Each handler corresponds to a single message type from the client.
|
||||||
@@ -313,22 +314,6 @@ async def handle_swap(data: dict, ctx: ConnectionContext, *, broadcast_game_stat
|
|||||||
reason=f"swapped {drawn_card.rank.value} into position {position}, replaced {old_rank}",
|
reason=f"swapped {drawn_card.rank.value} into position {position}, replaced {old_rank}",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Broadcast reveal of old face-down card before state update
|
|
||||||
if old_card_data:
|
|
||||||
reveal_msg = {
|
|
||||||
"type": "card_revealed",
|
|
||||||
"player_id": ctx.player_id,
|
|
||||||
"position": position,
|
|
||||||
"card": old_card_data,
|
|
||||||
}
|
|
||||||
for pid, p in ctx.current_room.players.items():
|
|
||||||
if not p.is_cpu and p.websocket:
|
|
||||||
try:
|
|
||||||
await p.websocket.send_json(reveal_msg)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
await asyncio.sleep(1.0)
|
|
||||||
|
|
||||||
await broadcast_game_state(ctx.current_room)
|
await broadcast_game_state(ctx.current_room)
|
||||||
await asyncio.sleep(1.0)
|
await asyncio.sleep(1.0)
|
||||||
check_and_run_cpu_turn(ctx.current_room)
|
check_and_run_cpu_turn(ctx.current_room)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Structured logging configuration for Golf game server.
|
Structured logging configuration for Golf game server.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""FastAPI WebSocket server for Golf card game."""
|
"""FastAPI WebSocket server for Golf card game."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
@@ -431,7 +432,7 @@ async def _close_all_websockets():
|
|||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="Golf Card Game",
|
title="Golf Card Game",
|
||||||
debug=config.DEBUG,
|
debug=config.DEBUG,
|
||||||
version="3.1.6",
|
version="3.2.0",
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -943,7 +944,18 @@ if os.path.exists(client_path):
|
|||||||
return FileResponse(os.path.join(client_path, "index.html"))
|
return FileResponse(os.path.join(client_path, "index.html"))
|
||||||
|
|
||||||
# Mount static files for everything else (JS, CSS, SVG, etc.)
|
# Mount static files for everything else (JS, CSS, SVG, etc.)
|
||||||
app.mount("/", StaticFiles(directory=client_path), name="static")
|
# Wrap StaticFiles to reject WebSocket requests gracefully instead of
|
||||||
|
# crashing with AssertionError (starlette asserts scope["type"] == "http").
|
||||||
|
static_files = StaticFiles(directory=client_path)
|
||||||
|
|
||||||
|
async def safe_static_files(scope, receive, send):
|
||||||
|
if scope["type"] != "http":
|
||||||
|
if scope["type"] == "websocket":
|
||||||
|
await send({"type": "websocket.close", "code": 1000})
|
||||||
|
return
|
||||||
|
await static_files(scope, receive, send)
|
||||||
|
|
||||||
|
app.mount("/", safe_static_files, name="static")
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Middleware components for Golf game server.
|
Middleware components for Golf game server.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Rate limiting middleware for FastAPI.
|
Rate limiting middleware for FastAPI.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Request ID middleware for request tracing.
|
Request ID middleware for request tracing.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Security headers middleware for FastAPI.
|
Security headers middleware for FastAPI.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""Models package for Golf game V2."""
|
"""Models package for Golf game V2."""
|
||||||
|
|
||||||
from .events import EventType, GameEvent
|
from .events import EventType, GameEvent
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Event definitions for Golf game event sourcing.
|
Event definitions for Golf game event sourcing.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Game state rebuilder for event sourcing.
|
Game state rebuilder for event sourcing.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
User-related models for Golf game authentication.
|
User-related models for Golf game authentication.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Room management for multiplayer Golf games.
|
Room management for multiplayer Golf games.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""Routers package for Golf game API."""
|
"""Routers package for Golf game API."""
|
||||||
|
|
||||||
from .auth import router as auth_router
|
from .auth import router as auth_router
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Admin API router for Golf game V2.
|
Admin API router for Golf game V2.
|
||||||
|
|
||||||
@@ -417,3 +418,76 @@ async def revoke_invite_code(
|
|||||||
if not success:
|
if not success:
|
||||||
raise HTTPException(status_code=404, detail="Invite code not found")
|
raise HTTPException(status_code=404, detail="Invite code not found")
|
||||||
return {"message": "Invite code revoked successfully"}
|
return {"message": "Invite code revoked successfully"}
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Invite Request Endpoints
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/invite-requests")
|
||||||
|
async def list_invite_requests(
|
||||||
|
status: Optional[str] = None,
|
||||||
|
admin: User = Depends(require_admin_v2),
|
||||||
|
service: AdminService = Depends(get_admin_service_dep),
|
||||||
|
):
|
||||||
|
"""List invite requests, optionally filtered by status (pending, approved, denied)."""
|
||||||
|
requests = await service.get_invite_requests(status=status)
|
||||||
|
return {"requests": [r.to_dict() for r in requests]}
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/invite-requests/{request_id}/approve")
|
||||||
|
async def approve_invite_request(
|
||||||
|
request_id: int,
|
||||||
|
request: Request,
|
||||||
|
admin: User = Depends(require_admin_v2),
|
||||||
|
service: AdminService = Depends(get_admin_service_dep),
|
||||||
|
):
|
||||||
|
"""Approve an invite request — creates a code and emails the requester."""
|
||||||
|
code = await service.approve_invite_request(
|
||||||
|
request_id=request_id,
|
||||||
|
admin_id=admin.id,
|
||||||
|
ip_address=get_client_ip(request),
|
||||||
|
)
|
||||||
|
if not code:
|
||||||
|
raise HTTPException(status_code=404, detail="Request not found or already handled")
|
||||||
|
|
||||||
|
# Get the request details to send the approval email
|
||||||
|
requests = await service.get_invite_requests()
|
||||||
|
req = next((r for r in requests if r.id == request_id), None)
|
||||||
|
if req:
|
||||||
|
from services.email_service import get_email_service
|
||||||
|
email_service = get_email_service()
|
||||||
|
await email_service.send_invite_approved_email(
|
||||||
|
to=req.email,
|
||||||
|
name=req.name,
|
||||||
|
invite_code=code,
|
||||||
|
)
|
||||||
|
|
||||||
|
return {"code": code, "message": "Request approved and invite sent"}
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/invite-requests/{request_id}/deny")
|
||||||
|
async def deny_invite_request(
|
||||||
|
request_id: int,
|
||||||
|
request: Request,
|
||||||
|
admin: User = Depends(require_admin_v2),
|
||||||
|
service: AdminService = Depends(get_admin_service_dep),
|
||||||
|
):
|
||||||
|
"""Deny an invite request — optionally emails the requester."""
|
||||||
|
result = await service.deny_invite_request(
|
||||||
|
request_id=request_id,
|
||||||
|
admin_id=admin.id,
|
||||||
|
ip_address=get_client_ip(request),
|
||||||
|
)
|
||||||
|
if not result:
|
||||||
|
raise HTTPException(status_code=404, detail="Request not found or already handled")
|
||||||
|
|
||||||
|
from services.email_service import get_email_service
|
||||||
|
email_service = get_email_service()
|
||||||
|
await email_service.send_invite_denied_email(
|
||||||
|
to=result["email"],
|
||||||
|
name=result["name"],
|
||||||
|
)
|
||||||
|
|
||||||
|
return {"message": "Request denied"}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Authentication API router for Golf game V2.
|
Authentication API router for Golf game V2.
|
||||||
|
|
||||||
@@ -74,6 +75,13 @@ class UpdatePreferencesRequest(BaseModel):
|
|||||||
preferences: dict
|
preferences: dict
|
||||||
|
|
||||||
|
|
||||||
|
class InviteRequestBody(BaseModel):
|
||||||
|
"""Invite request body."""
|
||||||
|
name: str
|
||||||
|
email: str
|
||||||
|
message: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class ConvertGuestRequest(BaseModel):
|
class ConvertGuestRequest(BaseModel):
|
||||||
"""Convert guest to user request."""
|
"""Convert guest to user request."""
|
||||||
guest_id: str
|
guest_id: str
|
||||||
@@ -331,6 +339,7 @@ async def signup_info():
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"invite_required": invite_required,
|
"invite_required": invite_required,
|
||||||
|
"invite_request_enabled": config.INVITE_REQUEST_ENABLED,
|
||||||
"open_signups_enabled": open_signups_enabled,
|
"open_signups_enabled": open_signups_enabled,
|
||||||
"daily_limit": config.DAILY_OPEN_SIGNUPS if not unlimited else None,
|
"daily_limit": config.DAILY_OPEN_SIGNUPS if not unlimited else None,
|
||||||
"remaining_today": remaining,
|
"remaining_today": remaining,
|
||||||
@@ -338,6 +347,55 @@ async def signup_info():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/request-invite")
|
||||||
|
async def request_invite(
|
||||||
|
request_body: InviteRequestBody,
|
||||||
|
request: Request,
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Public endpoint: submit a request for an invite code.
|
||||||
|
|
||||||
|
Stores the request in the database and notifies admins via email.
|
||||||
|
"""
|
||||||
|
if not config.INVITE_REQUEST_ENABLED:
|
||||||
|
raise HTTPException(status_code=404, detail="Invite requests are not enabled")
|
||||||
|
|
||||||
|
if not _admin_service:
|
||||||
|
raise HTTPException(status_code=503, detail="Service not initialized")
|
||||||
|
|
||||||
|
name = request_body.name.strip()
|
||||||
|
email = request_body.email.strip().lower()
|
||||||
|
message = request_body.message.strip() if request_body.message else None
|
||||||
|
|
||||||
|
if not name or len(name) > 100:
|
||||||
|
raise HTTPException(status_code=400, detail="Name is required (max 100 characters)")
|
||||||
|
if not email or "@" not in email:
|
||||||
|
raise HTTPException(status_code=400, detail="Valid email is required")
|
||||||
|
|
||||||
|
client_ip = get_client_ip(request)
|
||||||
|
|
||||||
|
request_id = await _admin_service.create_invite_request(
|
||||||
|
name=name,
|
||||||
|
email=email,
|
||||||
|
message=message,
|
||||||
|
ip_address=client_ip,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Notify admin emails
|
||||||
|
if config.ADMIN_EMAILS:
|
||||||
|
from services.email_service import get_email_service
|
||||||
|
email_service = get_email_service()
|
||||||
|
for admin_email in config.ADMIN_EMAILS:
|
||||||
|
await email_service.send_invite_request_admin_notification(
|
||||||
|
to=admin_email,
|
||||||
|
requester_name=name,
|
||||||
|
requester_email=email,
|
||||||
|
message=message or "",
|
||||||
|
)
|
||||||
|
|
||||||
|
return {"status": "ok", "message": "Your request has been submitted. We'll be in touch!"}
|
||||||
|
|
||||||
|
|
||||||
@router.post("/verify-email")
|
@router.post("/verify-email")
|
||||||
async def verify_email(
|
async def verify_email(
|
||||||
request_body: VerifyEmailRequest,
|
request_body: VerifyEmailRequest,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Health check endpoints for production deployment.
|
Health check endpoints for production deployment.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Replay API router for Golf game.
|
Replay API router for Golf game.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Stats and Leaderboards API router for Golf game.
|
Stats and Leaderboards API router for Golf game.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Score distribution analysis for Golf AI.
|
Score distribution analysis for Golf AI.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Create an admin user for the Golf game.
|
Create an admin user for the Golf game.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""Services package for Golf game V2 business logic."""
|
"""Services package for Golf game V2 business logic."""
|
||||||
|
|
||||||
from .recovery_service import RecoveryService, RecoveryResult
|
from .recovery_service import RecoveryService, RecoveryResult
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Admin service for Golf game.
|
Admin service for Golf game.
|
||||||
|
|
||||||
@@ -137,6 +138,35 @@ class InviteCode:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class InviteRequest:
|
||||||
|
"""Invite request details."""
|
||||||
|
id: int
|
||||||
|
name: str
|
||||||
|
email: str
|
||||||
|
message: Optional[str]
|
||||||
|
status: str
|
||||||
|
ip_address: Optional[str]
|
||||||
|
created_at: datetime
|
||||||
|
reviewed_at: Optional[datetime]
|
||||||
|
reviewed_by: Optional[str]
|
||||||
|
reviewed_by_username: Optional[str] = None
|
||||||
|
|
||||||
|
def to_dict(self) -> dict:
|
||||||
|
return {
|
||||||
|
"id": self.id,
|
||||||
|
"name": self.name,
|
||||||
|
"email": self.email,
|
||||||
|
"message": self.message,
|
||||||
|
"status": self.status,
|
||||||
|
"ip_address": self.ip_address,
|
||||||
|
"created_at": self.created_at.isoformat() if self.created_at else None,
|
||||||
|
"reviewed_at": self.reviewed_at.isoformat() if self.reviewed_at else None,
|
||||||
|
"reviewed_by": self.reviewed_by,
|
||||||
|
"reviewed_by_username": self.reviewed_by_username,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AdminService:
|
class AdminService:
|
||||||
"""
|
"""
|
||||||
Admin operations and moderation service.
|
Admin operations and moderation service.
|
||||||
@@ -1210,6 +1240,183 @@ class AdminService:
|
|||||||
|
|
||||||
return result != "UPDATE 0"
|
return result != "UPDATE 0"
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
# Invite Requests
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
async def create_invite_request(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
email: str,
|
||||||
|
message: Optional[str] = None,
|
||||||
|
ip_address: Optional[str] = None,
|
||||||
|
) -> int:
|
||||||
|
"""
|
||||||
|
Create a new invite request.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The request ID.
|
||||||
|
"""
|
||||||
|
async with self.pool.acquire() as conn:
|
||||||
|
# Check for existing pending request from same email
|
||||||
|
existing = await conn.fetchval(
|
||||||
|
"SELECT id FROM invite_requests WHERE email = $1 AND status = 'pending'",
|
||||||
|
email,
|
||||||
|
)
|
||||||
|
if existing:
|
||||||
|
return existing
|
||||||
|
|
||||||
|
row_id = await conn.fetchval(
|
||||||
|
"""
|
||||||
|
INSERT INTO invite_requests (name, email, message, ip_address)
|
||||||
|
VALUES ($1, $2, $3, $4::inet)
|
||||||
|
RETURNING id
|
||||||
|
""",
|
||||||
|
name,
|
||||||
|
email,
|
||||||
|
message,
|
||||||
|
ip_address,
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info(f"New invite request #{row_id} from {email}")
|
||||||
|
return row_id
|
||||||
|
|
||||||
|
async def get_invite_requests(self, status: Optional[str] = None) -> List[InviteRequest]:
|
||||||
|
"""Get invite requests, optionally filtered by status."""
|
||||||
|
async with self.pool.acquire() as conn:
|
||||||
|
query = """
|
||||||
|
SELECT r.id, r.name, r.email, r.message, r.status, r.ip_address,
|
||||||
|
r.created_at, r.reviewed_at, r.reviewed_by,
|
||||||
|
u.username as reviewed_by_username
|
||||||
|
FROM invite_requests r
|
||||||
|
LEFT JOIN users_v2 u ON r.reviewed_by = u.id
|
||||||
|
"""
|
||||||
|
params = []
|
||||||
|
if status:
|
||||||
|
query += " WHERE r.status = $1"
|
||||||
|
params.append(status)
|
||||||
|
query += " ORDER BY r.created_at DESC"
|
||||||
|
|
||||||
|
rows = await conn.fetch(query, *params)
|
||||||
|
|
||||||
|
return [
|
||||||
|
InviteRequest(
|
||||||
|
id=row["id"],
|
||||||
|
name=row["name"],
|
||||||
|
email=row["email"],
|
||||||
|
message=row["message"],
|
||||||
|
status=row["status"],
|
||||||
|
ip_address=str(row["ip_address"]) if row["ip_address"] else None,
|
||||||
|
created_at=row["created_at"],
|
||||||
|
reviewed_at=row["reviewed_at"],
|
||||||
|
reviewed_by=str(row["reviewed_by"]) if row["reviewed_by"] else None,
|
||||||
|
reviewed_by_username=row["reviewed_by_username"],
|
||||||
|
)
|
||||||
|
for row in rows
|
||||||
|
]
|
||||||
|
|
||||||
|
async def approve_invite_request(
|
||||||
|
self,
|
||||||
|
request_id: int,
|
||||||
|
admin_id: str,
|
||||||
|
ip_address: Optional[str] = None,
|
||||||
|
) -> Optional[str]:
|
||||||
|
"""
|
||||||
|
Approve an invite request: create an invite code and update the request.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The generated invite code, or None if request not found/already handled.
|
||||||
|
"""
|
||||||
|
async with self.pool.acquire() as conn:
|
||||||
|
# Verify request exists and is pending
|
||||||
|
row = await conn.fetchrow(
|
||||||
|
"SELECT id, email, name FROM invite_requests WHERE id = $1 AND status = 'pending'",
|
||||||
|
request_id,
|
||||||
|
)
|
||||||
|
if not row:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Create an invite code for this request
|
||||||
|
code = secrets.token_urlsafe(6).upper()[:8]
|
||||||
|
expires_at = datetime.now(timezone.utc) + timedelta(days=7)
|
||||||
|
|
||||||
|
invite_id = await conn.fetchval(
|
||||||
|
"""
|
||||||
|
INSERT INTO invite_codes (code, created_by, expires_at, max_uses)
|
||||||
|
VALUES ($1, $2, $3, 1)
|
||||||
|
RETURNING id
|
||||||
|
""",
|
||||||
|
code,
|
||||||
|
admin_id,
|
||||||
|
expires_at,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Update the request
|
||||||
|
await conn.execute(
|
||||||
|
"""
|
||||||
|
UPDATE invite_requests
|
||||||
|
SET status = 'approved', reviewed_at = NOW(), reviewed_by = $1, invite_code_id = $2
|
||||||
|
WHERE id = $3
|
||||||
|
""",
|
||||||
|
admin_id,
|
||||||
|
invite_id,
|
||||||
|
request_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
await self.audit(
|
||||||
|
admin_id,
|
||||||
|
"approve_invite_request",
|
||||||
|
"invite_request",
|
||||||
|
str(request_id),
|
||||||
|
{"email": row["email"], "invite_code": code},
|
||||||
|
ip_address,
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info(f"Admin {admin_id} approved invite request #{request_id}, code={code}")
|
||||||
|
return code
|
||||||
|
|
||||||
|
async def deny_invite_request(
|
||||||
|
self,
|
||||||
|
request_id: int,
|
||||||
|
admin_id: str,
|
||||||
|
ip_address: Optional[str] = None,
|
||||||
|
) -> Optional[dict]:
|
||||||
|
"""
|
||||||
|
Deny an invite request.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The request info (name, email) or None if not found/already handled.
|
||||||
|
"""
|
||||||
|
async with self.pool.acquire() as conn:
|
||||||
|
row = await conn.fetchrow(
|
||||||
|
"SELECT id, email, name FROM invite_requests WHERE id = $1 AND status = 'pending'",
|
||||||
|
request_id,
|
||||||
|
)
|
||||||
|
if not row:
|
||||||
|
return None
|
||||||
|
|
||||||
|
await conn.execute(
|
||||||
|
"""
|
||||||
|
UPDATE invite_requests
|
||||||
|
SET status = 'denied', reviewed_at = NOW(), reviewed_by = $1
|
||||||
|
WHERE id = $2
|
||||||
|
""",
|
||||||
|
admin_id,
|
||||||
|
request_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
await self.audit(
|
||||||
|
admin_id,
|
||||||
|
"deny_invite_request",
|
||||||
|
"invite_request",
|
||||||
|
str(request_id),
|
||||||
|
{"email": row["email"]},
|
||||||
|
ip_address,
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info(f"Admin {admin_id} denied invite request #{request_id}")
|
||||||
|
return {"name": row["name"], "email": row["email"]}
|
||||||
|
|
||||||
|
|
||||||
# Global admin service instance
|
# Global admin service instance
|
||||||
_admin_service: Optional[AdminService] = None
|
_admin_service: Optional[AdminService] = None
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Authentication service for Golf game.
|
Authentication service for Golf game.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Email service for Golf game authentication.
|
Email service for Golf game authentication.
|
||||||
|
|
||||||
@@ -164,6 +165,76 @@ class EmailService:
|
|||||||
|
|
||||||
return await self._send_email(to, subject, html)
|
return await self._send_email(to, subject, html)
|
||||||
|
|
||||||
|
async def send_invite_request_admin_notification(
|
||||||
|
self,
|
||||||
|
to: str,
|
||||||
|
requester_name: str,
|
||||||
|
requester_email: str,
|
||||||
|
message: str,
|
||||||
|
) -> Optional[str]:
|
||||||
|
"""Notify admin of a new invite request."""
|
||||||
|
if not self.is_configured():
|
||||||
|
logger.info(f"Email not configured. Would send invite request notification to {to}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
admin_url = f"{self.base_url}/admin.html"
|
||||||
|
message_html = f"<p><strong>Message:</strong> {message}</p>" if message else ""
|
||||||
|
|
||||||
|
subject = f"Golf Game invite request from {requester_name}"
|
||||||
|
html = f"""
|
||||||
|
<h2>New Invite Request</h2>
|
||||||
|
<p><strong>Name:</strong> {requester_name}</p>
|
||||||
|
<p><strong>Email:</strong> {requester_email}</p>
|
||||||
|
{message_html}
|
||||||
|
<p><a href="{admin_url}">Review in Admin Panel</a></p>
|
||||||
|
"""
|
||||||
|
|
||||||
|
return await self._send_email(to, subject, html)
|
||||||
|
|
||||||
|
async def send_invite_approved_email(
|
||||||
|
self,
|
||||||
|
to: str,
|
||||||
|
name: str,
|
||||||
|
invite_code: str,
|
||||||
|
) -> Optional[str]:
|
||||||
|
"""Notify requester that their invite was approved."""
|
||||||
|
if not self.is_configured():
|
||||||
|
logger.info(f"Email not configured. Would send invite approval to {to}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
signup_url = f"{self.base_url}/?invite={invite_code}"
|
||||||
|
|
||||||
|
subject = "Your Golf Game invite is ready!"
|
||||||
|
html = f"""
|
||||||
|
<h2>You're In, {name}!</h2>
|
||||||
|
<p>Your request to join Golf Game has been approved.</p>
|
||||||
|
<p>Use this link to create your account:</p>
|
||||||
|
<p><a href="{signup_url}">{signup_url}</a></p>
|
||||||
|
<p>Or sign up manually with invite code: <strong>{invite_code}</strong></p>
|
||||||
|
<p>This invite is single-use and expires in 7 days.</p>
|
||||||
|
"""
|
||||||
|
|
||||||
|
return await self._send_email(to, subject, html)
|
||||||
|
|
||||||
|
async def send_invite_denied_email(
|
||||||
|
self,
|
||||||
|
to: str,
|
||||||
|
name: str,
|
||||||
|
) -> Optional[str]:
|
||||||
|
"""Notify requester that their invite was denied."""
|
||||||
|
if not self.is_configured():
|
||||||
|
logger.info(f"Email not configured. Would send invite denial to {to}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
subject = "Golf Game invite request update"
|
||||||
|
html = f"""
|
||||||
|
<h2>Hi {name},</h2>
|
||||||
|
<p>Thanks for your interest in Golf Game. Unfortunately, we're not able to approve your invite request at this time.</p>
|
||||||
|
<p>We may open up registrations in the future — stay tuned!</p>
|
||||||
|
"""
|
||||||
|
|
||||||
|
return await self._send_email(to, subject, html)
|
||||||
|
|
||||||
async def _send_email(
|
async def _send_email(
|
||||||
self,
|
self,
|
||||||
to: str,
|
to: str,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
PostgreSQL-backed game logging for AI decision analysis.
|
PostgreSQL-backed game logging for AI decision analysis.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Matchmaking service for public skill-based games.
|
Matchmaking service for public skill-based games.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Redis-based rate limiter service.
|
Redis-based rate limiter service.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Glicko-2 rating service for Golf game matchmaking.
|
Glicko-2 rating service for Golf game matchmaking.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Game recovery service for rebuilding active games from event store.
|
Game recovery service for rebuilding active games from event store.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Replay service for Golf game.
|
Replay service for Golf game.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Spectator manager for Golf game.
|
Spectator manager for Golf game.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Stats service for Golf game leaderboards and achievements.
|
Stats service for Golf game leaderboards and achievements.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Golf AI Simulation Runner
|
Golf AI Simulation Runner
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""Stores package for Golf game V2 persistence."""
|
"""Stores package for Golf game V2 persistence."""
|
||||||
|
|
||||||
from .event_store import EventStore, ConcurrencyError
|
from .event_store import EventStore, ConcurrencyError
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
PostgreSQL-backed event store for Golf game.
|
PostgreSQL-backed event store for Golf game.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Redis pub/sub for cross-server game events.
|
Redis pub/sub for cross-server game events.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Redis-backed live game state cache.
|
Redis-backed live game state cache.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
PostgreSQL-backed user store for Golf game authentication.
|
PostgreSQL-backed user store for Golf game authentication.
|
||||||
|
|
||||||
@@ -132,6 +133,20 @@ CREATE TABLE IF NOT EXISTS invite_codes (
|
|||||||
is_active BOOLEAN DEFAULT TRUE
|
is_active BOOLEAN DEFAULT TRUE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Invite requests table
|
||||||
|
CREATE TABLE IF NOT EXISTS invite_requests (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
name VARCHAR(100) NOT NULL,
|
||||||
|
email VARCHAR(255) NOT NULL,
|
||||||
|
message TEXT,
|
||||||
|
status VARCHAR(20) DEFAULT 'pending',
|
||||||
|
ip_address INET,
|
||||||
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||||
|
reviewed_at TIMESTAMPTZ,
|
||||||
|
reviewed_by UUID REFERENCES users_v2(id),
|
||||||
|
invite_code_id BIGINT REFERENCES invite_codes(id)
|
||||||
|
);
|
||||||
|
|
||||||
-- Player stats table (extended for V2 leaderboards)
|
-- Player stats table (extended for V2 leaderboards)
|
||||||
CREATE TABLE IF NOT EXISTS player_stats (
|
CREATE TABLE IF NOT EXISTS player_stats (
|
||||||
id BIGSERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Test suite for AI decision sub-functions extracted from ai.py.
|
Test suite for AI decision sub-functions extracted from ai.py.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Tests for the GameAnalyzer decision evaluation logic.
|
Tests for the GameAnalyzer decision evaluation logic.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Tests for the authentication system.
|
Tests for the authentication system.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Test suite for 6-Card Golf game rules.
|
Test suite for 6-Card Golf game rules.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Test suite for WebSocket message handlers.
|
Test suite for WebSocket message handlers.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
House Rules Testing Suite
|
House Rules Testing Suite
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Test for the original Maya bug:
|
Test for the original Maya bug:
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Test suite for Room and RoomManager CRUD operations.
|
Test suite for Room and RoomManager CRUD operations.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Test suite for V3 features in 6-Card Golf.
|
Test suite for V3 features in 6-Card Golf.
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""Tests package for Golf game."""
|
"""Tests package for Golf game."""
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Tests for event sourcing and state replay.
|
Tests for event sourcing and state replay.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Tests for V2 Persistence & Recovery components.
|
Tests for V2 Persistence & Recovery components.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
"""
|
"""
|
||||||
Tests for the replay service.
|
Tests for the replay service.
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
from textual.app import ComposeResult
|
from textual.app import ComposeResult
|
||||||
from textual.containers import Container, Horizontal, Vertical
|
from textual.containers import Container, Horizontal, Vertical
|
||||||
from textual.screen import Screen
|
from textual.screen import Screen
|
||||||
@@ -23,6 +25,7 @@ class ConnectScreen(Screen):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._mode: str = "login" # "login" or "signup"
|
self._mode: str = "login" # "login" or "signup"
|
||||||
|
self._last_esc: float = 0.0
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
with Container(id="connect-container"):
|
with Container(id="connect-container"):
|
||||||
@@ -30,7 +33,7 @@ class ConnectScreen(Screen):
|
|||||||
|
|
||||||
# Login form
|
# Login form
|
||||||
with Vertical(id="login-form"):
|
with Vertical(id="login-form"):
|
||||||
yield Static("Log in to play")
|
yield Static("Log in to play\n")
|
||||||
yield Input(placeholder="Username", id="input-username")
|
yield Input(placeholder="Username", id="input-username")
|
||||||
yield Input(placeholder="Password", password=True, id="input-password")
|
yield Input(placeholder="Password", password=True, id="input-password")
|
||||||
with Horizontal(id="connect-buttons"):
|
with Horizontal(id="connect-buttons"):
|
||||||
@@ -64,7 +67,7 @@ class ConnectScreen(Screen):
|
|||||||
|
|
||||||
with Horizontal(classes="screen-footer"):
|
with Horizontal(classes="screen-footer"):
|
||||||
yield Static("", id="connect-footer-left", classes="screen-footer-left")
|
yield Static("", id="connect-footer-left", classes="screen-footer-left")
|
||||||
yield Static("\\[q] quit", id="connect-footer-right", classes="screen-footer-right")
|
yield Static("\\[q]uit or \\[esc]x2", id="connect-footer-right", classes="screen-footer-right")
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
self._update_form_visibility()
|
self._update_form_visibility()
|
||||||
@@ -103,11 +106,17 @@ class ConnectScreen(Screen):
|
|||||||
self._update_form_visibility()
|
self._update_form_visibility()
|
||||||
|
|
||||||
def handle_escape(self) -> None:
|
def handle_escape(self) -> None:
|
||||||
"""Escape goes back to login if on signup form."""
|
"""Escape goes back to login if on signup form. Double-escape quits."""
|
||||||
if self._mode == "signup":
|
if self._mode == "signup":
|
||||||
self._mode = "login"
|
self._mode = "login"
|
||||||
self._set_status("")
|
self._set_status("")
|
||||||
self._update_form_visibility()
|
self._update_form_visibility()
|
||||||
|
self._last_esc = 0.0
|
||||||
|
else:
|
||||||
|
now = time.monotonic()
|
||||||
|
if now - self._last_esc < 0.5:
|
||||||
|
self.app.exit()
|
||||||
|
self._last_esc = now
|
||||||
|
|
||||||
def on_input_submitted(self, event: Input.Submitted) -> None:
|
def on_input_submitted(self, event: Input.Submitted) -> None:
|
||||||
if event.input.id == "input-password":
|
if event.input.id == "input-password":
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class LobbyScreen(Screen):
|
|||||||
# In-room: player list + controls + settings
|
# In-room: player list + controls + settings
|
||||||
with Vertical(id="in-room"):
|
with Vertical(id="in-room"):
|
||||||
yield Static("", id="room-info")
|
yield Static("", id="room-info")
|
||||||
yield Static("[bold]Players[/bold]", id="player-list-label")
|
yield Static("[bold]Players[/bold]\n", id="player-list-label")
|
||||||
yield Static("", id="player-list")
|
yield Static("", id="player-list")
|
||||||
|
|
||||||
# CPU controls: compact [+] [-]
|
# CPU controls: compact [+] [-]
|
||||||
@@ -185,18 +185,18 @@ class LobbyScreen(Screen):
|
|||||||
yield Label("Wolfpack")
|
yield Label("Wolfpack")
|
||||||
yield Switch(id="sw-wolfpack")
|
yield Switch(id="sw-wolfpack")
|
||||||
|
|
||||||
with Collapsible(title="Deck Style", collapsed=True, id="coll-deck"):
|
with Horizontal(classes="setting-row"):
|
||||||
with Horizontal(classes="setting-row"):
|
yield Label("Deck Style")
|
||||||
yield Select(
|
yield Select(
|
||||||
[(name.replace("-", " ").title(), name) for name in DECK_PRESETS],
|
[(name.replace("-", " ").title(), name) for name in DECK_PRESETS],
|
||||||
value="classic",
|
value="classic",
|
||||||
id="sel-deck-style",
|
id="sel-deck-style",
|
||||||
allow_blank=False,
|
allow_blank=False,
|
||||||
)
|
)
|
||||||
yield Static(
|
yield Static(
|
||||||
self._render_deck_preview("classic"),
|
self._render_deck_preview("classic"),
|
||||||
id="deck-preview",
|
id="deck-preview",
|
||||||
)
|
)
|
||||||
|
|
||||||
yield Button("Start Game", id="btn-start", variant="success")
|
yield Button("Start Game", id="btn-start", variant="success")
|
||||||
|
|
||||||
@@ -398,15 +398,7 @@ class LobbyScreen(Screen):
|
|||||||
)
|
)
|
||||||
line3 = "".join(parts3)
|
line3 = "".join(parts3)
|
||||||
|
|
||||||
parts4: list[str] = []
|
return f"{line1}\n{line2}\n{line3}"
|
||||||
for color_name in seen:
|
|
||||||
hc = BACK_COLORS.get(color_name, BACK_COLORS["red"])
|
|
||||||
parts4.append(
|
|
||||||
f"[{bc}]└───┘[/{bc}] "
|
|
||||||
)
|
|
||||||
line4 = "".join(parts4)
|
|
||||||
|
|
||||||
return f"{line1}\n{line2}\n{line3}\n{line4}"
|
|
||||||
|
|
||||||
def _add_random_cpu(self) -> None:
|
def _add_random_cpu(self) -> None:
|
||||||
"""Add a random CPU (server picks the profile)."""
|
"""Add a random CPU (server picks the profile)."""
|
||||||
|
|||||||
@@ -205,9 +205,8 @@ LobbyScreen {
|
|||||||
|
|
||||||
#deck-preview {
|
#deck-preview {
|
||||||
width: auto;
|
width: auto;
|
||||||
height: auto;
|
height: 3;
|
||||||
padding: 1 1 0 1;
|
padding: 0 1;
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.rule-row {
|
.rule-row {
|
||||||
|
|||||||
Reference in New Issue
Block a user