ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/item.C
(Generate patch)

Comparing deliantra/server/common/item.C (file contents):
Revision 1.80 by root, Sun Apr 4 02:57:10 2010 UTC vs.
Revision 1.81 by root, Mon Apr 5 20:33:13 2010 UTC

71static char numbers_10[10][20] = { 71static char numbers_10[10][20] = {
72 "zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", 72 "zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy",
73 "eighty", "ninety" 73 "eighty", "ninety"
74}; 74};
75 75
76static char levelnumbers[21][20] = { 76static char ordnumbers[21][20] = {
77 "zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", 77 "zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh",
78 "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", 78 "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth",
79 "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteen", 79 "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth",
80 "nineteen", "twentieth" 80 "nineteenth", "twentieth"
81}; 81};
82 82
83static char levelnumbers_10[11][20] = { 83static char ordnumbers_10[11][20] = {
84 "zeroth", "tenth", "twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", 84 "zeroth", "tenth", "twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth",
85 "seventieth", "eightieth", "ninetieth" 85 "seventieth", "eightieth", "ninetieth"
86}; 86};
87 87
88/* The following is a large table of item types, the fields are: 88/* The following is a large table of item types, the fields are:
387/* 387/*
388 * Returns the pointer to a static buffer containing 388 * Returns the pointer to a static buffer containing
389 * the number requested (of the form first, second, third...) 389 * the number requested (of the form first, second, third...)
390 */ 390 */
391const char * 391const char *
392get_levelnumber (int i) 392ordinal (int i)
393{ 393{
394 static char buf[MAX_BUF]; 394 if (i < 0)
395 395 return format ("minus %s", ordinal (-i));
396 if (i > 99)
397 {
398 sprintf (buf, "%d.", i);
399 return buf;
400 }
401 396
402 if (i < 21) 397 if (i < 21)
403 return levelnumbers[i]; 398 return ordnumbers[i];
404 399
400 int digit = i % 10;
401
405 if (!(i % 10)) 402 if (i >= 100)
403 return format (
404 digit == 1 ? "%dst"
405 : digit == 2 ? "%dnd"
406 : digit == 3 ? "%drd"
407 : "%dth",
408 i
409 );
410
411 if (digit == 0)
406 return levelnumbers_10[i / 10]; 412 return ordnumbers_10[i / 10];
407 413 else
408 strcpy (buf, numbers_10[i / 10]); 414 return format ("%s%s", numbers_10[i / 10], ordnumbers[i % 10]);
409 strcat (buf, levelnumbers[i % 10]);
410 return buf;
411} 415}
412 416
413/* 417/*
414 * Returns pointer to static buffer containing ring's or amulet's 418 * Returns pointer to static buffer containing ring's or amulet's
415 * abilities 419 * abilities
1208 1212
1209 switch (type) 1213 switch (type)
1210 { 1214 {
1211 case SPELLBOOK: 1215 case SPELLBOOK:
1212 if (flag [FLAG_IDENTIFIED] && inv) 1216 if (flag [FLAG_IDENTIFIED] && inv)
1213 buf.printf ("%s is a level %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill); 1217 buf.printf ("%s is a %s level %s spell.\r", &inv->name, ordinal (inv->level), &inv->skill);
1214 break; 1218 break;
1215 1219
1216 case BOOK: 1220 case BOOK:
1217 if (msg) 1221 if (msg)
1218 buf << "Something is written in it.\r"; 1222 buf << "Something is written in it.\r";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines