Skip to content

Commit ea6d09b

Browse files
feat: Port 'War Card Game' to the Web App
1 parent a6e5f66 commit ea6d09b

4 files changed

Lines changed: 959 additions & 6 deletions

File tree

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# 🎮 Python Mini Projects Collection 🎯
66

7-
### *Learn Python by Building Fun, Interactive Games & Tools!*
7+
### _Learn Python by Building Fun, Interactive Games & Tools!_
88

99
[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
1010
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
@@ -53,7 +53,6 @@
5353
- [📝 License](#-license)
5454
- [💬 Connect & Share](#-connect--share)
5555

56-
5756
## 🎯 Repo Introduction
5857

5958
This repository is a collection of small Python games and utility projects built to make learning Python more practical and engaging. It includes both command-line projects and a browser-based web app for trying the projects online.
@@ -110,18 +109,21 @@ cd python-mini-project
110109
#### 2. Create a Virtual Environment
111110

112111
For Linux/macOS:
112+
113113
```bash
114114
python3 -m venv venv
115115
source venv/bin/activate
116116
```
117117

118118
For Windows (Command Prompt):
119+
119120
```bash
120121
python -m venv venv
121122
venv\Scripts\activate
122123
```
123124

124125
For Windows (PowerShell):
126+
125127
```bash
126128
python -m venv venv
127129
venv\Scripts\Activate.ps1
@@ -166,6 +168,7 @@ The web application provides a browser-based interface for all projects.
166168
#### Prerequisites for Web App
167169

168170
The web app requires Node.js and npm:
171+
169172
- Download from https://nodejs.org/ (v16 or higher recommended)
170173
- Verify installation: `node --version && npm --version`
171174

@@ -188,6 +191,7 @@ pytest tests/ -v
188191
```
189192

190193
For specific test file:
194+
191195
```bash
192196
pytest tests/test_armstrong.py -v
193197
```
@@ -212,6 +216,7 @@ pytest tests/test_armstrong.py -v
212216
#### Virtual Environment Reminder
213217

214218
Always activate your virtual environment before working:
219+
215220
```bash
216221
# Linux/macOS
217222
source venv/bin/activate
@@ -221,6 +226,7 @@ venv\Scripts\activate
221226
```
222227

223228
Deactivate when done:
229+
224230
```bash
225231
deactivate
226232
```
@@ -237,6 +243,7 @@ deactivate
237243
The browser app currently exposes 38 projects:
238244

239245
### Games
246+
240247
- 2048 Game
241248
- BlackJack21
242249
- Coin Flip
@@ -255,8 +262,10 @@ The browser app currently exposes 38 projects:
255262
- Whack-a-Mole
256263
- Word Scramble
257264
- Spot the Difference
265+
- War Card Game
258266

259267
### Math
268+
260269
- AP/GP/AGP/HP Recognizer
261270
- Armstrong Numbers
262271
- Binary Search
@@ -272,6 +281,7 @@ The browser app currently exposes 38 projects:
272281
- Progress Tracker
273282

274283
### Utilities
284+
275285
- AI Resume Analyzer
276286
- Color Palette Suggestor
277287
- Morse Code
@@ -286,7 +296,6 @@ These standalone Python project files do not have a browser counterpart yet and
286296

287297
- [games/Number-Sliding-Puzzle/Number-Sliding-Puzzle.py](games/Number-Sliding-Puzzle/Number-Sliding-Puzzle.py)
288298
- [games/Reverse-Hangman-Game/Reverse-Hangman-Game.py](games/Reverse-Hangman-Game/Reverse-Hangman-Game.py)
289-
- [games/War-Card-Game/War-Card-Game.py](games/War-Card-Game/War-Card-Game.py)
290299
- [math/Happy-Number/Happy-Number.py](math/Happy-Number/Happy-Number.py)
291300
- [math/Matrix-Calculator/Matrix-Calculator.py](math/Matrix-Calculator/Matrix-Calculator.py)
292301
- [math/Quadratic-Solver/Quadratic-Solver.py](math/Quadratic-Solver/Quadratic-Solver.py)
@@ -1159,7 +1168,7 @@ Found this helpful? Show some love!
11591168

11601169
**Made with ❤️ for Python learners everywhere**
11611170

1162-
*If you learned something new, don't forget to star the repo! ⭐*
1171+
_If you learned something new, don't forget to star the repo! ⭐_
11631172

11641173
[⬆ Back to Top](#-python-mini-projects-collection-)
11651174

web-app/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ <h3>Legal</h3>
872872
<script defer src="js/playground.js"></script>
873873
<script defer type="module" src="js/main.js"></script>
874874
<script defer src="js/hero-canvas.js"></script>
875+
<script defer src="js/projects/war-card-game.js"></script>
875876
<script>
876877
lucide.createIcons();
877878
</script>
@@ -997,6 +998,13 @@ <h3>Legal</h3>
997998
desc: "Friendship relationship calculator",
998999
tags: "game,relationship",
9991000
},
1001+
{
1002+
project: "war-card-game",
1003+
title: "War Card Game",
1004+
category: "games",
1005+
desc: "A classic two-player card game based on comparing rank values",
1006+
tags: "game,cards,multiplayer,war",
1007+
},
10001008

10011009
// MATH (15+)
10021010
{

web-app/js/projects.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Project Registry
1+
// Project Registry
22
// Each project's HTML and logic lives in its own file under js/projects/
33

44
function getProjectHTML(projectName) {
@@ -1595,6 +1595,17 @@ function getProjectHTML(projectName) {
15951595

15961596
const projectInstructions = {
15971597
// GAMES
1598+
"war-card-game": {
1599+
title: "⚔️ How to Play War Card Game",
1600+
steps: [
1601+
"Enter names or check the option to play against the CPU.",
1602+
"Each player starts with a deck of 26 cards.",
1603+
"Click 'Draw / Battle' to draw the top card from both decks.",
1604+
"The player with the higher card rank wins the round and gets a point.",
1605+
"Ace is the highest, 2 is the lowest.",
1606+
"Play continues until all cards are drawn. The player with the most points wins!"
1607+
]
1608+
},
15981609
"2048-game": {
15991610
title: "🎮 How to Play 2048",
16001611
steps: [
@@ -3127,7 +3138,8 @@ function initializeProject(projectName) {
31273138
"color-palette": "initColorPalette",
31283139
"math-quiz": "initMathQuiz",
31293140
"resume-analyzer": "initResumeAnalyzer",
3130-
"caesar-cipher": "initCaesarCipher"
3141+
"caesar-cipher": "initCaesarCipher",
3142+
"war-card-game": "initWarCardGame"
31313143
};
31323144

31333145
const initializerName = initializers[projectName];

0 commit comments

Comments
 (0)