exploring/fighting is functional
[sketchy-heroes.git] / src / api.ts
index 0af6dec7441ed1e77bb5129778cb66c68c49d28a..d9548981f3d45f095e894c7bdcd02553fdcf2d78 100644 (file)
@@ -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);