From ef3cf374c35fc964bede87b64b628432550f457d Mon Sep 17 00:00:00 2001 From: xangelo Date: Mon, 3 Jul 2023 07:05:21 -0400 Subject: [PATCH] fix: new players didn't get profession level set Because their profession level wasn't set, they were unable to do anything because loading a player attempts to join that table. --- src/server/player.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/server/player.ts b/src/server/player.ts index 3c95080..6683144 100644 --- a/src/server/player.ts +++ b/src/server/player.ts @@ -3,6 +3,7 @@ import {Player, maxHp} from "../shared/player"; import { random } from 'lodash'; import { Skills } from '../shared/skills'; import {Profession} from 'shared/profession'; +import {logger} from './lib/logger'; export async function loadPlayer(authToken: string): Promise { const res = await db.first() @@ -35,11 +36,15 @@ export async function createPlayer(): Promise { const res = await db('players').insert(raw).returning('*'); const player = res.pop(); + logger.log(`Created player [${player.id}]`); + // await skills! const pairs = []; const values = []; const sql = `insert into player_skills (id, player_id) values `; + logger.log(`Inserted base skills for [${player.id}]`) + Skills.forEach(skill => { pairs.push('(?,?)'); values.push(skill.id, player.id); @@ -48,13 +53,15 @@ export async function createPlayer(): Promise { await db.raw(sql + pairs.join(','), values); // create the profession level - db('profession_levels').insert({ + await db('profession_levels').insert({ player_id: player.id, profession: 'Wanderer', level: 1, exp: 0 }); + logger.log(`Inserted base profession level [${player.id}]`); + return player; } -- 2.25.1