import { NetRequest } from "../../Engine/CatanEngine/NetManagerV2/NetRequest";
import { AdSyncType, TAdParam } from "./AdRequest";

// #region Request

export type RpcActivityListRequest = null
export type RpcActivityListResponse = TActivityList[]

export class ActivityListRequest extends NetRequest<RpcActivityListRequest, RpcActivityListResponse> {
	get Method(): string {
		return "activity.list";
	}
	constructor() {
		super();
	}
}

export type RpcActivityDetailRequest = null
export type RpcActivityDetailResponse = TActivityDetail[]

export class ActivityDetailRequest extends NetRequest<RpcActivityDetailRequest, RpcActivityDetailResponse> {
	get Method(): string {
		return "activity.detail";
	}
	constructor() {
		super();
	}
}

//-------- ActivityCommon

interface ActivityCommonDetailId {
	id: number;
}

export class ActivityCommonDetail extends NetRequest<ActivityCommonDetailId, JSON> {
	get Method(): string {
		return "activity_com.detail";
	}
	constructor(id: number) {
		super();
		this.Data = {
			id: id
		};
	}
}

interface ActivityCommand {
	id: number;
	c: number;
}

export class ActivityCommonCommand extends NetRequest<ActivityCommand, JSON> {
	get Method(): string {
		return "activity_com.cmd";
	}
	constructor(id: number, c: number) {
		super();
		this.Data = {
			id: id,
			c: c
		};
	}
}


export type RpcActivityComSyncResponse = TActivityComSyncData[]

// #endregion

// #region Type

export type TActivityList = [
	id: number,
	eventName: string,
	eventType: EActivityType,
	sort: number,
	showStartTime: number,
	showEndTime: number,
	activityStartTime: number,
	activityEndTime: number,
	image: string,
	eventEnd: number,
];

export type TActivityDetail = [
	slot: number[],
	vipLimit: number,
	navType: AdSyncType,
	navRef: TAdParam,
	content1: number,
	content2: number,
	modData: TModData,
	prizeData: TPrizeData,
	jpAmount: number,
];

type TModData = [
	rankType: number,
	minBet: number,
	minRounds: number,
	totalRanks: number,
];

type TPrizeData = [
	aid: number,
	nickname: number,
	multiplier: number,
	money: number,
];

export type TActivityComSyncData = [
	id: number,
	activitySyncData: TActivitySyncData[],
];

export type TActivitySyncData = [
	type: EActivitySyncType,
	extra1: any,
	extra2: any,
	extra3: any
];

// #endregion

// #region Enum

export enum EActivityType {
	Normal = 1,
	JP = 2,
	Rank = 3,
}

export enum EActivitySyncType {
	IsOpen = 1,
	Sync,
	Task,
}

// #endregion