from kloppy.domain import FormationType, PositionType

formation_id_mapping = {
    2: FormationType.FOUR_FOUR_TWO,
    3: FormationType.FOUR_ONE_TWO_ONE_TWO,
    4: FormationType.FOUR_THREE_THREE,
    5: FormationType.FOUR_FIVE_ONE,
    6: FormationType.FOUR_FOUR_ONE_ONE,
    7: FormationType.FOUR_ONE_FOUR_ONE,
    8: FormationType.FOUR_TWO_THREE_ONE,
    9: FormationType.FOUR_THREE_TWO_ONE,
    10: FormationType.FIVE_THREE_TWO,
    11: FormationType.FIVE_FOUR_ONE,
    12: FormationType.THREE_FIVE_TWO,
    13: FormationType.THREE_FOUR_THREE,
    14: FormationType.THREE_ONE_THREE_ONE_TWO,
    15: FormationType.FOUR_TWO_TWO_TWO,
    16: FormationType.THREE_FIVE_ONE_ONE,
    17: FormationType.THREE_FOUR_TWO_ONE,
    18: FormationType.THREE_FOUR_ONE_TWO,
    19: FormationType.THREE_ONE_FOUR_TWO,
    20: FormationType.THREE_ONE_TWO_ONE_THREE,
    21: FormationType.FOUR_ONE_THREE_TWO,
    22: FormationType.FOUR_TWO_FOUR_ZERO,
    23: FormationType.FOUR_THREE_ONE_TWO,
    24: FormationType.THREE_TWO_FOUR_ONE,
    25: FormationType.THREE_THREE_THREE_ONE,
}

formation_name_mapping = {
    "442": FormationType.FOUR_FOUR_TWO,
    "41212": FormationType.FOUR_ONE_TWO_ONE_TWO,
    "433": FormationType.FOUR_THREE_THREE,
    "451": FormationType.FOUR_FIVE_ONE,
    "4411": FormationType.FOUR_FOUR_ONE_ONE,
    "4141": FormationType.FOUR_ONE_FOUR_ONE,
    "4231": FormationType.FOUR_TWO_THREE_ONE,
    "4321": FormationType.FOUR_THREE_TWO_ONE,
    "532": FormationType.FIVE_THREE_TWO,
    "541": FormationType.FIVE_FOUR_ONE,
    "352": FormationType.THREE_FIVE_TWO,
    "343": FormationType.THREE_FOUR_THREE,
    "4222": FormationType.FOUR_TWO_TWO_TWO,
    "3511": FormationType.THREE_FIVE_ONE_ONE,
    "3421": FormationType.THREE_FOUR_TWO_ONE,
    "3412": FormationType.THREE_FOUR_ONE_TWO,
    "3142": FormationType.THREE_ONE_FOUR_TWO,
    "343d": FormationType.THREE_ONE_TWO_ONE_THREE,
    "4132": FormationType.FOUR_ONE_THREE_TWO,
    "4312": FormationType.FOUR_THREE_ONE_TWO,
    "3241": FormationType.THREE_TWO_FOUR_ONE,
    "3331": FormationType.THREE_THREE_THREE_ONE,
}

