-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests
- Loading branch information
Showing
2 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,54 @@ | ||
// generated by "sampctl package generate" | ||
|
||
#include <a_samp> | ||
#include "foreach.inc" | ||
|
||
#define MAX_TEAMS 5 | ||
|
||
new | ||
gPlayerScore[MAX_PLAYERS] = {10, ...}, | ||
Iterator:Team[MAX_TEAMS]<MAX_PLAYERS>; | ||
|
||
stock Team_SetPlayerTeam(playerid, teamid) | ||
{ | ||
new current_team = GetPlayerTeam(playerid); | ||
if (current_team != NO_TEAM && current_team != -1) { | ||
Iter_Remove(Team[current_team], playerid); | ||
} | ||
|
||
if (teamid != NO_TEAM) { | ||
Iter_Add(Team[teamid], playerid); | ||
} | ||
|
||
return SetPlayerTeam(playerid, teamid); | ||
} | ||
#if defined _ALS_SetPlayerTeam | ||
#undef SetPlayerTeam | ||
#else | ||
#define _ALS_SetPlayerTeam | ||
#endif | ||
|
||
#define SetPlayerTeam Team_SetPlayerTeam | ||
|
||
main() { | ||
// write tests for libraries here and run "sampctl package run" | ||
Iter_Init(Team); | ||
|
||
SetPlayerTeam(0, 1); | ||
SetPlayerTeam(1, 1); | ||
SetPlayerTeam(2, 2); | ||
SetPlayerTeam(3, 3); | ||
|
||
printf("Iter_Index(Team[1], 1) = %d", Iter_Index(Team[1], 1)); | ||
printf("Iter_Last(Team[1]) = %d", Iter_Last(Team[1])); | ||
|
||
new scores[MAX_TEAMS]; | ||
for (new teamid; teamid < MAX_TEAMS; teamid++) { | ||
foreach (new playerid : Team[teamid]) { | ||
scores[teamid] += gPlayerScore[playerid]; | ||
} | ||
} | ||
|
||
for (new teamid; teamid < MAX_TEAMS; teamid++) { | ||
printf("Team %d: %d", teamid, scores[teamid]); | ||
} | ||
} |