import { Question } from "./question";

export enum QueueTypes {
  additionalQuestion = 'additional_question',
  giveOutAPrize = 'give_out_a_prize',
  penalty = 'penalty',
  playExtraCard = 'play_extra_card',
  screpa = 'screpa',
  showresults = 'show_results',
}

export interface EventPhotosUpdated {
  id: number;
}

export interface EventStateChanged {
  state: string;
  value: string;
}
export interface EventAnswerReceived {
  telegramId: number;
  validAnswer: string;
  note: string|null;
}

export interface EventWrongAnswerReceived extends EventAnswerReceived {}

export interface EventUserAdded {
  telegramId: number;
  name: string;
}

export interface UserPropertyChanged {
  user: number;
  property: string;
  value: string;
}

export interface EventCardsChanged {
  telegramId: number;
  cards: [];
}
export interface EventCardPlayed {
  telegramId: number;
  card: string;
  name: string;
}

export interface EventScoreChanged {
  telegramId: number;
  newScore: number;
}

export interface VersusBeginEvent {
  player1: number;
  player2: number;
  player1name: string;
  player2name: string;
}

export interface EventGameQueue {
  text?: string;
  target: number;
  completed: boolean;
  type: QueueTypes;
  _id: string;
}

export interface EventQueueCompleted {

}

export class EventNotification {
  text: string;
  timeout: number;
}


export interface QuestionChangedEvent extends Question {};

export interface ServerEvent<T> {
  event: 'photos_updated'
      | 'state_changed'
      | 'question_changed'
      | 'answer_received'
      | 'user_added'
      | 'cards_changed'
      | 'card_played'
      | 'wrong_answer_received'
      | 'score_changed'
      | 'game_queue'
      | 'queue_completed'
      | 'game_paused'
      | 'game_resumed'
      | 'notification'
      | 'user_property_changed'
      | 'feature_flag_changed'
      | 'begin_versus'
  | 'end_versus'
  data: T
}
