import "dota_client_enums.proto";

enum ETournamentEvent {
	k_ETournamentEvent_None = 0;
	k_ETournamentEvent_TournamentCreated = 1;
	k_ETournamentEvent_TournamentsMerged = 2;
	k_ETournamentEvent_GameOutcome = 3;
	k_ETournamentEvent_TeamGivenBye = 4;
	k_ETournamentEvent_TournamentCanceledByAdmin = 5;
	k_ETournamentEvent_TeamAbandoned = 6;
	k_ETournamentEvent_ScheduledGameStarted = 7;
	k_ETournamentEvent_Canceled = 8;
	k_ETournamentEvent_TeamParticipationTimedOut_EntryFeeRefund = 9;
	k_ETournamentEvent_TeamParticipationTimedOut_EntryFeeForfeit = 10;
	k_ETournamentEvent_TeamParticipationTimedOut_GrantedVictory = 11;
}

message CMsgRequestWeekendTourneySchedule {
}

message CMsgWeekendTourneySchedule {
	message Division {
		optional uint32 division_code = 1;
		optional uint32 time_window_open = 2;
		optional uint32 time_window_close = 3;
		optional uint32 time_window_open_next = 4;
		optional uint32 trophy_id = 5;
		optional bool free_weekend = 6;
	}

	repeated .CMsgWeekendTourneySchedule.Division divisions = 1;
}

message CMsgWeekendTourneyOpts {
	optional bool participating = 1;
	optional uint32 division_id = 2;
	optional uint32 buyin = 3;
	optional uint32 skill_level = 4;
	optional uint32 match_groups = 5;
	optional uint32 team_id = 6;
	optional string pickup_team_name = 7;
	optional uint64 pickup_team_logo = 8;
}

message CMsgWeekendTourneyLeave {
}

message CMsgDOTATournament {
	message Team {
		optional fixed64 team_gid = 1;
		optional uint32 node_or_state = 2;
		repeated uint32 players = 3 [packed = true];
		repeated uint32 player_buyin = 9 [packed = true];
		repeated uint32 player_skill_level = 10 [packed = true];
		optional uint32 match_group_mask = 12;
		optional uint32 team_id = 4;
		optional string team_name = 5;
		optional uint64 team_base_logo = 7;
		optional uint64 team_ui_logo = 8;
	}

	message Game {
		optional uint32 node_idx = 1;
		optional fixed64 lobby_id = 2;
		optional uint64 match_id = 3;
		optional bool team_a_good = 4;
		optional .ETournamentGameState state = 5 [default = k_ETournamentGameState_Unknown];
		optional uint32 start_time = 6;
	}

	message Node {
		optional uint32 node_id = 1;
		optional uint32 team_idx_a = 2;
		optional uint32 team_idx_b = 3;
		optional .ETournamentNodeState node_state = 4 [default = k_ETournamentNodeState_Unknown];
	}

	optional uint32 tournament_id = 1;
	optional uint32 division_id = 2;
	optional uint32 schedule_time = 3;
	optional uint32 skill_level = 4;
	optional .ETournamentTemplate tournament_template = 5 [default = k_ETournamentTemplate_None];
	optional .ETournamentState state = 6 [default = k_ETournamentState_Unknown];
	optional uint32 state_seq_num = 10;
	optional uint32 season_trophy_id = 11;
	repeated .CMsgDOTATournament.Team teams = 7;
	repeated .CMsgDOTATournament.Game games = 8;
	repeated .CMsgDOTATournament.Node nodes = 9;
}

message CMsgDOTATournamentStateChange {
	message GameChange {
		optional uint64 match_id = 1;
		optional .ETournamentGameState new_state = 2 [default = k_ETournamentGameState_Unknown];
	}

	message TeamChange {
		optional uint64 team_gid = 1;
		optional uint32 new_node_or_state = 2;
		optional uint32 old_node_or_state = 3;
	}

	optional uint32 new_tournament_id = 1;
	optional .ETournamentEvent event = 2 [default = k_ETournamentEvent_None];
	optional .ETournamentState new_tournament_state = 3 [default = k_ETournamentState_Unknown];
	repeated .CMsgDOTATournamentStateChange.GameChange game_changes = 4;
	repeated .CMsgDOTATournamentStateChange.TeamChange team_changes = 5;
	repeated uint32 merged_tournament_ids = 6 [packed = true];
	optional uint32 state_seq_num = 7;
}

message CMsgDOTAWeekendTourneyPlayerSkillLevelStats {
	optional uint32 skill_level = 1;
	optional uint32 times_won_0 = 2;
	optional uint32 times_won_1 = 3;
	optional uint32 times_won_2 = 4;
	optional uint32 times_won_3 = 5;
	optional uint32 times_bye_and_lost = 6;
	optional uint32 times_bye_and_won = 7;
	optional uint32 times_unusual_champ = 10;
	optional uint32 total_games_won = 8;
	optional uint32 score = 9;
}

message CMsgDOTAWeekendTourneyPlayerStats {
	optional uint32 account_id = 1;
	optional uint32 season_trophy_id = 2;
	repeated .CMsgDOTAWeekendTourneyPlayerSkillLevelStats skill_levels = 3;
	optional uint32 current_tier = 4;
}

message CMsgDOTAWeekendTourneyPlayerStatsRequest {
	optional uint32 account_id = 1;
	optional uint32 season_trophy_id = 2;
}

message CMsgDOTAWeekendTourneyPlayerHistory {
	message Tournament {
		optional uint32 tournament_id = 1;
		optional uint32 start_time = 2;
		optional uint32 tournament_tier = 3;
		optional uint32 team_id = 4;
		optional uint32 team_date = 5;
		optional uint32 team_result = 6;
		repeated uint32 account_id = 7;
		optional string team_name = 8;
		optional uint32 season_trophy_id = 9;
	}

	optional uint32 account_id = 1;
	repeated .CMsgDOTAWeekendTourneyPlayerHistory.Tournament tournaments = 3;
}

message CMsgDOTAWeekendTourneyParticipationDetails {
	message Tier {
		optional uint32 tier = 1;
		optional uint32 players = 2;
		optional uint32 teams = 3;
		optional uint32 winning_teams = 4;
		optional uint32 players_streak_2 = 5;
		optional uint32 players_streak_3 = 6;
		optional uint32 players_streak_4 = 7;
		optional uint32 players_streak_5 = 8;
	}

	message Division {
		optional uint32 division_id = 1;
		optional uint32 schedule_time = 2;
		repeated .CMsgDOTAWeekendTourneyParticipationDetails.Tier tiers = 3;
	}

	repeated .CMsgDOTAWeekendTourneyParticipationDetails.Division divisions = 1;
}
