1 |
pippijn |
1.1 |
BEGIN { |
2 |
|
|
# special is a list of what special things we should look for. |
3 |
|
|
# The value of the array is how many commas we should skip. |
4 |
|
|
special["attacks"] = 1; |
5 |
|
|
special["protected"] = 1; |
6 |
|
|
special["immune"] = 1; |
7 |
|
|
special["vulnerable"] = 1; |
8 |
|
|
special["spell abilities"] = 1; |
9 |
|
|
} |
10 |
|
|
|
11 |
|
|
{ |
12 |
|
|
|
13 |
|
|
# Old stuff: |
14 |
|
|
# if ($2 > 25000) z = "Ordeal"; |
15 |
|
|
# else if ($2 > 10000) z = "Mighty"; |
16 |
|
|
# else if ($2 > 5000) z = "Powerful"; |
17 |
|
|
# else if ($2 > 1000) z = "Dangerous"; |
18 |
|
|
# else if ($2 > 400) z = "Tough"; |
19 |
|
|
# else if ($2 > 200) z = "Tricky"; |
20 |
|
|
# else if ($2 > 100) z = "Hard"; |
21 |
|
|
# else if ($2 > 50) z = "Easy"; |
22 |
|
|
# else if ($2 > 25) z = "Simple"; |
23 |
|
|
# else if ($2 > 14) z = "Weak"; |
24 |
|
|
# else if ($2 > 8) z = "Feeble"; |
25 |
|
|
# else z = "Defenseless"; |
26 |
|
|
|
27 |
|
|
# Expl: |
28 |
|
|
# name - .. |
29 |
|
|
# comma - Print a comma or not |
30 |
|
|
# antall - number of (sub)fields in the 'Special' field; antall(Nor) <-> "number of". |
31 |
|
|
# i - counter. Should start as values 2. |
32 |
|
|
|
33 |
|
|
name = capitalize($1); |
34 |
|
|
sub("_", " ", name); |
35 |
|
|
comma = 0; |
36 |
|
|
# The split allows "(", ")(", ", ", ":", ":)(" etc. as delimiters |
37 |
|
|
antall = split($5, field, "([():,][():,]*) *"); |
38 |
|
|
|
39 |
|
|
printf("%s &~~%s~~ &%s &%s &%s &%s &", |
40 |
|
|
name, $6, $7 ? "~~" $7 "~~" : "", $2, $3, $4); |
41 |
|
|
for (i = 2; i < antall; i++) { |
42 |
|
|
if (field[i] in special) { |
43 |
|
|
if (comma > 0) |
44 |
|
|
printf("\\newline "); |
45 |
|
|
printf("%s: ", capitalize(field[i])); |
46 |
|
|
comma = 1 - special[field[i]]; |
47 |
|
|
} else { |
48 |
|
|
if (comma > 0) |
49 |
|
|
printf(", "); |
50 |
|
|
else |
51 |
|
|
++comma; |
52 |
|
|
printf(i == 2 ? capitalize(field[i]) : field[i]); |
53 |
|
|
} |
54 |
|
|
} |
55 |
|
|
printf("\\\\\n"); |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
function capitalize(str) { |
59 |
|
|
return toupper(substr(str, 1, 1)) substr(str, 2); |
60 |
|
|
} |