12
12
#include "struct.h"
15
/* Calculate DI to next rank, following server logic */
16
/* Credit: Bill Balcerski, revision 1.2, 2007/04/02 10:12:38, Netrek XP */
17
static float toNextRank(int rank)
20
float rankDI, myDI, oRating, pRating, bRating, Ratings;
22
/* TODO: add support for INL mode */
23
if (!strcmp(me->p_name, "guest") || !strcmp(me->p_name, "Guest"))
28
oRating = offenseRating (me);
29
pRating = planetRating (me);
30
bRating = bombingRating (me);
31
Ratings = oRating + pRating + bRating;
32
myDI = (float) (Ratings * (me->p_stats.st_tticks / 36000.0));
33
rankDI = ranks[rank].ratings * ranks[rank].hours / hourratio;
35
if (Ratings > ranks[rank].ratings)
40
return (rankDI - myDI);
42
else if (Ratings > (ranks[rank-1].ratings))
47
return (2*rankDI - myDI);
49
else if (me->p_stats.st_rank > 0 && Ratings > (ranks[rank-2].ratings))
54
return (4*rankDI - myDI);
56
else if (me->p_stats.st_rank >= 4 && Ratings > (ranks[rank-3].ratings))
61
return (8*rankDI - myDI);
15
67
void ranklist(void)
71
int col = F_sp_rank ? textColor : W_Grey;
20
/* W_ClearWindow(rankw); */
21
(void) strcpy(buf, " Rank Hours Defense Ratings DI");
22
W_WriteText(rankw, 1, 1, textColor, buf, strlen(buf), W_BoldFont);
23
for (i = 0; i < NUMRANKS; i++)
25
sprintf(buf, "%-11.11s %5.0f %8.2f %8.2f %7.2f",
30
ranks[i].ratings * ranks[i].hours);
31
if (mystats->st_rank == i)
33
W_WriteText(rankw, 1, i + 2, W_Cyan, buf, strlen(buf), W_BoldFont);
37
W_WriteText(rankw, 1, i + 2, textColor, buf, strlen(buf), W_RegularFont);
76
W_ResizeTextWindow(rankw, 65, nranks + 9);
79
strcpy(buf, " Rank Hours Offense Ratings DI");
80
W_WriteText(rankw, 1, 1, col, buf, strlen(buf), W_BoldFont);
81
for (i = 0; i < nranks; i++) {
82
sprintf(buf, "%-11.11s %5.0f %8.2f %8.2f %7.2f",
86
ranks[i].ratings, ranks[i].ratings * ranks[i].hours);
87
if (mystats->st_rank == i) {
91
if ((DI = toNextRank(i+1)) != -1) {
92
sprintf(buf2, " (need %.2f DI)", DI);
95
strcat(buf, " (need ratings)");
98
W_WriteText(rankw, 1, i + 2, W_Cyan, buf, strlen(buf), W_BoldFont);
100
W_WriteText(rankw, 1, i + 2, col, buf, strlen(buf), W_RegularFont);
40
103
strcpy(buf, "To achieve a rank, you need the corresponding DI");
41
W_WriteText(rankw, 1, i + 3, textColor, buf, strlen(buf), W_RegularFont);
42
strcpy(buf, "in less than the hours allowed.");
43
W_WriteText(rankw, 1, i + 4, textColor, buf, strlen(buf), W_RegularFont);
44
strcpy(buf, "OR, get offense+boming+planets above corresponding Ratings");
45
W_WriteText(rankw, 1, i + 5, textColor, buf, strlen(buf), W_RegularFont);
104
W_WriteText(rankw, 1, i + 3, col, buf, strlen (buf), W_RegularFont);
105
strcpy(buf, "in less than the hours allowed (DI = ratings x hours).");
106
W_WriteText(rankw, 1, i + 4, col, buf, strlen (buf), W_RegularFont);
107
strcpy(buf, "OR, get offense+bombing+planets above corresponding Ratings");
108
W_WriteText(rankw, 1, i + 5, col, buf, strlen (buf), W_RegularFont);
46
109
strcpy(buf, "Promotions also occur at 2xDI with Ratings - 1");
47
W_WriteText(rankw, 1, i + 6, textColor, buf, strlen(buf), W_RegularFont);
48
strcpy(buf, "and at 4xDI with Ratings - 2");
49
W_WriteText(rankw, 1, i + 7, textColor, buf, strlen(buf), W_RegularFont);
50
strcpy(buf, " also, some servers require .8 defense for promotion.");
51
W_WriteText(rankw, 1, i + 8, textColor, buf, strlen(buf), W_RegularFont);
110
W_WriteText(rankw, 1, i + 6, col, buf, strlen (buf), W_RegularFont);
111
strcpy(buf, "4xDI with Ratings - 2, and 8xDI with Ratings - 3");
112
W_WriteText(rankw, 1, i + 7, col, buf, strlen (buf), W_RegularFont);