import "dota_shared_enums.proto";

enum ELeagueNodeGroupType {
	INVALID_GROUP_TYPE = 0;
	ORGANIZATIONAL = 1;
	ROUND_ROBIN = 2;
	SWISS = 3;
	BRACKET_SINGLE = 4;
	BRACKET_DOUBLE_SEED_LOSER = 5;
	BRACKET_DOUBLE_ALL_WINNER = 6;
	SHOWMATCH = 7;
	GSL = 8;
	PLACEMENT = 9;
}

enum ELeagueNodeType {
	INVALID_NODE_TYPE = 0;
	BEST_OF_ONE = 1;
	BEST_OF_THREE = 2;
	BEST_OF_FIVE = 3;
	BEST_OF_TWO = 4;
}

message CMsgDOTALeagueNode {
	message MatchDetails {
		optional uint64 match_id = 1;
		optional uint32 winning_team_id = 2;
	}

	message VOD {
		optional uint32 series_game = 1;
		optional uint32 stream_id = 2;
		optional string url = 3;
	}

	optional string name = 1;
	optional uint32 node_id = 2;
	optional uint32 node_group_id = 3;
	optional uint32 winning_node_id = 4;
	optional uint32 losing_node_id = 5;
	optional uint32 incoming_node_id_1 = 6;
	optional uint32 incoming_node_id_2 = 7;
	optional .ELeagueNodeType node_type = 8 [default = INVALID_NODE_TYPE];
	optional uint32 scheduled_time = 9;
	optional uint32 actual_time = 19;
	optional uint32 series_id = 10;
	optional uint32 team_id_1 = 11;
	optional uint32 team_id_2 = 12;
	repeated .CMsgDOTALeagueNode.MatchDetails matches = 13;
	optional uint32 team_1_wins = 14;
	optional uint32 team_2_wins = 15;
	optional bool has_started = 16;
	optional bool is_completed = 17;
	repeated uint32 stream_ids = 18;
	repeated .CMsgDOTALeagueNode.VOD vods = 20;
}

message CMsgDOTALeagueNodeGroup {
	message TeamStanding {
		optional uint32 standing = 1;
		optional uint32 team_id = 2;
		optional string team_name = 3;
		optional string team_tag = 4;
		optional uint64 team_logo = 5;
		optional string team_logo_url = 6;
		optional uint32 wins = 7;
		optional uint32 losses = 8;
		optional int64 score = 9;
		optional string team_abbreviation = 10;
		optional bool is_pro = 14;
		optional uint32 tiebreak_game_win_pct = 15;
		optional uint32 tiebreak_opponent_match_wins = 16;
		optional uint32 tiebreak_opponent_game_win_pct = 17;
		optional uint32 tiebreak_coinflip = 18;
	}

	optional string name = 1;
	optional uint32 node_group_id = 2;
	optional uint32 parent_node_group_id = 3;
	repeated uint32 incoming_node_group_ids = 4;
	optional uint32 advancing_node_group_id = 5;
	optional uint32 advancing_team_count = 6;
	optional uint32 team_count = 7;
	optional .ELeagueNodeGroupType node_group_type = 8 [default = INVALID_GROUP_TYPE];
	optional .ELeagueNodeType default_node_type = 9 [default = INVALID_NODE_TYPE];
	optional uint32 round = 10;
	optional uint32 max_rounds = 11;
	optional uint32 win_loss_limit = 27;
	optional bool is_tiebreaker = 12;
	optional bool is_final_group = 13;
	optional bool is_completed = 14;
	optional .ELeaguePhase phase = 18 [default = LEAGUE_PHASE_UNSET];
	optional .ELeagueRegion region = 19 [default = LEAGUE_REGION_UNSET];
	optional uint32 start_time = 20;
	optional uint32 end_time = 21;
	optional uint32 secondary_advancing_node_group_id = 22;
	optional uint32 secondary_advancing_team_count = 23;
	optional uint32 tertiary_advancing_node_group_id = 24;
	optional uint32 tertiary_advancing_team_count = 25;
	optional uint32 elimination_dpc_points = 26;
	repeated .CMsgDOTALeagueNodeGroup.TeamStanding team_standings = 15;
	repeated .CMsgDOTALeagueNode nodes = 16;
	repeated .CMsgDOTALeagueNodeGroup node_groups = 17;
}

