import type { serverNotificationEvent } from "web/serverTypes";
import type { TTS } from "./TTSTypes";

type alertBase<name extends string> = {
	name: name;
	user: string;
};

export type userBlastAlert = alertBase<"userBlast"> & {
	target: string;
};

export type userExecutionAlert = alertBase<"userExecution"> & {
	target: string;
};

export type grenadeExplosionAlert = alertBase<"grenadeExplosion"> & {
	target: string;
};

export type tntExplosionAlert = alertBase<"tntExplosion"> & {
	targets: string[];
};

export type soundAlerts =
	| "mrockmadhouse"
	| "eddiescream"
	| "ripbozo"
	| "factorioalert"
	| "fail1"
	| "fail2";

export type soundAlert = alertBase<"sound"> & {
	sound: soundAlerts;
};

export type blastinRoulette = alertBase<"blastinRoulette"> & {
	targets: string[];
	finaltarget?: string;
};

export type alert =
	| userBlastAlert
	| userExecutionAlert
	| grenadeExplosionAlert
	| tntExplosionAlert
	| soundAlert
	| blastinRoulette;

type playAlertEvent = {
	function: "playAlert";
	alert: alert;
};

type playTTS = {
	function: "playTTS";
	tts: TTS;
};

type cancelTTS = {
	function: "cancelTTS";
};

export type alertEventData =
	| playAlertEvent
	| playTTS
	| cancelTTS
	| serverNotificationEvent;
