import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Exclude } from 'class-transformer';
import { DEFAULT_PHOTO } from '../resources/default-photo';

export type GuestDocument = Guest & Document;

export interface IGuestProperties {
  [index: string]: string | number | boolean | object | undefined;
}

@Schema()
export class Guest {
  @Prop({ required: true })
  name: string;

  @Prop({ default: 0 })
  score: number;
  @Prop()
  telegramId: number;
  @Prop()
  chatId: number;
  @Prop({ default: DEFAULT_PHOTO })
  @Exclude()
  photo: string;
  @Prop({ default: 10 })
  prizeChance: number;
  @Prop({ default: 0 })
  validAnswers: number;
  @Prop({ default: 0 })
  invalidAnswers: number;
  @Prop({default: 0})
  invalidAnswersInRow: number;
  @Prop({ default:0 })
  rewardsReceived: number;
  @Prop({ default: 0})
  penaltiesReceived: number;
  @Prop({ type: Map })
  properties: Record<string, string>;
}

export const GuestSchema = SchemaFactory.createForClass(Guest);