message CMsgDOTALeague {
	message Info {
		optional uint32 league_id = 1;
		optional string name = 2;
		optional .ELeagueTier tier = 3 [default = LEAGUE_TIER_UNSET];
		optional .ELeagueRegion region = 4 [default = LEAGUE_REGION_UNSET];
		optional string url = 5;
		optional string description = 6;
		optional string notes = 7;
		optional uint32 start_timestamp = 8;
		optional uint32 end_timestamp = 9;
		optional uint32 pro_circuit_points = 10;
		optional uint32 image_bits = 11;
		optional .ELeagueStatus status = 12 [default = LEAGUE_STATUS_UNSET];
		optional uint32 most_recent_activity = 13;
		optional uint32 registration_period = 14;
	}

	message Admin {
		optional uint32 account_id = 1;
		optional bool is_primary = 2;
		optional string email_address = 3;
	}

	message PrizePoolItem {
		optional uint32 item_def = 1;
		optional uint32 sales_stop_timestamp = 2;
		optional uint32 revenue_pct = 3;
		optional uint32 revenue_cents_per_sale = 4;
	}

	message PrizePool {
		optional uint32 base_prize_pool = 1;
		optional uint32 total_prize_pool = 2;
		repeated uint32 prize_split_pct_x100 = 3;
		repeated .CMsgDOTALeague.PrizePoolItem prize_pool_items = 4;
	}

	message Stream {
		optional uint32 stream_id = 1;
		optional uint32 language = 2;
		optional string name = 3;
		optional .ELeagueBroadcastProvider broadcast_provider = 4 [default = LEAGUE_BROADCAST_UNKNOWN];
		optional string stream_url = 5;
		optional string vod_url = 6;
	}

	message SeriesInfo {
		optional uint32 series_id = 1;
		optional uint32 series_type = 2;
		optional uint32 start_time = 3;
		repeated uint64 match_ids = 4;
		optional uint32 team_id_1 = 5;
		optional uint32 team_id_2 = 6;
	}

	message Player {
		optional uint32 account_id = 1;
		optional string name = 2;
		optional uint32 team_id = 3;
	}

	optional .CMsgDOTALeague.Info info = 1;
	optional .CMsgDOTALeague.PrizePool prize_pool = 2;
	repeated .CMsgDOTALeague.Admin admins = 3;
	repeated .CMsgDOTALeague.Stream streams = 4;
	repeated .CMsgDOTALeagueNodeGroup node_groups = 5;
	repeated .CMsgDOTALeague.SeriesInfo series_infos = 6;
	repeated .CMsgDOTALeague.Player registered_players = 7;
}

message CMsgDOTALeagueList {
	repeated .CMsgDOTALeague leagues = 1;
}

message CMsgDOTALeagueInfo {
	optional uint32 league_id = 1;
	optional string name = 2;
	optional .ELeagueTier tier = 3 [default = LEAGUE_TIER_UNSET];
	optional .ELeagueRegion region = 4 [default = LEAGUE_REGION_UNSET];
	optional uint32 most_recent_activity = 5;
	optional uint32 total_prize_pool = 6;
	optional uint32 start_timestamp = 7;
	optional uint32 end_timestamp = 8;
	optional uint32 status = 9;
}

message CMsgDOTALeagueInfoList {
	repeated .CMsgDOTALeagueInfo infos = 1;
}

message CMsgDOTALeagueLiveGames {
	message LiveGame {
		optional uint32 league_id = 1;
		optional uint64 server_steam_id = 2;
		optional string radiant_name = 3;
		optional uint64 radiant_logo = 4;
		optional uint32 radiant_team_id = 9;
		optional string dire_name = 5;
		optional uint64 dire_logo = 6;
		optional uint32 dire_team_id = 10;
		optional uint32 time = 7;
		optional uint32 spectators = 8;
		optional uint32 league_node_id = 11;
		optional uint32 series_id = 12;
		optional uint64 match_id = 13;
	}

	repeated .CMsgDOTALeagueLiveGames.LiveGame games = 1;
}

message CMsgDOTALeagueMessages {
	message Message {
		optional uint32 author_account_id = 1;
		optional uint32 timestamp = 2;
		optional string message = 3;
	}

	repeated .CMsgDOTALeagueMessages.Message messages = 1;
}

message CMsgDOTALeaguePrizePool {
	optional uint32 prize_pool = 1;
	optional float increment_per_second = 2;
}

