#!/usr/bin/perl
#-----------------------------------------------------------#
# 罪と罰++ 二律背反 #
# Copyright(C) 2001-2002 by Vivid Studio. BLANK BOARD #
# Vivid Studio.[ http://www17.big.or.jp/~obochan/vivid/ ] #
# BLANK BOARD [ http://pom.to/ ] #
#-----------------------------------------------------------#
# アイテム図鑑 Version 1.0
# Arranged by あくあ
# HPタイトル [http://aqure.zive.net/]
#--- [注意事項] --------------------------------------------#
# ・このスクリプトは以下の利用規程に従って配布しています。 #
# http://www24.big.or.jp/~obo/game/ore_/gild/ #
#-----------------------------------------------------------#
# 更新履歴
# 1.1a 04.11.08 ソート処理DEBUG
# 1.1 04.11.06 表示をCONFIG順にソート
# 1.1 04.11.03 説明ポップアップ
# 設置方法:
# # 図鑑を表示
# require './inc/ore_sub-collect.cgi';
# &collect_list;
# # 図鑑に登録
# &collect_get(1, $dg_a); # 武具
# &collect_get(2, $dg_a); # 道具
# &collect_get(3, $dg_a); # 防具
#-----------------------------------------------------------
# 設定
#
# 取得したアイテムを記録するファイル
$collect_file = "$usrdata$id"."_col\.cgi";
#-----------------------------------------------------------
#
# 現在の状態を表示
#
sub collect_list {
&collect_read;
foreach (0..$#dg_col_s) {
$ret .= ($_).".$dg_data[$dg_col_s[$_]][1] " if($dg_col_s[$_]>0);
}
$ret .= "
";
foreach (0..$#di_col_s) {
$ret .= ($_).".$di_data[$di_col_s[$_]][1] " if($di_col_s[$_]>0);
}
$ret .= "
";
foreach (0..$#df_col_s) {
$ret .= ($_).".$df_data[$df_col_s[$_]][1] " if($df_col_s[$_]>0);
}
$log .= "
$ret
";
}
#-----------------------------------------------------------
#
# アイテム取得時に &colelct_get($type,$item_no); で呼び出す
#
sub collect_get {
&collect_read;
my $itype = @_[0];
my $ino = @_[1];
$flg_check = &collect_check($itype, $ino);
if(($itype>0 && $itype<4 && $ino>0)
&& ($flg_check>0)) {
if($itype==1){
$dg_col[$#dg_col+1]=$ino;
$log .= qq|
$dg_data[$ino][1]を図鑑に登録しました|;
}elsif($itype==2){
$di_col[$#di_col+1]=$ino;
$log .= qq|
$di_data[$ino][1]を図鑑に登録しました|;
}elsif($itype==3){
$df_col[$#df_col+1]=$ino;
$log .= qq|
$df_data[$ino][1]を図鑑に登録しました|;
}
}
&collect_write;
}
#-----------------------------------------------------------
#
# &collect_readで配列を読み込んだあとチェックする
# -1: 持ってない 1: 所持
#
sub collect_check {
my $itype = @_[0];
my $ino = @_[1];
$flg_check = 1;
if($itype==1){
foreach (0..$#dg_col+1) {
$flg_check = -1 if($dg_col[$_]==$ino);
}
}elsif($itype==2){
foreach (0..$#di_col+1) {
$flg_check = -1 if($di_col[$_]==$ino);
}
}elsif($itype==3){
foreach (0..$#df_col+1) {
$flg_check = -1 if($df_col[$_]==$ino);
}
}
return $flg_check;
}
#-----------------------------------------------------------
#
# ファイルを読み/書き
#
sub collect_read {
if(-e $collect_file){
open(IN,$collect_file) || &error("収集データを開けません
Open Error : $collect_file");
@dat1=;
close(IN);
%COL = '';
@dg_col='';
@di_col='';
@df_col='';
@prats = split(/,/, $dat1[0]);
foreach (0..$#prats) {
my($key,$v) = split(/;/, @prats[$_]);
if($key==1){
$dg_col[$#dg_col+1]=$v;
}elsif($key==2){
$di_col[$#di_col+1]=$v;
}elsif($key==3){
$df_col[$#df_col+1]=$v;
}
}
# ソート
my @temp = @dg_col;
@dg_col_s = sort @temp;
my @temp = @di_col;
@di_col_s = sort @temp;
my @temp = @df_col;
@df_col_s = sort @temp;
}
}
sub collect_write {
&error("open error no such a file!",1) if(!$nm || !$id);
$dat = '';
foreach (0..$#dg_col) {
$dat.="1;$dg_col[$_]," if($dg_col[$_]>0);
}
foreach (0..$#di_col) {
$dat.="2;$di_col[$_]," if($di_col[$_]>0);
}
foreach (0..$#df_col) {
$dat.="3;$df_col[$_]," if($df_col[$_]>0);
}
open (OUT,">$collect_file") || &error("open error: $collect_file",1);
print OUT $dat;
close(OUT) or die "Can't close : $!";
}
1;