formation_position_mapping = {
    FormationType.FOUR_FOUR_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.RightCentralMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.LeftForward,
        10: PositionType.RightForward,
        11: PositionType.LeftMidfield,
    },
    FormationType.FOUR_ONE_TWO_ONE_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.CenterDefensiveMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightMidfield,
        8: PositionType.CenterAttackingMidfield,
        9: PositionType.LeftForward,
        10: PositionType.RightForward,
        11: PositionType.LeftMidfield,
    },
    FormationType.FOUR_THREE_THREE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.CenterMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightMidfield,
        8: PositionType.LeftMidfield,
        9: PositionType.Striker,
        10: PositionType.RightWing,
        11: PositionType.LeftWing,
    },
    FormationType.FOUR_FIVE_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.RightCentralMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.Striker,
        10: PositionType.CenterMidfield,
        11: PositionType.LeftMidfield,
    },
    FormationType.FOUR_FOUR_ONE_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.RightCentralMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.Striker,
        10: PositionType.CenterAttackingMidfield,
        11: PositionType.LeftMidfield,
    },
    FormationType.FOUR_ONE_FOUR_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.CenterDefensiveMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightMidfield,
        8: PositionType.RightCentralMidfield,
        9: PositionType.Striker,
        10: PositionType.LeftCentralMidfield,
        11: PositionType.LeftMidfield,
    },
    FormationType.FOUR_TWO_THREE_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.RightCentralMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightAttackingMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.Striker,
        10: PositionType.CenterAttackingMidfield,
        11: PositionType.LeftAttackingMidfield,
    },
    FormationType.FOUR_THREE_TWO_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.CenterMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.LeftMidfield,
        8: PositionType.RightMidfield,
        9: PositionType.Striker,
        10: PositionType.RightAttackingMidfield,
        11: PositionType.LeftAttackingMidfield,
    },
    FormationType.FIVE_THREE_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.RightCentralMidfield,
        8: PositionType.CenterMidfield,
        9: PositionType.LeftForward,
        10: PositionType.RightForward,
        11: PositionType.LeftCentralMidfield,
    },
    FormationType.FIVE_FOUR_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.RightMidfield,
        8: PositionType.RightCentralMidfield,
        9: PositionType.Striker,
        10: PositionType.LeftCentralMidfield,
        11: PositionType.LeftMidfield,
    },
    FormationType.THREE_FIVE_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightMidfield,
        3: PositionType.LeftMidfield,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.RightCentralMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.LeftForward,
        10: PositionType.RightForward,
        11: PositionType.CenterMidfield,
    },
    FormationType.THREE_FOUR_THREE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightMidfield,
        3: PositionType.LeftMidfield,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.RightCentralMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.Striker,
        10: PositionType.RightWing,
        11: PositionType.LeftWing,
    },
    FormationType.THREE_ONE_THREE_ONE_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.Unknown,
        3: PositionType.Unknown,
        4: PositionType.Unknown,
        5: PositionType.Unknown,
        6: PositionType.Unknown,
        7: PositionType.Unknown,
        8: PositionType.Unknown,
        9: PositionType.Unknown,
        10: PositionType.Unknown,
        11: PositionType.Unknown,
    },
    FormationType.FOUR_TWO_TWO_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.RightDefensiveMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightCentralMidfield,
        8: PositionType.LeftDefensiveMidfield,
        9: PositionType.LeftForward,
        10: PositionType.RightForward,
        11: PositionType.LeftCentralMidfield,
    },
    FormationType.THREE_FIVE_ONE_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightMidfield,
        3: PositionType.LeftMidfield,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.RightDefensiveMidfield,
        8: PositionType.LeftDefensiveMidfield,
        9: PositionType.Striker,
        10: PositionType.CenterAttackingMidfield,
        11: PositionType.CenterDefensiveMidfield,
    },
    FormationType.THREE_FOUR_TWO_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightMidfield,
        3: PositionType.LeftMidfield,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.RightCentralMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.Striker,
        10: PositionType.RightForward,
        11: PositionType.LeftForward,
    },
    FormationType.THREE_FOUR_ONE_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightMidfield,
        3: PositionType.LeftMidfield,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.RightCentralMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.CenterAttackingMidfield,
        10: PositionType.RightForward,
        11: PositionType.LeftForward,
    },
    FormationType.THREE_ONE_FOUR_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightMidfield,
        3: PositionType.LeftMidfield,
        4: PositionType.CenterBack,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightCentralMidfield,
        8: PositionType.CenterDefensiveMidfield,
        9: PositionType.RightForward,
        10: PositionType.LeftWing,
        11: PositionType.LeftCentralMidfield,
    },
    FormationType.THREE_ONE_TWO_ONE_THREE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightMidfield,
        3: PositionType.LeftMidfield,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.CenterAttackingMidfield,
        8: PositionType.CenterDefensiveMidfield,
        9: PositionType.Striker,
        10: PositionType.RightWing,
        11: PositionType.LeftWing,
    },
    FormationType.FOUR_ONE_THREE_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.CenterDefensiveMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightWing,
        8: PositionType.CenterAttackingMidfield,
        9: PositionType.RightForward,
        10: PositionType.LeftForward,
        11: PositionType.LeftWing,
    },
    FormationType.FOUR_TWO_FOUR_ZERO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.RightCentralMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightWing,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.RightForward,
        10: PositionType.LeftForward,
        11: PositionType.LeftWing,
    },
    FormationType.FOUR_THREE_ONE_TWO: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightBack,
        3: PositionType.LeftBack,
        4: PositionType.CenterMidfield,
        5: PositionType.RightCenterBack,
        6: PositionType.LeftCenterBack,
        7: PositionType.RightMidfield,
        8: PositionType.CenterAttackingMidfield,
        9: PositionType.RightForward,
        10: PositionType.LeftForward,
        11: PositionType.LeftMidfield,
    },
    FormationType.THREE_TWO_FOUR_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightDefensiveMidfield,
        3: PositionType.LeftDefensiveMidfield,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.RightCentralMidfield,
        8: PositionType.LeftCentralMidfield,
        9: PositionType.Striker,
        10: PositionType.RightWing,
        11: PositionType.LeftWing,
    },
    FormationType.THREE_THREE_THREE_ONE: {
        0: None,
        1: PositionType.Goalkeeper,
        2: PositionType.RightDefensiveMidfield,
        3: PositionType.LeftDefensiveMidfield,
        4: PositionType.LeftCenterBack,
        5: PositionType.CenterBack,
        6: PositionType.RightCenterBack,
        7: PositionType.CenterAttackingMidfield,
        8: PositionType.CenterDefensiveMidfield,
        9: PositionType.Striker,
        10: PositionType.RightWing,
        11: PositionType.LeftWing,
    },
}
