MinoMino / minqlx

Extends Quake Live's dedicated server with extra functionality and scripting.
GNU General Public License v3.0
112 stars 42 forks source link

Add is_team_game method #90

Closed tjone270 closed 5 years ago

tjone270 commented 5 years ago

It's often useful to be able to determine if the current game is a team one or not easily.

em92 commented 5 years ago

Cool! I need to take it to 1.0 branch with some other additions from here https://gist.github.com/em92/9a7ce6984261cb37c6ebe79b558d772c

Currently list is old, some fixes are already included in 0.5.2. Wanted to release 1.0.0 version, but failed during testing, 'cos servers were constantly crashing.

I will find time to make 1.0 branch later.

em92 commented 5 years ago

Btw, expressions like 'a < b < c' work in python and are more readable. So, I suggest to edit your commit

tjone270 commented 5 years ago

Hi @em92,

I don't think I could use chained comparisions here, as they work slightly differently to my standard method.

Excerpt from the Python documentation on expressions:

Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent to x < y and y <= z, except that y is evaluated only once (but in both cases z is not evaluated at all when x < y is found to be false).

Formally, if a, b, c, …, y, z are expressions and op1, op2, …, opN are comparison operators, then a op1 b op2 c ... y opN z is equivalent to a op1 b and b op2 c and ... y opN z, except that each expression is evaluated at most once.

Note that a op1 b op2 c doesn’t imply any kind of comparison between a and c, so that, e.g., x < y > z is perfectly legal (though perhaps not pretty).
em92 commented 5 years ago

I don't think I could use chained comparisions here

3 <= int(self["g_gametype"]) < 12

Didn't understand, why not?

tjone270 commented 5 years ago

You're right, I was doing it incorrectly.