OSDN Git Service
(root)
/
jnethack
/
tool.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
add monobj
[jnethack/tool.git]
/
monobj
/
patchmonst.pl
1
#!
2
use strict;
3
use warnings;
4
5
use Data::Dumper;
6
7
my %type = (
8
PROJECTILE => ')',
9
WEAPON => ')',
10
BOW => ')',
11
HELM => ']',
12
ARMOR => ']',
13
DRGN_ARMR => ']',
14
CLOAK => ']',
15
SHIELD => ']',
16
GLOVES => ']',
17
BOOTS => ']',
18
RING => '=',
19
AMULET => '"',
20
CONTAINER => '(',
21
TOOL => '(',
22
WEPTOOL => '(',
23
FOOD => '%',
24
POTION => '!',
25
SCROLL => '?',
26
SPELL => '+',
27
WAND => '/',
28
COIN => '$',
29
GEM => '*',
30
ROCK => '*',
31
'OBJECT(OBJ' => 'K',
32
);
33
34
{
35
my %base;
36
37
open my $fd, '<', 'jtrnsmon.dat' or die;
38
39
while(<$fd>){
40
if(!/^([^:]*):\t*([^:]*):/){next;}
41
my($e, $j) = ($1, $2, $3);
42
$base{$e} = $j;
43
}
44
close $fd;
45
46
open my $fr, '<', 'monst.c' or die;
47
48
my @orig;
49
while(<$fr>){
50
push @orig, $_;
51
}
52
close $fr;
53
54
open my $fw, '>', 'monstj.c' or die;
55
binmode($fw);
56
for(@orig){
57
if(/^ *MON\("([^\"]*)"/){
58
my $j = $base{$1};
59
if(defined $j){
60
s/$1/$j/;
61
}
62
}
63
print $fw $_;
64
}
65
close $fw;
66
}