Ejemplo n.º 1
0
def _parse_set_piece(raw_event: Dict, next_event: Dict) -> Dict:
    qualifiers = _generic_qualifiers(raw_event)

    result = {}

    if raw_event["subEventName"] in wyscout_events.FREE_KICK.PASS_TYPES:
        result = _parse_pass(raw_event, next_event)
        if raw_event["subEventName"] == wyscout_events.FREE_KICK.GOAL_KICK:
            qualifiers.append(SetPieceQualifier(SetPieceType.GOAL_KICK))
        elif raw_event["subEventName"] == wyscout_events.FREE_KICK.THROW_IN:
            qualifiers.append(SetPieceQualifier(SetPieceType.THROW_IN))
            qualifiers.append(PassQualifier(PassType.HAND_PASS))
        elif raw_event["subEventName"] in [
            wyscout_events.FREE_KICK.FREE_KICK,
            wyscout_events.FREE_KICK.FREE_KICK_CROSS,
        ]:
            qualifiers.append(SetPieceQualifier(SetPieceType.FREE_KICK))
        elif raw_event["subEventName"] == wyscout_events.FREE_KICK.CORNER:
            qualifiers.append(SetPieceQualifier(SetPieceType.CORNER_KICK))
    elif raw_event["subEventName"] in wyscout_events.FREE_KICK.SHOT_TYPES:
        result = _parse_shot(raw_event, next_event)
        if (
            raw_event["subEventName"]
            == wyscout_events.FREE_KICK.FREE_KICK_SHOT
        ):
            qualifiers.append(SetPieceQualifier(SetPieceType.FREE_KICK))
        elif raw_event["subEventName"] == wyscout_events.FREE_KICK.PENALTY:
            qualifiers.append(SetPieceQualifier(SetPieceType.PENALTY))

    result["qualifiers"] = qualifiers
    return result
Ejemplo n.º 2
0
def _get_event_qualifiers(raw_event: Dict,
                          previous_event: Dict = None) -> List[Qualifier]:
    qualifiers = []

    if raw_event["type"] == DF_EVENT_TYPE_THROW_IN:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.THROW_IN))

    if raw_event["type"] == DF_EVENT_TYPE_CORNER_KICK:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.CORNER_KICK))

    if raw_event["type"] in PENALTY_SHOT_EVENTS:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.PENALTY))

    if raw_event["type"] == DF_EVENT_TYPE_SHOT_HEAD_GOAL:
        qualifiers.append(BodyPartQualifier(value=BodyPart.HEAD))

    if (previous_event is not None
            and previous_event["type"] == DF_EVENT_TYPE_GOAL_KICK
            and previous_event["plyrId"] == raw_event["plyrId"]):
        qualifiers.append(SetPieceQualifier(value=SetPieceType.GOAL_KICK))

    if raw_event["type"] == DF_EVENT_TYPE_SHOT_FREE_KICK_GOAL or (
            previous_event is not None
            and previous_event["type"] in FOUL_FREE_KICK_EVENTS):
        qualifiers.append(SetPieceQualifier(value=SetPieceType.FREE_KICK))

    if previous_event is None or previous_event["type"] in GOAL_EVENTS:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.KICK_OFF))

    return qualifiers
Ejemplo n.º 3
0
def _get_set_piece_qualifiers(pass_dict: Dict) -> List[SetPieceQualifier]:
    qualifiers = []
    if "type" in pass_dict:
        type_id = pass_dict["type"]["id"]
        set_piece_type = None
        if type_id == SB_EVENT_TYPE_CORNER_KICK:
            set_piece_type = SetPieceType.CORNER_KICK
        elif type_id == SB_EVENT_TYPE_FREE_KICK:
            set_piece_type = SetPieceType.FREE_KICK
        elif type_id == SB_EVENT_TYPE_PENALTY:
            set_piece_type = SetPieceType.PENALTY
        elif type_id == SB_EVENT_TYPE_THROW_IN:
            set_piece_type = SetPieceType.THROW_IN
        elif type_id == SB_EVENT_TYPE_KICK_OFF:
            set_piece_type = SetPieceType.KICK_OFF
        elif type_id == SB_EVENT_TYPE_GOAL_KICK:
            set_piece_type = SetPieceType.GOAL_KICK
        if set_piece_type:
            qualifiers.append(SetPieceQualifier(value=set_piece_type))
    return qualifiers