message CMsgDOTALeagueInfoListAdminsRequest {
}

message CMsgDOTALeagueAvailableLobbyNodesRequest {
	optional uint32 league_id = 1;
}

message CMsgDOTALeagueAvailableLobbyNodes {
	message NodeInfo {
		optional uint32 node_id = 1;
		optional string node_name = 2;
		optional string node_group_name = 3;
		optional uint32 team_id_1 = 4;
		optional uint32 team_id_2 = 5;
	}

	repeated .CMsgDOTALeagueAvailableLobbyNodes.NodeInfo node_infos = 1;
}

message CMsgDOTALeagueNodeResults {
	message Result {
		optional uint32 node_id = 1;
		optional uint32 winning_node_id = 2;
		optional uint32 losing_node_id = 3;
		optional uint32 incoming_node_id_1 = 4;
		optional uint32 incoming_node_id_2 = 5;
		optional uint32 team_id_1 = 6;
		optional uint32 team_id_2 = 7;
		optional string team_1_name = 8;
		optional string team_2_name = 9;
		optional uint32 team_1_wins = 10;
		optional uint32 team_2_wins = 11;
		optional uint32 winning_team_id = 12;
		optional uint32 losing_team_id = 13;
		optional bool has_started = 14;
		optional bool is_completed = 15;
		optional uint32 scheduled_time = 16;
		repeated uint64 match_ids = 17;
	}

	repeated .CMsgDOTALeagueNodeResults.Result node_results = 1;
}

message CMsgDOTADPCLeagueResults {
	message Result {
		optional uint32 standing = 1;
		optional uint32 team_id = 2;
		optional string team_name = 3;
		optional uint64 team_logo = 4;
		optional string team_logo_url = 5;
		optional uint32 points = 6;
		optional uint32 earnings = 7;
		optional uint32 timestamp = 8;
		optional .ELeaguePhase phase = 9 [default = LEAGUE_PHASE_UNSET];
		optional string team_abbreviation = 10;
	}

	repeated .CMsgDOTADPCLeagueResults.Result results = 1;
	repeated uint32 points = 2;
	repeated uint32 dollars = 3;
}

message CMsgDOTADPCTeamResults {
	message Result {
		optional uint32 league_id = 1;
		optional uint32 standing = 2;
		optional uint32 points = 3;
		optional uint32 earnings = 4;
		optional uint32 timestamp = 5;
	}

	repeated .CMsgDOTADPCTeamResults.Result results = 1;
}

message CMsgDOTADPCSeasonResults {
	message TeamLeagueResult {
		optional uint32 timestamp = 1;
		optional uint32 league_id = 2;
		optional uint32 standing = 3;
		optional uint32 points = 4;
		optional uint32 earnings = 5;
		optional uint32 audit_action = 6;
		optional uint32 audit_data = 7;
	}

	message TeamResult {
		optional uint32 team_id = 1;
		optional string team_name = 2;
		optional string team_abbreviation = 8;
		optional uint64 team_logo = 3;
		optional string team_logo_url = 4;
		optional uint32 total_points = 5;
		optional uint32 total_earnings = 6;
		repeated .CMsgDOTADPCSeasonResults.TeamLeagueResult league_results = 7;
	}

	message StandingEntry {
		optional uint32 team_id = 1;
		optional uint32 wins = 2;
		optional uint32 losses = 3;
		optional string team_url = 4;
		optional string team_name = 5;
		optional string team_abbreviation = 6;
	}

	message Standing {
		optional .ELeagueRegion region = 1 [default = LEAGUE_REGION_UNSET];
		optional .ELeagueDivision division = 2 [default = LEAGUE_DIVISION_UNSET];
		repeated .CMsgDOTADPCSeasonResults.StandingEntry entries = 3;
	}

	repeated .CMsgDOTADPCSeasonResults.TeamResult results = 1;
	repeated .CMsgDOTADPCSeasonResults.Standing standings = 2;
	repeated .CMsgDOTADPCSeasonResults.StandingEntry major_wildcard_standings = 3;
	repeated .CMsgDOTADPCSeasonResults.StandingEntry major_group_standings = 4;
	repeated .CMsgDOTADPCSeasonResults.StandingEntry major_playoff_standings = 5;
}

message CMsgDOTADPCSeasonSpoilerResults {
	optional uint32 time_last_updated = 1;
	optional .CMsgDOTADPCSeasonResults saved_results = 2;
}
