# Player ID

A player ID is the player number assigned to a player. For example, when we are referencing to "Player 3" in a trigger, we talking of the player which has the value "3" assigned as his Player ID.

The problem with the current Battle.net 2.0's state is that determining the Player ID isn't intuitive.

## Lobby isn't right

The lobby fills itself without taking in consideration the Game Variants.

The engine tries to fill every first slots of each team before filling seconds, and so on.

## How Battle.net 2.0 assigns Players' ID

The host is assigned the Player ID #1. First player to join: #2. Second player to join: #3. And it keeps going like this until it reaches the maximum (14).

## In-game Player ID vs lobby appearance

Let's imagine a lobby with 2 teams of 2 players (2v2) and some Game Variants:

```(Player) Team [Custom Teams]
Player 1: Team 1 [1]
Player 2: Team 1 [2]
Player 3: Team 2 [1]
Player 4: Team 2 [2]
```

Based on how B.net fills lobbies, the first player to join (after the host) will appear as being the first player of the team #2 (while host is first player of team #1). Second player to join will appear as second player of team #1, and third player to join: second player of team #2.

Thereby, one could think the second player to join (second player of team #1) would be Player 2 because it is intuitive to base the Player ID on the position of the player in the lobby, but this is not how it works!

## How it works

No matter what it looks like in the lobby, the Player ID is based on the order the players join the lobby.

Thus, if we keep the same example and join order of the example explained above, the in-game teams will be:

```First player of the team #1 + First player of the team #2 VS Second player of the team #1 + Second player of the team #2
```

### In the case a player leaves the lobby after joining it

What happens to the leaver's Player ID? This is still to confirm (I forgot to test that in my last testing session).

## Solution

I'll explain how to over-pass this problem with an example: a 3v2v3v1 lobby.

Here's how the Game Variants should look like:

```(Game) Locked Alliances
Yes (Locked)
(Player) Team [Custom Teams]
Player 1: Team 1 [1]
Player 2: Team 2 [1]
Player 3: Team 3 [1]
Player 4: Team 4 [1]
Player 5: Team 1 [2]
Player 6: Team 2 [2]
Player 7: Team 3 [2]
Player 8: Team 1 [3]
Player 9: Team 3 [3]
```

Don't forget to adjust the map's triggers based on this (Player 1, 5 and 8 are in the same team, etc.).