This commit is contained in:
2024-05-12 21:24:14 +02:00
parent c49a2563f8
commit 2f4ae43996
9 changed files with 100 additions and 28 deletions

View File

@ -1,5 +1,6 @@
import bcrypt from "bcryptjs";
import UserRepository from "../repositories/user.repository";
import CharacterRepository from "../repositories/character.repository";
class UserService {
async login(username: string, password: string): Promise<boolean | any> {
@ -23,7 +24,12 @@ class UserService {
}
const hashedPassword = await bcrypt.hash(password, 10);
return await UserRepository.create(username, hashedPassword);
const newUser = await UserRepository.create(username, hashedPassword);
// @TODO: Create a new character for the user
const newCharacter = await CharacterRepository.create(newUser.id, newUser.username);
return newUser
}
}

View File

@ -5,8 +5,7 @@ class ZoneService
{
async createDemoZone(): Promise<boolean>
{
const zoneRepo = new ZoneRepository();
await zoneRepo.create("Demo Zone", 10, 10, [
await ZoneRepository.create("Demo Zone", 10, 10, [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],