X-Git-Url: https://git.xangelo.ca/?p=sketchy-heroes.git;a=blobdiff_plain;f=src%2Fapi.ts;fp=src%2Fapi.ts;h=d9548981f3d45f095e894c7bdcd02553fdcf2d78;hp=0af6dec7441ed1e77bb5129778cb66c68c49d28a;hb=7aa7248bc4f3f59a002beb98fa889a9da3c25866;hpb=9cec2c639563092ed050716db1e7e4657f937bf5 diff --git a/src/api.ts b/src/api.ts index 0af6dec..d954898 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,5 +1,6 @@ import { config as dotenv } from 'dotenv'; import { server, WrappedApiEndpointHandler } from './lib/server'; +import { prisma } from './lib/db'; import { logger } from './lib/logger'; import * as routes from './routes'; import { each } from 'lodash'; @@ -16,6 +17,10 @@ server.start(process.env.PORT || '9090').catch(err => { throw err; }); - - - +setInterval(async () => { + await prisma.$transaction([ + prisma.$queryRaw`update "Player" set stamina = stamina + 1 where stamina < (woosh * level + 19)`, + prisma.$queryRaw`update "Player" set hp = hp + 1 where hp < (zest * 3 + 2 * level)` + ]); + logger.info('Updated HP and Stamina'); +}, 1000 * 60);