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<Player> {
const res = await db.first()
const res = await db('players').insert(raw).returning<Player[]>('*');
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);
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;
}