… | |
… | |
34 | $ing |
34 | $ing |
35 | } |
35 | } |
36 | } |
36 | } |
37 | |
37 | |
38 | my $DEBUG = 1; |
38 | my $DEBUG = 1; |
|
|
39 | |
|
|
40 | sub merge { |
|
|
41 | my ($chdl, $sk, $pl, $do_analyze) = @_; |
|
|
42 | |
|
|
43 | my $ingred = $chdl->extract_jeweler_ingredients; |
|
|
44 | my @ring = $ingred->get_ring; |
|
|
45 | my @rings = map { Jeweler::Object->new (object => $_) } @ring; |
|
|
46 | |
|
|
47 | if (@rings < 2) { |
|
|
48 | $pl->message ("You slap yourself, you forgot to put at least 2 jeweles in!"); |
|
|
49 | } |
|
|
50 | |
|
|
51 | my $ring = shift @rings; |
|
|
52 | $ring->improve_by_ring (@rings); |
|
|
53 | |
|
|
54 | if ($do_analyze) { |
|
|
55 | $pl->message ("You want to make a " . $ring->to_string . ": " . $ring->analyze ($sk, $pl)); |
|
|
56 | if ($pl->get_flag (cf::FLAG_WIZ)) { |
|
|
57 | $ring->wiz_analyze ($pl); |
|
|
58 | } |
|
|
59 | return; |
|
|
60 | } |
|
|
61 | |
|
|
62 | make_ring ($chdl, $ingred, $ring, $sk, $pl); |
|
|
63 | } |
|
|
64 | |
|
|
65 | sub make_ring { |
|
|
66 | my ($chdl, $ingred, $ring, $sk, $pl) = @_; |
|
|
67 | |
|
|
68 | if (!$pl->get_flag (cf::FLAG_WIZ)) { |
|
|
69 | $ingred->remove ('rings'); |
|
|
70 | $ingred->remove ('ammys'); |
|
|
71 | } |
|
|
72 | |
|
|
73 | my $ch = $ring->get_chance_perc ($sk); |
|
|
74 | my $succ = 0; |
|
|
75 | my $r = cf::random_roll (0, 100, $pl, cf::PREFER_HIGH); |
|
|
76 | if ($r <= $ch) { |
|
|
77 | $pl->message ("You succeed."); |
|
|
78 | } else { |
|
|
79 | $pl->message ("You fail!"); |
|
|
80 | $ring->negate; |
|
|
81 | } |
|
|
82 | $chdl->put ($ring->to_object); |
|
|
83 | } |
39 | |
84 | |
40 | cf::attach_to_type cf::SKILL, cf::SK_JEWELER, |
85 | cf::attach_to_type cf::SKILL, cf::SK_JEWELER, |
41 | on_use_skill => sub { |
86 | on_use_skill => sub { |
42 | my ($sk, $ob, $part, $dir, $msg) = @_; |
87 | my ($sk, $ob, $part, $dir, $msg) = @_; |
43 | my $pl = $ob; |
88 | my $pl = $ob; |
… | |
… | |
74 | return |
119 | return |
75 | } |
120 | } |
76 | |
121 | |
77 | Jeweler::simple_converter ($player, $ingred, $chdl, $1); |
122 | Jeweler::simple_converter ($player, $ingred, $chdl, $1); |
78 | |
123 | |
|
|
124 | } elsif ($msg =~ m/^\s*merge\s*analy[sz]e\s*$/i) { |
|
|
125 | merge ($chdl, $sk, $pl, 1); |
|
|
126 | |
79 | } elsif ($msg =~ m/^\s*merge\s*$/i) { |
127 | } elsif ($msg =~ m/^\s*merge\s*$/i) { |
80 | my $ingred = $chdl->extract_jeweler_ingredients; |
128 | merge ($chdl, $sk, $pl, 0); |
81 | my @ring = $ingred->get_ring; |
|
|
82 | my @rings = map { Jeweler::Object->new (object => $_) } @ring; |
|
|
83 | |
|
|
84 | my $ring = shift @rings; |
|
|
85 | $ring->improve_by_ring (@rings); |
|
|
86 | $ring->power_to_level; |
|
|
87 | |
129 | |
88 | } else { |
130 | } else { |
89 | my $ingred = $chdl->extract_jeweler_ingredients; |
131 | my $ingred = $chdl->extract_jeweler_ingredients; |
90 | my $plan = $ingred->get_plan; |
132 | my $plan = $ingred->get_plan; |
91 | |
133 | |
… | |
… | |
122 | $pl->message ("You want to make a " . $iring->to_string . ": " . $iring->analyze ($sk, $pl)); |
164 | $pl->message ("You want to make a " . $iring->to_string . ": " . $iring->analyze ($sk, $pl)); |
123 | $pl->message ("You recognize that you are short of: " |
165 | $pl->message ("You recognize that you are short of: " |
124 | . (join ", ", |
166 | . (join ", ", |
125 | map { my $cost = $remcosts->{$_}; $cost . " " . ($cost > 1 ? "times" : "time") . " " . ingred_alias ($_) } |
167 | map { my $cost = $remcosts->{$_}; $cost . " " . ($cost > 1 ? "times" : "time") . " " . ingred_alias ($_) } |
126 | grep { $remcosts->{$_} > 0 } keys %$remcosts)); |
168 | grep { $remcosts->{$_} > 0 } keys %$remcosts)); |
|
|
169 | |
127 | if ($pl->get_flag (cf::FLAG_WIZ)) { |
170 | if ($pl->get_flag (cf::FLAG_WIZ)) { |
128 | $iring->wiz_analyze ($pl); |
171 | $iring->wiz_analyze ($pl); |
129 | } |
172 | } |
130 | } else { |
173 | } else { |
131 | if (!$pl->get_flag (cf::FLAG_WIZ)) { |
174 | if (!$pl->get_flag (cf::FLAG_WIZ)) { |
132 | $ingred->check_costs (\%cdiff, 1); |
175 | $ingred->check_costs (\%cdiff, 1); |
133 | $ingred->remove ('rings'); |
|
|
134 | $ingred->remove ('ammys'); |
|
|
135 | } |
176 | } |
136 | |
177 | make_ring ($chdl, $ingred, $iring, $sk, $pl); |
137 | my $ch = $iring->get_chance_perc ($sk); |
|
|
138 | my $succ = 0; |
|
|
139 | my $r = cf::random_roll (0, 100, $pl, cf::PREFER_HIGH); |
|
|
140 | if ($r <= $ch) { |
|
|
141 | $pl->message ("You succeed."); |
|
|
142 | } else { |
|
|
143 | $pl->message ("You fail!"); |
|
|
144 | $iring->negate; |
|
|
145 | } |
|
|
146 | $chdl->put ($iring->to_object); |
|
|
147 | } |
178 | } |
148 | } |
179 | } |
149 | } else { |
180 | } else { |
150 | $pl->message ("You've got no idea what you are planning to do!"); |
181 | $pl->message ("You've got no idea what you are planning to do!"); |
151 | } |
182 | } |