Ejemplo n.º 4
0
def _get_event_qualifiers(event_chain: Dict) -> List[Qualifier]:
    qualifiers = []
    if SPORTEC_EVENT_NAME_THROW_IN in event_chain:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.THROW_IN))
    elif SPORTEC_EVENT_NAME_GOAL_KICK in event_chain:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.GOAL_KICK))
    elif SPORTEC_EVENT_NAME_PENALTY in event_chain:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.PENALTY))
    elif SPORTEC_EVENT_NAME_CORNER_KICK in event_chain:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.CORNER_KICK))
    elif SPORTEC_EVENT_NAME_KICKOFF in event_chain:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.KICK_OFF))
    elif SPORTEC_EVENT_NAME_FREE_KICK in event_chain:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.FREE_KICK))
    return qualifiers
Ejemplo n.º 5
0
def _get_event_qualifiers(raw_qualifiers: List) -> List[Qualifier]:
    qualifiers = []
    if EVENT_QUALIFIER_CORNER_KICK in raw_qualifiers:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.CORNER_KICK))
    elif EVENT_QUALIFIER_FREE_KICK in raw_qualifiers:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.FREE_KICK))
    elif EVENT_QUALIFIER_PENALTY in raw_qualifiers:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.PENALTY))
    elif EVENT_QUALIFIER_THROW_IN in raw_qualifiers:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.THROW_IN))
    elif EVENT_QUALIFIER_KICK_OFF in raw_qualifiers:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.KICK_OFF))
    elif EVENT_QUALIFIER_GOAL_KICK in raw_qualifiers:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.GOAL_KICK))

    return qualifiers
Ejemplo n.º 6
0
def _get_event_qualifiers(qualifiers_dict: Dict) -> List[Qualifier]:
    qualifiers = []
    if "type" in qualifiers_dict:
        if qualifiers_dict["type"]["id"] == SB_EVENT_TYPE_CORNER_KICK:
            qualifiers.append(
                SetPieceQualifier(value=SetPieceType.CORNER_KICK))
        elif qualifiers_dict["type"]["id"] == SB_EVENT_TYPE_FREE_KICK:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.FREE_KICK))
        elif qualifiers_dict["type"]["id"] == SB_EVENT_TYPE_PENALTY:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.PENALTY))
        elif qualifiers_dict["type"]["id"] == SB_EVENT_TYPE_THROW_IN:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.THROW_IN))
        elif qualifiers_dict["type"]["id"] == SB_EVENT_TYPE_KICK_OFF:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.KICK_OFF))
        elif qualifiers_dict["type"]["id"] == SB_EVENT_TYPE_GOAL_KICK:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.GOAL_KICK))

    return qualifiers
Ejemplo n.º 7
0
def _get_event_setpiece_qualifiers(previous_event: Dict,
                                   subtypes: List) -> List[Qualifier]:

    qualifiers = []
    previous_event_type_id = previous_event["type"]["id"]
    if previous_event_type_id == MS_SET_PIECE:
        set_piece_subtypes = _parse_subtypes(previous_event)
        if MS_SET_PIECE_CORNER_KICK in set_piece_subtypes:
            qualifiers.append(
                SetPieceQualifier(value=SetPieceType.CORNER_KICK))
        elif MS_SET_PIECE_FREE_KICK in set_piece_subtypes:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.FREE_KICK))
        elif MS_SET_PIECE_PENALTY in set_piece_subtypes:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.PENALTY))
        elif MS_SET_PIECE_THROW_IN in set_piece_subtypes:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.THROW_IN))
        elif MS_SET_PIECE_KICK_OFF in set_piece_subtypes:
            qualifiers.append(SetPieceQualifier(value=SetPieceType.KICK_OFF))
    elif subtypes and MS_SET_PIECE_GOAL_KICK in subtypes:
        qualifiers.append(SetPieceQualifier(value=SetPieceType.GOAL_KICK))

    return qualifiers