Skip to content

Commit

Permalink
add database persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
hex-agon committed Jul 29, 2023
1 parent ded75f7 commit 2f0b594
Show file tree
Hide file tree
Showing 80 changed files with 6,822 additions and 347 deletions.
31 changes: 27 additions & 4 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
name: Build Images

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
game_server_image:
description: 'Build game server image'
required: true
type: boolean
login_server_image:
description: 'Build login server image'
required: true
type: boolean
resources_server_image:
description: 'Build resources server image'
required: true
type: boolean

jobs:
build:
Expand All @@ -24,8 +38,17 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build images
- name: Build game server image
if: ${{ inputs.game_server_image }}
run: |
mvn package jib:build --no-transfer-progress --pl game-server -am
- name: Build login server image
if: ${{ inputs.login_server_image }}
run: |
mvn package jib:build --no-transfer-progress --pl resources-server -am
mvn package jib:build --no-transfer-progress --pl login-server -am
mvn package jib:build --no-transfer-progress --pl game-server -am
- name: Build resources server image
if: ${{ inputs.resources_server_image }}
run: |
mvn package jib:build --no-transfer-progress --pl resources-server -am
47 changes: 39 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
### NOTE: Due to the exploratory nature of this project the git history is a mess, may be rewritten at any time and commits are big and messy. Architectural changes can happen at any time and will break any forks!
# Alter-Pangya

An attempt at creating a PangYa S8 server emulator
A PangYa GB.852 server emulator

#### Dependencies
## Finding a client

