Skip to content
Snippets Groups Projects
Commit 60d7e75c authored by L4168's avatar L4168
Browse files

fixed imports

parent 334573db
No related branches found
No related tags found
2 merge requests!59Development to master,!10Gamecreation
......@@ -5,7 +5,6 @@ import { AuthGuard } from '../shared/auth.guard';
import { User } from '../user/user.decorator';
import { GameDTO } from './game.dto';
import { ValidationPipe } from '../shared/validation.pipe';
import { async } from 'rxjs/internal/scheduler/async';
@Controller('game')
export class GameController {
......
......@@ -36,7 +36,7 @@ export class GameDTO {
})
// custom validation for array length (arr>min, arr<max)
@Validate(ArrayLength, [4, 8])
passwords: [];
passwords: string[];
factions: FactionDTO[];
}
......
......@@ -17,7 +17,7 @@ export class GameEntity {
@Column('json') map: JSON;
@Column('timestamp') startdate: Timestamp;
@Column('timestamp') enddate: Timestamp;
@Column("text", {array: true}) passwords: [];
@Column("text", {array: true}) passwords: string[];
@OneToMany(type => FactionEntity, faction => faction.game)
factions: FactionEntity[];
@OneToMany(type => Game_PersonEntity, game_persons => game_persons.game)
......
......@@ -3,10 +3,11 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { GameController } from './game.controller';
import { GameService } from './game.service';
import { GameEntity, FactionEntity } from './game.entity';
import { GameEntity, FactionEntity, Game_PersonEntity } from './game.entity';
import { PersonEntity } from 'src/user/user.entity';
@Module({
imports: [TypeOrmModule.forFeature([GameEntity, FactionEntity])],
imports: [TypeOrmModule.forFeature([GameEntity, FactionEntity, Game_PersonEntity, PersonEntity])],
controllers: [GameController],
providers: [GameService]
})
......
......@@ -2,9 +2,9 @@ import { Injectable, Logger, HttpException, HttpStatus } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository, In } from 'typeorm';
import { GameEntity, FactionEntity } from './game.entity';
import { GameEntity, FactionEntity, Game_PersonEntity } from './game.entity';
import { GameDTO } from './game.dto';
import { PersonEntity } from 'src/user/user.entity';
import { PersonEntity } from '../user/user.entity';
@Injectable()
export class GameService {
......@@ -15,6 +15,8 @@ export class GameService {
private factionRepository: Repository<FactionEntity>,
@InjectRepository(PersonEntity)
private personRepository: Repository<PersonEntity>,
@InjectRepository(Game_PersonEntity)
private game_PersonRepository: Repository<Game_PersonEntity>,
) {}
// create a new game
......@@ -46,9 +48,21 @@ export class GameService {
}
// checks the password, creates an entry in GamePerson table with associated role&faction
async joinGame(person, gameId, password) {
const user = await this.personRepository.findOne({ where: { id: person.id } });
async joinGame(person, gameId, json) {
const user = await this.personRepository.findOne({
where: { id: person },
});
const game = await this.gameRepository.findOne({ where: { id: gameId } });
const index = game.passwords.indexOf(json.password);
// create game_Person entry
/* const gamePerson = await this.game_PersonRepository.create({
faction,
gameId,
person,
});
*/
return 'WIP';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment