# Tips Text Placeholder Replacement Rules

This page describes how placeholders inside Tip Text are dynamically replaced with fixture participant names based on the `isHomeTeamTip` flag.

***

## 1. `{participant}` Placeholder

The `{participant}` placeholder is dynamically replaced with one of the fixture teams. The selected team depends on the `isHomeTeamTip` property.

**Replacement Logic**

* If `isHomeTeamTip = true` → `{participant}` = Home team
* If `isHomeTeamTip = false` → `{participant}` = Away team

**Received Tip**

```
The sum of runs during the 9th inning was less than 2.5, in all of the last 10 away matches that {participant} trailed by the end of the 8th inning.
```

**Example Resolution**

* **Home Team:** Boston Red Sox
* **Away Team:** New York Yankees
* **isHomeTeamTip:** false

**Resolved Tip**

```
The sum of runs during the 9th inning was less than 2.5, in all of the last 10 away matches that New York Yankees trailed by the end of the 8th inning.
```

***

## 2. `{participant}` and `{opponent}` Placeholders

Some tips contain both placeholders:

```
3 of the last 5 away meetings by {participant} against {opponent} ended with less than 14.5 runs.
```

**Replacement Logic**

* Resolve `{participant}` using the same rule as before
* Resolve `{opponent}` as the opposite team:
  * If `{participant}` = Home → `{opponent}` = Away
  * If `{participant}` = Away → `{opponent}` = Home

**Example Resolution**

* **Home Team:** Los Angeles Dodgers
* **Away Team:** San Diego Padres
* **isHomeTeamTip:** true

**Replacements:**

* `{participant}` → Los Angeles Dodgers
* `{opponent}` → San Diego Padres

**Resolved Tip**

```
3 of the last 5 away meetings by Los Angeles Dodgers against San Diego Padres ended with less than 14.5 runs.
```

***

## 3. `{league}` Placeholder

The `{league}` placeholder is used in tips that reference historical performance within a specific competition or league. It should be replaced with the league name associated with the fixture (e.g., MLB, NFL, NBA, Premier League, etc.).

**Replacement Logic**

Replace `{league}` with the competition name of the current fixture. This field is taken directly from the fixture's metadata.

**Example Tip**

```
{participant} didn't lose in 3 of their last 10 matches played in {league}
```

**Example Resolution**

* **Home Team:** Atlanta Braves
* **Away Team:** Philadelphia Phillies
* **isHomeTeamTip:** true
* **Fixture League:** MLB

**Replacements:**

* `{participant}` → Atlanta Braves
* `{league}` → MLB

**Resolved Tip**

```
Atlanta Braves didn't lose in 3 of their last 10 matches played in MLB
```

***

## 4. `{player}` Placeholder

The `{player}` placeholder is used in tips that reference individual player performance. It must be replaced with the player name provided by the tip data model.

**Replacement Logic**

Replace `{player}` with the player's full name supplied in the tip payload.

`{opponent}` is replaced according to the existing team logic:

* If `isHomeTeamTip = true`, `{opponent}` = Away team
* If `isHomeTeamTip = false`, `{opponent}` = Home team

**Example Tip**

```
{player} scored a goal in 3 of his last 5 matches against {opponent}
```

**Example Resolution**

* **Home Team:** Liverpool FC
* **Away Team:** West Ham United
* **isHomeTeamTip:** true
* **Player:** Cody Gakpo

**Replacements:**

* `{player}` → Cody Gakpo
* `{opponent}` → West Ham United

**Resolved Tip**

```
Cody Gakpo scored a goal in 3 of his last 5 matches against West Ham United
```
