| 1 |
BEGIN { |
| 2 |
oldFS=FS; FS=":"; |
| 3 |
crosscmd = crosscmd " 2>&1"; |
| 4 |
while (crosscmd | getline == 1) { |
| 5 |
if ($2 != "(null)" && $2 != "null" ) |
| 6 |
before[$1] = $2; |
| 7 |
if ($3 != "(null)" && $3 != "null" ) |
| 8 |
after[$1] = $3; |
| 9 |
} |
| 10 |
close(crosscmd); |
| 11 |
FS=oldFS; |
| 12 |
} |
| 13 |
|
| 14 |
/^spell spells/,/^}/ { |
| 15 |
++line; |
| 16 |
if (line < 3 || $0 ~ /^}/) |
| 17 |
next; |
| 18 |
if ($4 > 0 || $7 > 0 || $8 > 0) { |
| 19 |
spell = $1; sub("^[{ \t]*", "", spell); |
| 20 |
level = $2; sp = $3; |
| 21 |
checks = sprintf("%s & %s & %s", |
| 22 |
check($4), check($7), check($8)); |
| 23 |
# wand, scroll, book |
| 24 |
# Skip the next line, we have the info needed in the mappings |
| 25 |
getline; |
| 26 |
|
| 27 |
arch_b = (spell in before) ? "~~" before[spell] "~~" : ""; |
| 28 |
arch_a = (spell in after) ? "~~" after[spell] "~~" : ""; |
| 29 |
|
| 30 |
printf("%s &%s &%s &%d &%d &%s \\\\\n", |
| 31 |
capitalize(spell), arch_b, arch_a, level, sp, checks); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
function check(i) { |
| 36 |
return (i+0 != 0) ? "$\\surd$" : ""; |
| 37 |
} |
| 38 |
|
| 39 |
function capitalize(str) { |
| 40 |
return toupper(substr(str, 1, 1)) substr(str, 2); |
| 41 |
} |