use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize)]
pub struct DreamTeamTopPlayer {
    pub id: u64,
    pub points: i64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct DreamTeamTeam {
    pub element: u64,
    pub points: i64,
    pub position: u64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct DreamTeam {
    pub top_player: DreamTeamTopPlayer,
    pub team: Vec<DreamTeamTeam>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Event {
    pub id: u64,
    pub name: String,
    pub deadline_time: String,
    pub average_entry_score: Option<u64>,
    pub highest_score: Option<u64>,
    pub is_current: bool,
    pub is_next: bool,
    pub finished: bool,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Element {
    pub id: u64,
    pub web_name: String,
    pub region: Option<u64>,
    pub element_type: u64,
    pub team: u64,
    pub now_cost: u64,
    pub selected_by_percent: String,
    pub form: String,
    pub total_points: i64,
    pub news: String,
    pub news_added: Option<String>,
    pub status: super::PlayerStatus,
    pub chance_of_playing_next_round: Option<u64>,
    pub transfers_in: u64,
    pub transfers_out: u64,
    pub transfers_in_event: u64,
    pub transfers_out_event: u64,
    pub cost_change_event: i64,
    pub cost_change_start: i64,
    pub minutes: u64,
    pub goals_scored: u64,
    pub assists: u64,
    pub clean_sheets: u64,
    pub goals_conceded: u64,
    pub own_goals: u64,
    pub penalties_saved: u64,
    pub penalties_missed: u64,
    pub yellow_cards: u64,
    pub red_cards: u64,
    pub saves: u64,
    pub bonus: u64,
    pub bps: i64,
    pub influence: String,
    pub creativity: String,
    pub threat: String,
    pub ict_index: String,
    pub dreamteam_count: u64,
    pub value_form: String,
    pub value_season: String,
    pub points_per_game: String,
    pub expected_goals: String,
    pub expected_assists: String,
    pub expected_goal_involvements: String,
    pub expected_goals_conceded: String,
    pub starts: u64,
    pub tackles: u64,
    pub clearances_blocks_interceptions: u64,
    pub recoveries: u64,
    pub defensive_contribution: u64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Team {
    pub position: u64,
    pub played: u64,
    pub win: u64,
    pub draw: u64,
    pub loss: u64,
    pub points: u64,
    pub strength: u8,
    pub strength_overall_home: u64,
    pub strength_overall_away: u64,
    pub strength_attack_home: u64,
    pub strength_attack_away: u64,
    pub strength_defence_home: u64,
    pub strength_defence_away: u64,
    pub form: Option<String>,
    pub id: u64,
    pub name: String,
    pub short_name: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct BootstrapStatic {
    pub events: Vec<Event>,
    pub elements: Vec<Element>,
    pub teams: Vec<Team>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Fixture {
    pub id: u64,
    pub code: u64,
    pub event: Option<u64>,
    pub finished: bool,
    pub started: Option<bool>,
    pub kickoff_time: Option<String>,
    pub team_a: u64,
    pub team_h: u64,
    pub team_a_difficulty: u8,
    pub team_h_difficulty: u8,
    pub team_h_score: Option<u64>,
    pub team_a_score: Option<u64>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct PlayerHistory {
    pub element: u64,
    pub fixture: u64,
    pub opponent_team: u64,
    pub total_points: i64,
    pub was_home: bool,
    pub kickoff_time: String,
    pub team_h_score: u64,
    pub team_a_score: u64,
    pub round: u64,
    pub modified: bool,
    pub minutes: u64,
    pub goals_scored: u64,
    pub assists: u64,
    pub clean_sheets: u64,
    pub goals_conceded: u64,
    pub own_goals: u64,
    pub penalties_saved: u64,
    pub penalties_missed: u64,
    pub yellow_cards: u64,
    pub red_cards: u64,
    pub saves: u64,
    pub bonus: u64,
    pub bps: i64,
    pub influence: String,
    pub creativity: String,
    pub threat: String,
    pub ict_index: String,
    pub clearances_blocks_interceptions: u64,
    pub recoveries: u64,
    pub tackles: u64,
    pub defensive_contribution: u64,
    pub starts: u64,
    pub expected_goals: String,
    pub expected_assists: String,
    pub expected_goal_involvements: String,
    pub expected_goals_conceded: String,
    pub value: u64,
    pub transfers_balance: i64,
    pub selected: u64,
    pub transfers_in: u64,
    pub transfers_out: u64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct HistoryPast {
    pub season_name: String,
    pub element_code: u64,
    pub start_cost: u64,
    pub end_cost: u64,
    pub total_points: i64,
    pub minutes: u64,
    pub goals_scored: u64,
    pub assists: u64,
    pub clean_sheets: u64,
    pub goals_conceded: u64,
    pub own_goals: u64,
    pub penalties_saved: u64,
    pub penalties_missed: u64,
    pub yellow_cards: u64,
    pub red_cards: u64,
    pub saves: u64,
    pub bonus: u64,
    pub bps: i64,
    pub influence: String,
    pub creativity: String,
    pub threat: String,
    pub ict_index: String,
    pub starts: u64,
    pub expected_goals: String,
    pub expected_assists: String,
    pub expected_goal_involvements: String,
    pub expected_goals_conceded: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct PlayerSummary {
    pub history: Vec<PlayerHistory>,
    pub history_past: Vec<HistoryPast>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct LiveData {
    pub elements: Vec<LiveElement>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct LiveElement {
    pub id: u64,
    pub stats: LiveStats,
    pub explain: Vec<LiveExplain>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct LiveStats {
    pub assists: u64,
    pub bonus: u64,
    pub bps: i64,
    pub clean_sheets: u64,
    pub clearances_blocks_interceptions: u64,
    pub creativity: String,
    pub defensive_contribution: u64,
    pub expected_assists: String,
    pub expected_goal_involvements: String,
    pub expected_goals: String,
    pub expected_goals_conceded: String,
    pub goals_conceded: u64,
    pub goals_scored: u64,
    pub ict_index: String,
    pub in_dreamteam: bool,
    pub influence: String,
    pub minutes: u64,
    pub own_goals: u64,
    pub penalties_missed: u64,
    pub penalties_saved: u64,
    pub recoveries: u64,
    pub red_cards: u64,
    pub saves: u64,
    pub starts: u64,
    pub tackles: u64,
    pub threat: String,
    pub total_points: i64,
    pub yellow_cards: u64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct LiveExplain {
    pub fixture: u64,
    pub stats: Vec<LiveExplainStat>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct LiveExplainStat {
    pub identifier: String,
    pub points: i64,
    pub value: u64,
}

#[derive(Default)]
pub struct StatsPoints {
    pub minutes: i64,
    pub goals_scored: i64,
    pub assists: i64,
    pub clean_sheets: i64,
    pub goals_conceded: i64,
    pub saves: i64,
    pub penalties_saved: i64,
    pub penalties_missed: i64,
    pub yellow_cards: i64,
    pub red_cards: i64,
    pub own_goals: i64,
    pub bonus: i64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct EntryHistory {
    pub event: u64,
    pub points: i64,
    pub total_points: i64,
    pub rank: Option<u64>,
    pub rank_sort: Option<u64>,
    pub overall_rank: Option<u64>,
    pub bank: i64,
    pub value: i64,
    pub event_transfers: i64,
    pub event_transfers_cost: i64,
    pub points_on_bench: i64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Pick {
    pub element: u64,
    pub position: u32,
    pub multiplier: u8,
    pub is_captain: bool,
    pub is_vice_captain: bool,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct ManagerPicks {
    pub picks: Vec<Pick>,
    pub entry_history: EntryHistory,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct SeasonHistory {
    pub event: u64,
    pub points: i64,
    pub total_points: i64,
    pub rank: Option<u64>,
    pub overall_rank: Option<u64>,
    pub bank: i64,
    pub value: i64,
    pub event_transfers: u64,
    pub event_transfers_cost: i64,
    pub points_on_bench: i64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct ManagerHistory {
    pub current: Vec<SeasonHistory>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct SetPieceNoteInfo {
    pub external_link: bool,
    pub info_message: String,
    pub source_link: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct SetPieceTeam {
    pub notes: Vec<SetPieceNoteInfo>,
    pub id: u64,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct SetPieceNotes {
    pub last_updated: String,
    pub teams: Vec<SetPieceTeam>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct StandingResult {
    pub id: u64,
    pub event_total: i64,
    pub player_name: String,
    pub rank: u64,
    pub last_rank: u64,
    pub rank_sort: u64,
    pub total: i64,
    pub entry: u64,
    pub entry_name: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Standings {
    pub has_next: bool,
    pub page: u64,
    pub results: Vec<StandingResult>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct League {
    pub id: u64,
    pub name: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct LeagueStandingsResponse {
    pub league: League,
    pub standings: Standings,
}
