ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/doc/playbook/treas2-extract
Revision: 1.2
Committed: Thu Sep 7 21:43:17 2006 UTC (17 years, 9 months ago) by pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
Moved documents to doc/historic

File Contents

# User Rev Content
1 root 1.1 # treas-extract - parse the treasures-file and output the
2     # player's stats in a structured format.
3    
4     # read in the list of player randomitems from randitem
5     BEGIN {
6     # yeah, its kludgey, but hey, I've been programming awk for
7     # all of 1 day!
8    
9     ignoreitem["ability_fire"] = 1;
10     ignoreitem["magic"] = 1;
11     ignoreitem["more"] = 1;
12     ignoreitem["basic_skills"] = 1;
13     ignoreitem["wizard_skills"] = 1;
14     ignoreitem["spell_skills"] = 1;
15     ignoreitem["priest_skills"] = 1;
16     ignoreitem["fighter_skills"] = 1;
17     ignoreitem["random_knowledge"] = 1;
18     ignoreitem["player_force"] = 1;
19     ignoreitem["nrof"] = 1;
20     ignoreitem["no_class_face_change"] = 1;
21    
22     plural["arrow"] = 1;
23    
24     newname["mage_skills"] = "talisman";
25     newname["nunchacu_1"] = "nunchacu";
26     newname["r_sack"] = "ruck sack";
27     newname["cleric_book"] = "prayer book";
28     newname["book"] = "spell book";
29    
30     # Read the player treasure types
31     pl = 0;
32     while ((getline buff < eqitems) == 1) {
33     nr = split(buff, line, ",");
34     player[pl] = line[1];
35     list[pl] = line[2];
36     pl++;
37     }
38     close(playerlist);
39    
40     }
41    
42     $1 == "treasure" {
43     for ( i=0; i < pl ; i++ ) {
44     if ($2 == list[i]) { # matched players list
45     nrloop=0;
46     do {
47     getline;
48     if($1 in ignoreitem) continue;
49     if($1 == ("yes"||"no")) {
50     nrloop++;
51     continue;
52     } else if($1 == "end") {
53     if(nrloop==0) { break; } else { nrloop--; }
54     continue;
55     }
56     if($2 ~ "^skill") continue;
57     if($2 ~ "^abil") continue;
58     if($2 ~ "force$") continue;
59     if($2 in ignoreitem) continue;
60     equip = $2;
61     if(equip in plural) equip = sprintf("%ss",equip);
62     if(equip in newname) equip = newname[equip];
63     equiplist[i] = sprintf("%s,%s",equiplist[i],equip);
64     } while ( $1 != ("treasure" || "treasureone" || "list" ) )
65     }
66     }
67     }
68    
69     END {
70     close("trease");
71     # now print this stuff out in correct order!
72     for(i=0;i<pl;i++) {
73     printf("%s & ",capitalize(player[i]));
74     nr = split(equiplist[i], eq, ",");
75     if(nr==0) {
76     # hmm. This can happen if 2 or more character classes
77     # share the same treaure list. Lets find it.
78     for(j=0;j<pl;j++)
79     if(list[i]==list[j]) break;
80     nr = split(equiplist[j], eq, ",");
81     }
82     gsub("_", " ", eq[nr]);
83     printf("%s",capitalize(eq[nr--]));
84     do {
85     printf(", ");
86     gsub("_", " ", eq[nr]);
87     # printf("& %s\\\\\n",capitalize(eq[nr]));
88     printf("%s",capitalize(eq[nr]));
89     } while (--nr>1);
90     printf(" \\\\\n");
91     }
92     }
93    
94     function capitalize(str) {
95     return toupper(substr(str, 1, 1)) substr(str, 2);
96     }
97