1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | use Fcntl (); |
3 | use Fcntl (); |
4 | use Coro::AIO; |
4 | use Coro::AIO; |
5 | |
5 | |
6 | our $HIGHSCORE_ENTRIES = $cf::CFG{highscore_entries} || 1000; |
6 | CONF HIGHSCORE_ENTRIES = 1000 |
|
|
7 | CONF EXPORT_HIGHSCORE = "www.deliantra.net/highscore.json" |
7 | |
8 | |
8 | our $HIGHSCORE; |
9 | our $HIGHSCORE; |
9 | |
10 | |
10 | # [name, title, exp, killer, where, hp, sp, gp, uuid] |
11 | # [name, title, exp, killer, where, hp, sp, gp, uuid] |
11 | |
12 | |
… | |
… | |
148 | $ob->send_msg ($SCORE_CHANNEL => $msg, cf::NDI_CLEAR); |
149 | $ob->send_msg ($SCORE_CHANNEL => $msg, cf::NDI_CLEAR); |
149 | |
150 | |
150 | if ($save) { |
151 | if ($save) { |
151 | save_highscore |
152 | save_highscore |
152 | or die "unable to write highscore file: $!"; |
153 | or die "unable to write highscore file: $!"; |
|
|
154 | |
|
|
155 | if (defined $EXPORT_HIGHSCORE) { |
|
|
156 | cf::get_slot 0.05, 0, "highscore export"; |
|
|
157 | |
|
|
158 | my $rank; |
|
|
159 | my @highscore = map { |
|
|
160 | my ($name, $title, $exp, $killer, $map, $hp, $sp, $grace) = @$_; |
|
|
161 | [++$rank, $name, $title, (cf::exp_to_level $exp), $exp, $killer, $map, $hp, $sp, $grace] |
|
|
162 | } @$HIGHSCORE; |
|
|
163 | |
|
|
164 | cf::replace_file $EXPORT_HIGHSCORE, cf::encode_json { |
|
|
165 | version => 1, |
|
|
166 | date => $cf::NOW, |
|
|
167 | data => \@highscore, |
|
|
168 | }; |
|
|
169 | } |
153 | } |
170 | } |
154 | } |
171 | } |
155 | |
172 | |