Skip to content

Commit 9051db8

Browse files
committed
Add 'grand-gardenias/' from commit '43dfd3c2ec07ac2c77d390efabc6105d0769c0df'
git-subtree-dir: grand-gardenias git-subtree-mainline: 2c2d794 git-subtree-split: 43dfd3c
2 parents 2c2d794 + 43dfd3c commit 9051db8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5569
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# GitHub Action workflow enforcing our code style.
2+
3+
name: Lint
4+
5+
# Trigger the workflow on both push (to the main repository, on the main branch)
6+
# and pull requests (against the main repository, but from any repo, from any branch).
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
13+
# Brand new concurrency setting! This ensures that not more than one run can be triggered for the same commit.
14+
# It is useful for pull requests coming from the main repository since both triggers will match.
15+
concurrency: lint-${{ github.sha }}
16+
17+
jobs:
18+
lint:
19+
runs-on: ubuntu-latest
20+
21+
env:
22+
# The Python version your project uses. Feel free to change this if required.
23+
PYTHON_VERSION: "3.12"
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Python ${{ env.PYTHON_VERSION }}
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ env.PYTHON_VERSION }}
33+
34+
- name: Run pre-commit hooks
35+
uses: pre-commit/action@v3.0.1

grand-gardenias/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Files generated by the interpreter
2+
__pycache__/
3+
*.py[cod]
4+
5+
# Environment specific
6+
.venv
7+
venv
8+
.env
9+
env
10+
11+
# Unittest reports
12+
.coverage*
13+
14+
# Logs
15+
*.log
16+
17+
# PyEnv version selector
18+
.python-version
19+
20+
# Built objects
21+
*.so
22+
dist/
23+
build/
24+
25+
# IDEs
26+
# PyCharm
27+
.idea/
28+
# VSCode
29+
.vscode/
30+
# MacOS
31+
.DS_Store
32+
33+
# npm and tailwindcss
34+
# Dependency directory
35+
node_modules/
36+
37+
# Generated files
38+
dist/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Pre-commit configuration.
2+
# See https://github.com/python-discord/code-jam-template/tree/main#pre-commit-run-linting-before-committing
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v5.0.0
7+
hooks:
8+
- id: check-toml
9+
- id: check-yaml
10+
- id: end-of-file-fixer
11+
- id: trailing-whitespace
12+
args: [--markdown-linebreak-ext=md]
13+
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.12.2
16+
hooks:
17+
- id: ruff-check
18+
- id: ruff-format

grand-gardenias/LICENSE.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2021 Python Discord
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

