Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mericozkayagan committed Dec 14, 2024
1 parent 9a4fdf2 commit 0623a70
Show file tree
Hide file tree
Showing 111 changed files with 7,825 additions and 912 deletions.
Binary file added .DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2
updates:
# Maintain dependencies for Python
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
target-branch: "main"
labels:
- "dependencies"
- "python"
commit-message:
prefix: "pip"
include: "scope"

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
target-branch: "main"
labels:
- "dependencies"
- "github-actions"
commit-message:
prefix: "github-actions"
include: "scope"
33 changes: 33 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Test

on:
pull_request:
branches: [ main, develop ]
push:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Check formatting with black
run: black --check .
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
language_version: python3.12

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
100 changes: 44 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,61 @@ A sophisticated text-based RPG that leverages AI to generate unique content, fea
- Inventory system with consumables and equipment
- Gold-based economy with configurable sell prices

### Multiplayer Support
- Turn-based combat with player queue
- Multiple players and enemies in combat
- Real-time communication using WebSockets
- Player authentication and session management
- Game state saving and loading

## Installation

### Prerequisites
- Python 3.12+
- OpenAI API key (for AI-generated content)
- PostgreSQL (for game state and session management)

### Setup
1. Clone the repository:
```bash
git clone https://github.com/yourusername/terminal-quest.git
cd terminal-quest
```
```bash
git clone https://github.com/yourusername/terminal-quest.git
cd terminal-quest
```

2. Install dependencies:
```bash
pip3 install -r requirements.txt
```
```bash
pip3 install -r requirements.txt
```

3. Create a `.env` file:
```env
OPENAI_API_KEY=your_key_here
```
```env
OPENAI_API_KEY=your_key_here
DATABASE_URL=your_postgresql_database_url
```

4. Run the game:
```bash
python3 main.py
```
4. Set up the PostgreSQL database:
- Ensure PostgreSQL is running.
- Create the necessary database and tables using the provided SQL scripts or migrations.

5. Run the server:
```bash
python src/services/server.py
```

6. Run the client:
```bash
python client/client.py
```

## Running the Game on a Server

To run the game on a server and allow players to connect from their machines, follow these steps:

1. Set up an AWS EC2 instance or any other cloud server.
2. Install the necessary dependencies on the server.
3. Configure the server to run the game as a service.
4. Use a WebSocket server to handle real-time communication between the server and clients.
5. Players can connect to the server using a client application that communicates with the server via WebSockets.

## Project Structure

Expand Down Expand Up @@ -111,45 +140,4 @@ terminal_quest/
## Best Practices

### Code Organization
- Modular design with clear separation of concerns
- Configuration centralized in settings.py
- Type hints throughout the codebase
- Comprehensive documentation and comments

### Error Handling
- Graceful fallback system for AI failures
- Input validation for all user interactions
- Proper exception handling for file and API operations

### Game Balance
- Configurable game constants in settings.py
- Balanced stat ranges for characters and items
- Progressive difficulty scaling
- Fair item drop rates and shop prices

### Performance
- Efficient status effect processing
- Minimal API calls with caching
- Optimized combat calculations

## Contributing

1. Fork the repository
2. Create a feature branch
3. Follow the established code style:
- Use type hints
- Follow PEP 8
- Add docstrings for functions and classes
- Update tests if applicable
4. Submit a pull request

## Future Enhancements
- Quest system
- More character classes
- Additional status effects
- Enhanced AI integration
- Saving/loading system
- Multiplayer support

## License
This project is licensed under the MIT License - see the LICENSE file for details.
- Modular design
34 changes: 34 additions & 0 deletions alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# alembic.ini
[alembic]
# path to migration scripts
script_location = migrations

# database connection URL
sqlalchemy.url = postgresql://rpg_user:secure_password@localhost:5432/rpg_game

[loggers]
keys = root, sqlalchemy

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
44 changes: 44 additions & 0 deletions client/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import asyncio
import websockets
import json


async def connect_to_server():
uri = "ws://localhost:8765"
async with websockets.connect(uri) as websocket:
# Authenticate player
await websocket.send(
json.dumps(
{"action": "authenticate", "username": "player", "password": "password"}
)
)
response = await websocket.recv()
print(response)

# If class selection is required
response_data = json.loads(response)
if "classes" in response_data:
print("Available classes:")
for i, class_name in enumerate(response_data["classes"], 1):
print(f"{i}. {class_name}")

class_choice = int(input("Select your class: ")) - 1
selected_class = response_data["classes"][class_choice]

# Send class selection to server
await websocket.send(
json.dumps({"action": "select_class", "class_name": selected_class})
)
response = await websocket.recv()
print(response)

# Load game state
await websocket.send(
json.dumps({"action": "load_game_state", "player": {"name": "player"}})
)
response = await websocket.recv()
print(response)


if __name__ == "__main__":
asyncio.run(connect_to_server())
20 changes: 20 additions & 0 deletions data/art/blood_sovereign.txt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀♦♦♦♦♦♦♦♦♦▀▀▀▀▀
▀▀▀▀▀▀▀███████▀▀▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀║▀█◆███◆█▀║▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀║▀███████▀║▀▀▀▀
▀▀▀▀▀▀▀███████▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
15 changes: 15 additions & 0 deletions data/art/class_shadow_revenant.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


║ ▄▄███████████▄
║ ▄█▀▓▒░░░░░░▒▓▀█▄
║ ██░░╳┌┐ └┘░█
║ ██╱░─┼┼─╲▁ ▂╱─┤██
║ █▒█│◆│ ▃ │█
║ █▓█╲┴┴─┘ ▅ └─╱█▓
║ ██▓██╳╲ ▆ █
║ ████╱◥──────◤╲███
║ ██╱█▒█╳◣──────◢╱█╲
║ ██╌█─◆│─◤──────◥─│◆
║ ██╌│───◢───────◣───
║ ██╳│──────────────
Loading

0 comments on commit 0623a70

Please sign in to comment.