From: xangelo Date: Mon, 3 Jul 2023 11:05:21 +0000 (-0400) Subject: fix: new players didn't get profession level set X-Git-Tag: v0.0.1~8 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=ef3cf374c35fc964bede87b64b628432550f457d;p=risinglegends.git 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. --- 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; }