grand-gardenias/README.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<p align="center">
2+
<img src="docs/img/logo.svg" alt="Project Logo" width="200"/>
3+
</p>
4+
5+
# 👾 Tetris Bugs: The Code Editor You Never Asked For
6+
7+
Built by **Grand Gardenias** for Python Discord's Summer CodeJam 2025. Challenge theme: **Wrong Tool for the Job** using **Python in the Browser** via [Pyscript](https://pyscript.net/).
8+
9+
---
10+
11+
## 🎯 The Concept
12+
13+
Instead of typing code like a normal human, you now have to **catch falling code blocks** and arrange them into working programs.
14+
15+
## 🎮 Game Modes (Choose Your Suffering)
16+
17+
### 1. 🏗️ Tetris Code Editor
18+
19+
- New File
20+
- Export/Save
21+
- Undo/Redo
22+
- Run Code
23+
- Terminal Output
24+
- Code Falls from Sky
25+
26+
### 2. ⚡ CodeRush Mode
27+
28+
- 5-minute timer counting down
29+
- Questions show up on the left
30+
- Solve as many as you can before time’s up
31+
- Your score = how many problems you solved before the end
32+
33+
### 3. 🗡️ Roguelike Mode
34+
35+
- We provide the CORRECT solution
36+
- Arrange the blocks properly to "clear" lines like Tetris
37+
- Wrong arrangements stack up
38+
- Reach the top = GAME OVER
39+
40+
### 4. We could not finish the multiplayer mode, but it is documented in [docs/goals.md](docs/goals.md)
41+
42+
## 🛠️ Tech Stack
43+
44+
- **PyScript**
45+
- **TailwindCSS**
46+
47+
## 📦 Requirements
48+
49+
- Python 3.13+
50+
- Node.js & npm
51+
52+
## ⚙️ Setup Instructions
53+
54+
1. Clone the repository:
55+
```shell
56+
git clone https://github.com/zishankadri/tetris-bugs.git
57+
cd tetris-bugs
58+
```
59+
3. Start a local Server:
60+
```shell
61+
cd frontend
62+
npm install
63+
npm run build
64+
python -m http.server
65+
```
66+
67+
3. **Open Your Browser** to `http://localhost:8000`
68+
4. 💡 For Contributors: Run `npm run dev` to auto-update Tailwind while you code.
69+
70+
## 🎉 Achievement Unlocked
71+
**Congratulations! You now have the most unique answer to "What IDE do you use?"**
72+
73+
*"Oh, I use Tetris."*
74+
75+
## Video Presentation
76+
[code-editor.webm](https://github.com/user-attachments/assets/cf059496-4f29-4d98-a95a-8969f91b333e)
77+
78+
<details>
79+
<summary>⚡ CodeRush Video Presentation </summary>
80+
https://drive.google.com/file/d/1t6_92z2R_ntOok2yyzjklHpKyxoKZl_g/view
81+
</details>
82+
83+
<details>
84+
<summary>🗡️ Roguelike (BETA) Video Presentation </summary>
85+
86+
[roguelike.webm](https://github.com/user-attachments/assets/ffc35054-e3de-4e12-ac63-f1e3520f2ee8)
87+
</details>
88+
89+
## 📸 Screenshots
90+
<details>
91+
<summary>Preview Images 📸</summary>
92+
<img width="1314" height="655" alt="code-editor" src="https://github.com/user-attachments/assets/d3d61ead-39b7-44e8-b62f-207709f3b1b6" />
93+
<img width="1360" height="676" alt="code-editor" src="https://github.com/user-attachments/assets/b8d619c7-280e-4e5e-b9b6-c59bfa21ccf9" />
94+
<img width="1360" height="768" alt="code-rush" src="https://github.com/user-attachments/assets/6f6c9027-1017-43cc-95ef-c971d493ccb7" />
95+
<img width="1360" height="676" alt="roguelike" src="https://github.com/user-attachments/assets/4142aa8b-012b-4f29-85a0-8624e1ef33e5" />
96+
<img width="1311" height="655" alt="menu" src="https://github.com/user-attachments/assets/1220ca0c-c8a3-49f1-a50d-1bd76965e989" />
97+
98+
</details>
99+
100+
## 🎯 Wrong Tool for the Job
101+
102+
✅ Using Tetris as an IDE
103+
✅ Spatial reasoning for coding problems
104+
105+
With some tweaks and backend, this could be a useful tool as a coding qualifier, as we doubt any LLM alone could pass this test.
106+
107+
## 🤝 Credits
108+
109+
(in order of contributed LOC):
110+
111+
<table>
112+
<tr>
113+
<th></th>
114+
<th>Name</th>
115+
<th>Contributions</th>
116+
</tr>
117+
<tr>
118+
<td><a href="https://github.com/zishankadri"><img src="https://github.com/zishankadri.png" alt="Luffy" width="64"></a></td>
119+
<td><a href="https://github.com/zishankadri">Luffy</a></td>
120+
<td>Lead developer, Project architecture, Ideation, Frontend</td>
121+
</tr>
122+
<tr>
123+
<td><a href="https://github.com/rxdiationx"><img src="https://github.com/rxdiationx.png" alt="rxdiationx" width="64"></a></td>
124+
<td><a href="https://github.com/rxdiationx">rxdiationx</a></td>
125+
<td>Base of CodeRush, sound effects/music, loading screen, Sourcing of problems</td>
126+
</tr>
127+
<tr>
128+
<td><a href="https://github.com/Sapient44"><img src="https://github.com/Sapient44.png" alt="Sapient44" width="64"></a></td>
129+
<td><a href="https://github.com/Sapient44">Sapient44</a></td>
130+
<td>Terminal and code execution, Modifications in roguelike mode, Sourcing of audio</td>
131+
</tr>
132+
<tr>
133+
<td><a href="https://github.com/Shivk123"><img src="https://github.com/Shivk123.png" alt="Shivk123" width="64"></a></td>
134+
<td><a href="https://github.com/Shivk123">Shivk123</a></td>
135+
<td>Meeting facilitation, Initial file structure, Set up Flask backend</td>
136+
</tr>
137+
<tr>
138+
<td><a href="https://github.com/mhasanali2010"><img src="https://github.com/mhasanali2010.png" alt="mhasanali2010" width="64"></a></td>
139+
<td><a href="https://github.com/mhasanali2010">mhasanali2010</a></td>
140+
<td>timer logic, pause screen</td>
141+
</tr>
142+
</table>

grand-gardenias/backend/__init__.py

Whitespace-only changes.

grand-gardenias/backend/app.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Define paths
2+
from pathlib import Path
3+
4+
from flask import Flask, render_template
5+
6+
template_dir = Path(__file__).resolve().parent.parent / "frontend"
7+
static_dir = template_dir # if your CSS/JS/config are in frontend/
8+
9+
app = Flask(
10+
__name__,
11+
template_folder=template_dir,
12+
static_folder=static_dir, # serve static files from frontend/
13+
static_url_path="", # serve at root so /config.json works
14+
)
15+
16+
17+
@app.route("/")
18+
def home() -> None:
19+
"""Render the main page."""
20+
# Render the index.html file from the frontend directory
21+
return render_template("index.html")

grand-gardenias/backend/run.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import shutil
2+
import subprocess
3+
import sys
4+
from pathlib import Path
5+
6+
from flask.cli import main as flask_main
7+
8+
DEFAULT_ARG_COUNT = 2 # Avoid magic number
9+
10+
11+
def main() -> None:
12+
"""Run the Flask application and start the frontend development server."""
13+
frontend_dir = Path(__file__).parent.parent / "frontend"
14+
15+
# Locate npm safely
16+
npm_path = shutil.which("npm")
17+
if npm_path is None:
18+
print("npm not found in PATH.")
19+
sys.exit(1)
20+
21+
# Start npm dev server
22+
try:
23+
subprocess.Popen( # noqa: S603
24+
[npm_path, "run", "dev"],
25+
cwd=frontend_dir,
26+
)
27+
print("Frontend dev server started.")
28+
except OSError as err:
29+
print(f"Failed to start frontend: {err}")
30+
31+
sys.argv.insert(1, "--app=backend.app")
32+
33+
if len(sys.argv) == DEFAULT_ARG_COUNT:
34+
sys.argv.append("run")
35+
36+
flask_main()
37+
38+
39+
if __name__ == "__main__":
40+
main()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Project Architecture
2+
3+
*(See ![Architecture Diagram](img/architecture-diagram.svg) for visual reference.)*
4+
5+
**Goal:** Avoid circular imports, enable reuse across modes, separate concerns.
6+
7+
## Layers
8+
9+
1. **Objects Layer** — self-contained game entities (no external knowledge).
10+
2. **Core Game Management** — orchestrates state, no DOM access.
11+
3. **Support Modules** — UI Manager, controls, block generators.
12+
13+
**Entry Point:** `main` wires components together and selects the mode.
14+
15+
## Dependency Rules
16+
17+
- Objects → no outward dependencies.
18+
- Game Manager → can talk to objects & support modules, but no cycles.
19+
- UI Manager → DOM Manipulation.
20+
- Controls → interact with Game Manager and objects only.
21+
- `main` → composition root, no logic.
22+
23+
Modes can add their own files, but they must follow the same rules.

grand-gardenias/docs/goals.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# MULTIPLAYER
2+
3+
![multiplayer screen](img/multiplayer.svg)
4+
5+
## THE CONCEPT OF 👾 Bugs
6+
7+
Occasionally, instead of the actual code blocks, the player will receive bugs from a number of pre-defined weapons in a class named 'Bugs' e.g. Bugs.beetle(). I originally thought of Bugs.bomb (), which on placing will immediately disappear from the player's own screen, but a bomb will appear at the same spot on the enemy's screen touching which will require the enemy to do over that one block, giving us a 'time advantage'. This will make so much sense if we create a 'time-based winner' game. (Open to suggestions this is just an example I have in mind for now.)
8+
9+
![bugs](img/special-block.svg)
10+
11+
## Bugs.beetle()
12+
13+
![bugs](img/bugs.svg)

0 commit comments

Comments
 (0)