Skip to content

Commit d9731f1

Browse files
fboucherCopilot
andauthored
Enhances dungeon game with new features and fixes (#141)
* Adds room editing dialog Adds a dialog to edit room properties, specifically the position of doors. This allows users to adjust room layouts and door placements after a room has been created. * Enables door repositioning in room editor Implements functionality to move door positions within the room editor dialog. This allows users to fine-tune door placement within a room, enhancing the level design process. It dynamically shows the correct axes of movement by looking at door direction and only displaying the perpendicular movement axes. * Enables moving exits in room editor Allows adjusting the position of exits on walls within the room editor. This change introduces functionality to dynamically update exit positions, providing a more intuitive and interactive editing experience. The "Modal" property of the dialog was set to false to allow background interaction. * Improves door placement in room editor Replaces directional buttons with a slider for precise door positioning on walls. This change allows users to visually adjust the door's location within the room editor dialog, enhancing the user experience. * add id on div to identify map context menu * Improves map menu placement. Makes the map menu stick to the top of the screen to prevent it from scrolling off-screen during gameplay. * Initial plan * Implement maps-menu enable/disable based on nextRoom draft state Co-authored-by: FBoucher <2404846+FBoucher@users.noreply.github.com> * When dialogue cancelled nextroom should be set to null * Disables room buttons when no room exists Disables the "Add Room" and "Edit Room" buttons when there isn't a room to add or edit. This prevents the user from interacting with those features when they are not available and improves the user experience. * Corrects door placement on the map Adjusts the positioning of doors on the map to ensure they are placed outside the adjacent room's boundary. Simplifies door drawing logic, ensuring doors are consistently drawn as full squares. * Fixes typo in new room dialog Corrects a typo in the new room dialog where "gameTurn" should be "get". This improves the readability of the generated room description for the user. * Corrects door placement on the map Adjusts the door coordinate calculation to ensure doors are placed correctly relative to rooms. The canvas drawing logic was also reviewed, and unnecessary offset code for vertical doors was removed. * Updates save game count to use adventure previews fixes #119 Changes the implementation of GetSaveGameCount to utilize the GetAdventurePreviews method, providing a more accurate count of saved games. Adds .gitignore file for Rider IDE to ignore IDE specific files. * Adds adventure deletion functionality Implements the ability to delete saved adventures. This change introduces a delete endpoint in the service and a corresponding button in the adventure picker component. When a user clicks the delete button, the selected adventure is removed and the adventure list is refreshed. * Fixes adventure deletion event handling Stops event propagation on the adventure deletion button to prevent unintended row selection when deleting an adventure. Also, adds project-level IDE configuration files. * Refactors adventure preview loading Improves the adventure picker component by extracting the adventure preview loading logic into a separate method. This change enhances code readability and maintainability. Also, this fixes a potential UI update issue by explicitly calling StateHasChanged after loading previews when deleting an adventure. * Adds adventurer deletion functionality Enables the deletion of adventurers, ensuring that an adventurer can only be deleted if it is not currently associated with any existing adventures. This prevents data integrity issues and provides a safeguard against accidentally deleting adventurers that are actively used in a game. * Add "Start a new fight" button to reset combat screen - fixes #116 (#124) * Initial analysis of issue #116 - combat screen reset functionality Co-authored-by: FBoucher <2404846+FBoucher@users.noreply.github.com> * Implement "Start a new fight" button to reset combat screen - fixes #116 Co-authored-by: FBoucher <2404846+FBoucher@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: FBoucher <2404846+FBoucher@users.noreply.github.com> * Add adventure name property and use adventurer ID reference (#126) * Initial plan * Add adventure name feature - update domain models and services Co-authored-by: FBoucher <2404846+FBoucher@users.noreply.github.com> * Remove foreign key constraint from adventures table Co-authored-by: FBoucher <2404846+FBoucher@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: FBoucher <2404846+FBoucher@users.noreply.github.com> * Add complete Dungeon theme with custom backgrounds, text, and accent colors (#128) * Initial plan * Add Dungeon theme option to Settings page Co-authored-by: fboucher <2404846+fboucher@users.noreply.github.com> * Address code review feedback - improve theme persistence Co-authored-by: fboucher <2404846+fboucher@users.noreply.github.com> * Updates Aspire SDK and package versions Updates the Aspire.AppHost.Sdk version in the AppHost project file. Adds a Directory.Packages.props file to manage package versions centrally, and updates various Aspire and related package versions to their latest releases, ensuring consistency and compatibility across the solution. * Implement full Dungeon theme with custom backgrounds and text colors Co-authored-by: fboucher <2404846+fboucher@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fboucher <2404846+fboucher@users.noreply.github.com> Co-authored-by: fboucher <fboucher@outlook.com> * Implement door type drawing functions with lock/unlock feature for dungeon map (#129) * Implement door details with different door types (Archway, Wooden, Metal, Reinforced, Curtain, Portcullis, Stone Slab) Co-authored-by: fboucher <2404846+fboucher@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fboucher <2404846+fboucher@users.noreply.github.com> * Fix: Addresses combobox selection and map debug issues (#130) Addresses an issue where combobox selections were not handled correctly. Now correctly passes the selected object instead of just the ID. Also adds debug logging to help resolve an intermittent map drawing issue. * Upgrades .NET and Aspire dependencies (#132) * upgrade in progress * feat(dab): Configure connection string via environment variable Configures the Data API Builder (DAB) connection string using an environment variable. This change ensures that the connection string for the database is properly set within the DAB configuration, especially during upgrade scenarios. It removes the port from the DAB template and constructs the connection string dynamically in code, referencing the MySQL resource's properties. * Replaces bind mount with file copy Replaces the bind mount approach for database initialization with a simpler file copy mechanism. This change simplifies the setup process, especially during upgrades, by ensuring that database scripts are copied directly into the container. * Implements combat turn management. (#134) Adds logic to manage combat turns, including identifying the current fighter and alternating turns between adventurer and creature. Introduces a dialog to select the first fighter and displays the current turn information. Fixes: #133 * Implements game over and victory conditions (#136) Adds logic to handle adventurer and creature defeats, displaying appropriate messages. Disables user interaction after combat ends to prevent further actions. Resets health depletion flags and UI elements on new fight start. Fixes #135 * Adds damage dice rolling functionality (#138) Implements the ability to roll damage dice within the combat page. This allows players to simulate damage rolls using 1D6 or 2D6 dice. Issue #137 * Removes seed adventurers from database (#139) * Removes demo adventurers from seed data Removes the demo adventurers from the database seed data. This prevents the creation of unnecessary or test adventurers when the database is initialized, ensuring a cleaner and more realistic initial state. * Removes demo adventurers from seed data The demo adventurers are no longer needed in the database seed data. This commit removes them. * Enables local Docker deployment (#140) * Adds Docker configuration for local development Sets up Docker Compose to orchestrate the application, database, and data api builder services for local development. Includes Dockerfile for the web client. Ensures database creation if it doesn't exist. Includes `.dockerignore` to exclude unnecessary files during image builds. Sets up `.env.example` with required environment variables * Enables running the app locally with Docker Provides a `docker-compose.yml` file for easy local deployment using Docker. Adds Dockerfiles for the database, Data API Builder (DAB), and web app components. Includes an `.env.example` file with configurable environment variables. Publishes images to Docker Hub upon tagging a commit. Fixes #91 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 99e6dd2 commit d9731f1

Some content is hidden

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

53 files changed

+1452
-167
lines changed

.aspire/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"appHostPath": "../src/AppHost/AppHost.csproj"
3+
}

.env.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Docker Hub namespace (username or org)
2+
DOCKERHUB_NAMESPACE=your-dockerhub-username
3+
# Image tag to pull with compose; usually matches the git tag that published the images
4+
IMAGE_TAG=latest
5+
6+
# Database settings
7+
MYSQL_ROOT_PASSWORD=changeme
8+
MYSQL_DATABASE=db2d6
9+
MYSQL_PORT=3306
10+
11+
# Data API Builder
12+
DAB_PORT=5000
13+
14+
# Web app
15+
WEBAPP_PORT=8080
16+
ASPNETCORE_ENVIRONMENT=Production
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish Docker images
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to Docker Hub
25+
uses: docker/login-action@v3
26+
with:
27+
username: ${{ secrets.DOCKERHUB_USERNAME }}
28+
password: ${{ secrets.DOCKERHUB_TOKEN }}
29+
30+
- name: Build and push database image
31+
uses: docker/build-push-action@v6
32+
with:
33+
context: .
34+
file: database/Dockerfile
35+
platforms: linux/amd64,linux/arm64
36+
push: true
37+
tags: |
38+
${{ secrets.DOCKERHUB_USERNAME }}/2d6-dungeon-database:${{ github.ref_name }}
39+
${{ secrets.DOCKERHUB_USERNAME }}/2d6-dungeon-database:latest
40+
41+
- name: Build and push DAB image
42+
uses: docker/build-push-action@v6
43+
with:
44+
context: .
45+
file: database/dab/Dockerfile
46+
platforms: linux/amd64,linux/arm64
47+
push: true
48+
tags: |
49+
${{ secrets.DOCKERHUB_USERNAME }}/2d6-dungeon-dab:${{ github.ref_name }}
50+
${{ secrets.DOCKERHUB_USERNAME }}/2d6-dungeon-dab:latest
51+
52+
- name: Build and push web app image
53+
uses: docker/build-push-action@v6
54+
with:
55+
context: src
56+
file: src/2d6-dungeon-web-client/Dockerfile
57+
platforms: linux/amd64,linux/arm64
58+
push: true
59+
tags: |
60+
${{ secrets.DOCKERHUB_USERNAME }}/2d6-dungeon-app:${{ github.ref_name }}
61+
${{ secrets.DOCKERHUB_USERNAME }}/2d6-dungeon-app:latest

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,45 @@ While I prototype functionalities, and make progress I create content (blog post
3232
- 📺 [How to Create a DEV Environment with Multiple Dev Containers](https://www.youtube.com/watch?v=sf3Ai4271nA)
3333

3434

35-
### How to Run it Locally
35+
### Run it Locally
3636

37-
The solution uses .NET Aspire to manage all the services and website.
37+
#### For Players (No coding experience needed!)
3838

39-
- You will need Docker [Docker](https://docs.docker.com/desktop/) or [Podman](https://podman.io/), and [.NET 9](https://dotnet.microsoft.com/en-us/download) installed.
39+
**Requirements:** [Docker Desktop](https://www.docker.com/products/docker-desktop/) must be installed and running on your computer.
40+
41+
Want to play 2D6 Dungeon? Follow these simple steps:
42+
43+
1. **Create a game folder**
44+
- Create a new folder on your computer (name it anything you like, e.g., "2d6-game")
45+
- Open a terminal/command prompt and navigate to that folder
46+
47+
2. **Download the configuration**
48+
- Run this command to download the game configuration:
49+
```
50+
curl -o docker-compose.yml https://raw.githubusercontent.com/FBoucher/2d6-dungeon-app/main/docker-compose.yml
51+
```
52+
53+
3. **Start the game**
54+
- Run this command:
55+
```
56+
docker-compose up -d --build
57+
```
58+
- Wait a minute for everything to download and start
59+
60+
4. **Play!**
61+
- Open your web browser and go to: `http://localhost:8080`
62+
- Start your adventure!
63+
64+
**To stop playing:** Run `docker-compose down` in your game folder.
65+
66+
67+
#### For Developers
68+
69+
The solution uses .NET Aspire to manage all the services and website.
70+
71+
- You will need [Docker](https://docs.docker.com/desktop/) or [Podman](https://podman.io/), and [.NET 10](https://dotnet.microsoft.com/en-us/download) installed.
4072
- Clone the repository locally.
41-
- To start 2d6-dungeon-client, from Open the solution in VSCode or Visual Studio and press F5. If asked for the starting point of the solution select the orchestrator `AppHost`. Once the solution starts it will:
73+
- Open the solution in VSCode or Visual Studio and press F5. If asked for the starting point of the solution select the orchestrator `AppHost`. Once the solution starts it will:
4274
- Open the .NET Aspire Dashboard in a web browser.
4375
- Create a MySQL container, create the database using the SQL script included.
4476
- Create a data API, in a second container.

database/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM mysql:8.0
2+
3+
# Default database name; can be overridden at runtime
4+
ENV MYSQL_DATABASE=db2d6
5+
ENV MYSQL_ROOT_HOST=%
6+
7+
# Ship schema and seed data inside the image so containers start ready-to-use
8+
COPY database/scripts/ /docker-entrypoint-initdb.d/
9+
10+
EXPOSE 3306

database/dab-config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
2-
"$schema": "https://github.com/Azure/data-api-builder/releases/download/v0.8.51/dab.draft.schema.json",
2+
"$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.6.84/dab.draft.schema.json",
33
"data-source": {
44
"database-type": "mysql",
55
"connection-string": "@env('ConnectionStrings__db2d6')",
66
"options": {}
77
},
8+
89
"runtime": {
10+
"health": {
11+
"max-query-parallelism": 8
12+
},
913
"rest": {
1014
"enabled": true,
1115
"path": "/api"

database/dab/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM mcr.microsoft.com/azure-databases/data-api-builder:latest
2+
WORKDIR /App
3+
# Bundle the static DAB configuration; connection string provided at runtime
4+
COPY database/dab-config.json ./dab-config.json
5+
CMD ["--ConfigFileName", "/App/dab-config.json"]

database/mssql/data-mssql.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ INSERT INTO dbo.rooms(roll, level, room_type, size, description, exits, is_uniqu
5151
VALUES (4,1,'Church', 'large','This room is lined with pews and chairs. Behind am allar...', 'Wooden doors',1);
5252

5353

54-
-- demo adventurers
55-
INSERT INTO dbo.adventurers(name, level, xp) VALUES('Toby the Creator', 1, 100);
56-
INSERT INTO dbo.adventurers(name, level, xp) VALUES('Frank', 0, 0);
57-
5854

5955
-- weapons
6056
INSERT INTO dbo.weapons(id, name) VALUES(1, 'LONGSWORD');

database/scripts/1-schema.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE DATABASE db2d6;
1+
CREATE DATABASE IF NOT EXISTS db2d6;
22

33

44
CREATE TABLE IF NOT EXISTS db2d6.meta_table (
@@ -22,7 +22,8 @@ CREATE TABLE IF NOT EXISTS db2d6.adventurers (
2222

2323
CREATE TABLE IF NOT EXISTS db2d6.adventures (
2424
id int NOT NULL AUTO_INCREMENT,
25-
adventurer_name varchar(255) DEFAULT NULL,
25+
name varchar(255) DEFAULT NULL,
26+
adventurer_id int DEFAULT NULL,
2627
level int DEFAULT 0,
2728
last_saved_datetime varchar(50) DEFAULT NULL,
2829
serialiazedObj longtext DEFAULT NULL,

database/scripts/2-data.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ VALUES (12, 1, 'LIBRARY', 'large', 'Lined with bookshelves, this huge library is
172172

173173

174174

175-
-- demo adventurers
176-
INSERT INTO db2d6.adventurers(name, level, xp) VALUES('Toby the Creator', 1, 100);
177-
INSERT INTO db2d6.adventurers(name, level, xp) VALUES('Frank', 0, 0);
178-
179-
180175
-- weapons
181176
INSERT INTO db2d6.weapons(id, name) VALUES(1, 'LONGSWORD');
182177
INSERT INTO db2d6.weapons(id, name) VALUES(2, 'GREATAXE');

0 commit comments

Comments
 (0)