Options
All
  • Public
  • Public/Protected
  • All
Menu

This class implements the logic to handle a group of player.

NOTE: the position of the players in a player group is always the absolute position of the players in the field, it's not normalized with the "event" team attacking left to right.

This is not possible since a player group can contain also players from both teams.

If you want to handle tracking coordinates normalized so that the event team plays left to right you should use the position manager methods (ie currentEvent.position.opponentsIn(zone) ...)

Hierarchy

  • PlayerGroup

Implements

Index

Constructors

Methods

  • Returns a player in a PlayerGroup

    Parameters

    • index: number

      index in the player group (starting from 0) or undefined

    Returns PitchPlayer

  • behindZone(playersRole: string, leftTeam: boolean): Zone
  • Get the polygon shape of the zone behind players of a specific role. NOTE: if you call this method directly you will get the ABSOLUTE position of the players in the group, not the position normalized with the event team attacking to the right. If you want to get the normalized position you should use:

    event.position.teammatesBehindZone(playersRole)

    or

    event.position.opponentsBehindZone(playersRole)

    Parameters

    • playersRole: string

      role of the players to consider (e.g., 'Defender').

    • leftTeam: boolean

      wether the team is playing left to rigth (LTR) or not.

    Returns Zone

    the polygon shape of the zone behind the players as a Zone object.

  • Get the depth of a PlayerGroup.

    DEPTH is the horizontal distance between the front-most and back-most player.

    Parameters

    • sport: SportType

      the sport for which the definition is applied.

    Returns number

    the distance in meters or 0 if not available.

  • Returns the first player of the group matching the given condition

    Parameters

    • condition: ((player: PitchPlayer) => boolean)

      function that has the player as argument and returns true if the player matches the desired condition.

    Returns PitchPlayer

    a PitchPlayer or null if no player of the group matches the given condition.

  • Get a player, with tracking coords and speed, from a given group, undefined if the player is not in that group.

    Parameters

    • player: string | IPlayer

      a player to search inside the group

    Returns PitchPlayer

    the player object enriched with tracking data or undefined

  • has(player: string | IPlayer): number
  • Check if a player group include a given player.

    Parameters

    • player: string | IPlayer

      a player to search inside the group

    Returns number

    the index of the player in the group or undefined if not

  • Returns a group of player from the given group that is located in the specified field zone. NOTE: if you call this method directly you will get the ABSOLUTE position of the players in the group, not the position normalized with the event team attacking to the right.

    If you want to get the normalized position you should use:

    event.position.teammatesIn(zone)

    or

    event.position.opponentsIn(zone)

    Parameters

    • zone: Zone

      the zone where the players are located

    Returns PlayerGroup

    a group of player (may be empty)

  • Remove from a group a given player (if it is in the group)

    Parameters

    • player: PitchPlayer

      the player to remove from the group

    Returns void

  • shape(playersToInclude: PlayersToInclude): Zone
  • Get the polygon shape of a PlayerGroup (excluding Goalkeeper). NOTE: if you call this method directly you will get the ABSOLUTE position of the players in the group, not the position normalized with the event team attacking to the right. If you want to get the normalized position you should use:

    event.position.teammatesShape(playersToInclude)

    or

    event.position.opponentsShape(playersToInclude)

    Parameters

    • playersToInclude: PlayersToInclude

      players to use as the vertices of the polygon, wheter all the players or only the external ones (Convex Hull).

    Returns Zone

    the polygon shape of the PlayerGroup as a Zone.

  • Get the width of a PlayerGroup.

    Width is the vertical distance between the left-most and right-most player on a player group

    Parameters

    • sport: SportType

      the sport for which the definition is applied.

    Returns number

    the distance in meters or 0 if not available.

  • withDistanceFrom(x: number, y: number, distance: number): PlayerGroup
  • Returns a group of player from the given group that is distant from a point less than "distance" meters

    Parameters

    • x: number

      x position of the point to measure the distance (in % of the field length)

    • y: number

      y position of the point to measure the distance (in % of the field width)

    • distance: number

      max distance in meters

    Returns PlayerGroup

    a group of player (may be empty)

  • Returns a group of player from the given group that is distant from a player less than "distance" meters

    Parameters

    • player: PitchPlayer

      the player from which to check the distance

    • distance: number

      max distance in meters

    Returns PlayerGroup

    a group of player (may be empty)