* Redis
* PostgreSQL
This emulator only works with the PangYa GB.852 client, if you browse around the pangya communities you'll easily find a download.
In order to run the client it is highly recommended that you use [RugBurn](https://github.com/pangbox/rugburn).

A big thanks to everyone at the [Cadie's Cauldron discord](https://discord.gg/HwDTssf)
## Running the servers

References:
### Dependencies

* A redis instance
* A postgres instance

## Development

### Setting up a Postgres database
You can run a local postgres database using the reference `Dockerfile` contained in the `database` directory, to quickly create an instance run:
```bash
docker image build -t alter_pangya database/
docker container run -d -p 5432:5432 --name alter_pangya alter_pangya
```

### Applying the migrations
Replace the relevant database parameters with your own values

```bash
mvn -Dflyway.url=jdbc:postgresql://localhost/alter_pangya -Dflyway.user=alter_pangya -Dflyway.password=alter_pangya -Dflyway.locations=filesystem:database/migrations org.flywaydb:flyway-maven-plugin:migrate --non-recursive
```

### Regenerating the JooQ classes (Schema changes)

While at the project root, run the following bash script to re-generate the jooq classes:

```bash
mvn -Djooq.codegen.jdbc.url=jdbc:postgresql://localhost/alter_pangya -Djooq.codegen.jdbc.user=alter_pangya -Djooq.codegen.jdbc.password=alter_pangya org.jooq:jooq-codegen-maven:generate --non-recursive
```

A big thanks to everyone at the [Caddie's Cauldron discord](https://discord.gg/HwDTssf)

#### References:

* [PangYa Tools](https://github.com/pangyatools)
* [Pangbox](https://github.com/pangbox/)
* [UGPangya](https://github.com/eantoniobr/UGPangya/)
* [SuperSS](https://github.com/Acrisio-Filho/SuperSS-Dev)
62 changes: 0 additions & 62 deletions asyncapi.yml

This file was deleted.

5 changes: 5 additions & 0 deletions database/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM postgres:15

ENV POSTGRES_USER=alter_pangya
ENV POSTGRES_PASSWORD=alter_pangya
ENV POSTGRES_DB=alter_pangya
127 changes: 127 additions & 0 deletions database/migrations/V0001__base-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
CREATE TABLE account (
uid serial PRIMARY KEY,
uuid uuid NOT NULL,
username text NOT NULL,
nickname text,
password bytea NOT NULL,
pang_balance int NOT NULL,
cookie_balance int NOT NULL,
created_at timestamptz DEFAULT NOW()
);

CREATE INDEX idx__account_uuid ON account (uuid);

CREATE TABLE achievement (
iff_id int NOT NULL PRIMARY KEY,
completed_with_milestone int NOT NULL,
category int NOT NULL
);

CREATE TABLE achievement_milestone (
iff_id int NOT NULL PRIMARY KEY,
achievement_iff_id int NOT NULL
CONSTRAINT fk__achievement_milestone REFERENCES achievement (iff_id),
name text NOT NULL
);

CREATE TABLE player_character (
uid serial PRIMARY KEY,
account_uid int NOT NULL
CONSTRAINT fk_player_character__account REFERENCES account (uid) ON DELETE CASCADE,
iff_id int NOT NULL,
hair_color int NOT NULL,
part_iff_ids json NOT NULL,
part_uids json NOT NULL,
aux_parts json NOT NULL,
cutin_iff_id int NOT NULL,
stats json NOT NULL,
mastery int NOT NULL,
cards json NOT NULL
);

CREATE UNIQUE INDEX idx_player_character ON player_character (account_uid, iff_id);

CREATE TABLE player_caddie (
uid serial PRIMARY KEY,
account_uid int NOT NULL
CONSTRAINT fk_player_caddie__account REFERENCES account (uid) ON DELETE CASCADE,
iff_id int NOT NULL,
level int NOT NULL,
experience int NOT NULL
);
CREATE UNIQUE INDEX idx_player_caddie ON player_caddie (account_uid, iff_id);

CREATE TABLE player_inventory_item (
uid serial PRIMARY KEY,
account_uid int NOT NULL
CONSTRAINT fk_player_inventory_item__account REFERENCES account (uid) ON DELETE CASCADE,
iff_id int NOT NULL,
quantity int DEFAULT 0,
stats json
);

CREATE TABLE player_equipment (
account_uid int NOT NULL PRIMARY KEY
CONSTRAINT fk_player_statistics__account REFERENCES account (uid) ON DELETE CASCADE,
item_iff_ids json NOT NULL,
character_uid int NOT NULL,
caddie_uid int NOT NULL,
club_set_uid int NOT NULL,
comet_iff_id int NOT NULL
);

CREATE TABLE player_statistics (
account_uid int NOT NULL PRIMARY KEY
CONSTRAINT fk_player_statistics__account REFERENCES account (uid) ON DELETE CASCADE,
total_shots int NOT NULL,
total_putts int NOT NULL,
playtime_seconds int NOT NULL,
shot_time_seconds int NOT NULL,
longest_drive float4 NOT NULL,
pangya_shots int NOT NULL,
timeouts int NOT NULL,
oob_shots int NOT NULL,
total_distance int NOT NULL,
total_holes int NOT NULL,
unfinished_holes int NOT NULL,
hole_in_ones int NOT NULL,
bunker_shots int NOT NULL,
fairway_shots int NOT NULL,
albatross int NOT NULL,
successful_putts int NOT NULL,
longest_putt float4 NOT NULL,
longest_chip_in float4 NOT NULL,
experience int NOT NULL,
level int NOT NULL,
pang_earned bigint NOT NULL,
total_score int NOT NULL,
games_played int NOT NULL,
game_combo_current_streak int NOT NULL,
game_combo_best_streak int NOT NULL,
games_quit int NOT NULL,
pang_won_in_battle int NOT NULL,
pang_battle_wins int NOT NULL,
pang_battle_losses int NOT NULL,
pang_battle_all_ins int NOT NULL,
pang_battle_combo int NOT NULL
);

CREATE TABLE player_achievement (
uid serial PRIMARY KEY,
account_uid int NOT NULL
CONSTRAINT fk_player_achievement__account REFERENCES account (uid) ON DELETE CASCADE,
iff_id int NOT NULL
);

CREATE UNIQUE INDEX idx_player_achievement ON player_achievement (account_uid, iff_id);

CREATE TABLE player_achievement_milestone (
uid serial PRIMARY KEY,
player_achievement_uid int NOT NULL
CONSTRAINT fk_player_achievement_milestone__player_achievement REFERENCES player_achievement (uid) ON DELETE CASCADE,
iff_id int NOT NULL,
progress INT NOT NULL DEFAULT 0,
completed_at timestamptz
);

CREATE UNIQUE INDEX idx_player_achievement_milestone ON player_achievement_milestone (player_achievement_uid, iff_id);
Loading

0 comments on commit 2f0b594

Please sign in to comment.