Skip to content
#1169
Auto-translated
RedHeavenHero
Why "magical"?
Because in the world of programming, using some vague ("magical") numbers is bad practice, making it difficult to read, understand, and modify the code. What is 0? What is 1? Nobody knows, and it's not clear from the context. It's a different story when using named constants, pre-compiled in a separate location (in this case, the developers have already provided such constants), where they can be centrally changed if necessary.

An exception might be, for example, counters, such as total = total + 1, where one represents the minimum step. In this case, its role is obvious to everyone, and therefore it is not considered "magical" in this context.
RedHeavenHero
Where? Besides, players outside the game are indicated by 4.
Judging by the manual:
PLAYER_NOT_IN_GAME -- Player is not in the game
PLAYER_ACTIVE -- Player is active
PLAYER_WON -- Player won
PLAYER_LOST -- Player lost
Usually, in such lists of constants, the values range from 0 and above, i.e., the value 4, apparently, does not correspond to any of the constants and, probably, indicates players outside the game (again, due to "magical" numbers, one can only make assumptions). But I haven't checked it in practice.

The number 0 is taken from here:
n = n + (GetPlayerState(i) == 1 or 0)
I completely don't understand what it does here, and due to the lack of parentheses, it is not even clear how this construct will be executed, whether the equality check will be performed first, and then OR, or vice versa.

Statistics

Welcome our newest member: den