]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/scores.qh
make the score adding functions return the new score (may help LMS implementation)
[divverent/nexuiz.git] / data / qcsrc / server / scores.qh
1 /**
2  * Attaches a PlayerScore entity to a player. Use that in ClientConnect.
3  * Remember to detach it in ClientDisconnect!
4  */
5 void PlayerScore_Attach(entity player);
6
7 /**
8  * Detaches a PlayerScore entity from the player. Use that in ClientDisconnect.
9  */
10 void PlayerScore_Detach(entity player);
11
12 /**
13  * Adds a score to the player's scores.
14  * NEVER call this if PlayerScore_Attach has not been called yet!
15  * Means: FIXME make players unable to join the game when not called ClientConnect yet.
16  * Returns the new score.
17  */
18 float PlayerScore_Add(entity player, float scorefield, float score);
19
20 /**
21  * Initialize the score of this player if needed.
22  * Does nothing in teamplay.
23  * Use that when a spectator becomes a player.
24  */
25 void PlayerScore_Clear(entity player);
26
27 /**
28  * Adds a score to the player's team's scores.
29  * NEVER call this if team has not been set yet!
30  * Returns the new score.
31  */
32 float TeamScore_Add(entity player, float scorefield, float score);
33
34 /**
35  * Adds a score to the given team.
36  * NEVER call this if team has not been set yet!
37  * Returns the new score.
38  */
39 float TeamScore_AddToTeam(float t, float scorefield, float score);
40
41 /**
42  * Adds a score to both the player and the team.
43  */
44 void PlayerTeamScore_Add(entity player, float pscorefield, float tscorefield, float score);
45
46 /**
47  * Adds to the generic score fields for both the player and the team.
48  */
49 #define PlayerTeamScore_AddScore(p,s) PlayerTeamScore_Add(p, SP_SCORE, ST_SCORE, s)
50
51 /**
52  * Initialize the scores info for the given number of teams.
53  * Immediately set all labels afterwards.
54  */
55 void ScoreInfo_Init(float teams);
56
57 /**
58  * Set the label of a team score item, as well as the scoring flags.
59  */
60 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags);
61
62 /**
63  * Set the label of a player score item, as well as the scoring flags.
64  */
65 void ScoreInfo_SetLabel_PlayerScore(float i, string label, float scoreflags);
66
67 /**
68  * Clear ALL scores (for ready-restart).
69  */
70 void Score_ClearAll();
71
72 /**
73  * Prints the scores (ugly!) to the console.
74  */
75 void Score_DebugPrint();
76
77 /**
78  * Sets the following results for the current scores entities.
79  */
80 void WinningConditionHelper();
81 float WinningConditionHelper_topscore;   ///< highest score
82 float WinningConditionHelper_equality;   ///< 1 if and only if the top two have equal scores
83 float WinningConditionHelper_winnerteam; ///< the color of the winning team, or -1 if none
84 entity WinningConditionHelper_winner;    ///< the winning player, or world if none