Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
StrayanDropbear committed May 12, 2024
2 parents d7bfce1 + 0eddf12 commit 3cab1c8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
17 changes: 17 additions & 0 deletions api/savedata/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,30 @@ func Get(uuid []byte, datatype, slot int) (any, error) {
return nil, err
}

// TODO this should be a transaction
compensations, err := db.FetchAndClaimAccountCompensations(uuid)
if err != nil {
return nil, fmt.Errorf("failed to fetch compensations: %s", err)
}

needsUpdate := false
for compensationType, amount := range compensations {
system.VoucherCounts[strconv.Itoa(compensationType)] += amount
if amount > 0 {
needsUpdate = true
}
}

if needsUpdate {
err = db.StoreSystemSaveData(uuid, system)
if err != nil {
return nil, fmt.Errorf("failed to update system save data: %s", err)
}

err = db.UpdateAccountStats(uuid, system.GameStats, system.VoucherCounts)
if err != nil {
return nil, fmt.Errorf("failed to update account stats: %s", err)
}
}

return system, nil
Expand Down
33 changes: 30 additions & 3 deletions docker-compose.Example.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
services:
server:
image: ghcr.io/pagefaultgames/pokerogue:latest
command: --debug --dbaddr db:3306 --dbuser pokerogue --dbpass pokerogue --dbname pokeroguedb
command: --debug --dbaddr db --dbuser pokerogue --dbpass pokerogue --dbname pokeroguedb
image: ghcr.io/pagefaultgames/rogueserver:master
restart: unless-stopped
depends_on:
- db
db:
condition: service_healthy
networks:
- internal
ports:
- "8001:8001"

db:
image: mariadb:11
restart: unless-stopped
healthcheck:
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
start_period: 10s
start_interval: 10s
interval: 1m
timeout: 5s
retries: 3
environment:
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: pokeroguedb
MYSQL_USER: pokerogue
MYSQL_PASSWORD: pokerogue
volumes:
- database:/var/lib/mysql
networks:
- internal

# Watchtower is a service that will automatically update your running containers
# when a new image is available. This is useful for keeping your server up-to-date.
# see https://containrrr.dev/watchtower/ for more information.
watchtower:
image: containrrr/watchtower
container_name: watchtower
restart: always
security_opt:
- no-new-privileges:true
environment:
WATCHTOWER_CLEANUP: true
WATCHTOWER_SCHEDULE: "@midnight"
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock

volumes:
database:
Expand Down

0 comments on commit 3cab1c8

Please sign in to comment.