#----------------------------------------------------------------------
# 箱庭諸島 ver2.20
# 地図モードモジュール
# 使用条件、使用方法等は、hako-readme.txtファイルを参照
#
# 箱庭諸島のページ: http://t.pos.to/hako/
#----------------------------------------------------------------------
# 「帝国の興亡」 ver1.0.0 by おじー http://t.pos.to/ozzy/
# 使用条件は箱庭諸島に準ずる.詳しくは付属のreadme.txtファイルを参照
#----------------------------------------------------------------------
package H2;
#----------------------------------------------------------------------
# 観光モード
#----------------------------------------------------------------------
# メイン
sub printIslandMain {
# 開放
unlock();
# idから島番号を取得
$H2::currentNumber = $H2::idToNumber{$H2::currentID};
# なぜかその島がない場合
if($H2::currentNumber eq '') {
tempProblem();
return;
}
# 名前の取得
$H2::currentName = $H2::islands[$H2::currentNumber]->{'name'};
# 観光画面
tempPrintIslandHead(); # ようこそ!!
islandInfo(); # 島の情報
islandMap(0); # 島の地図、観光モード
islandData(); # 各種データ
# ○○島ローカル掲示板
tempLbbsHead(); # ローカル掲示板
tempLbbsInput(); # 書き込みフォーム
if ($H2::keepSecretLbbs != 1) {
tempLbbsContents(); # 掲示板内容
}
# 近況
tempRecent(0);
}
#----------------------------------------------------------------------
# 開発モード
#----------------------------------------------------------------------
# メイン
sub ownerMain {
# 開放
unlock();
# モードを明示
$H2::mainMode = 'owner';
# idから島を取得
$H2::currentNumber = $H2::idToNumber{$H2::currentID};
my($island) = $H2::islands[$H2::currentNumber];
$H2::currentName = $island->{'name'};
# パスワード
if(!checkPassword($island->{'password'},$H2::inputPassword)) {
# password間違い
tempWrongPassword();
return;
}
# 開発画面
tempOwner(); # 「開発計画」
# ○○島ローカル掲示板
tempLbbsHead(); # ローカル掲示板
tempLbbsInputOW(); # 書き込みフォーム
tempLbbsContents(); # 掲示板内容
# 近況
tempRecent(1);
}
#----------------------------------------------------------------------
# コマンドモード
#----------------------------------------------------------------------
# メイン
sub commandMain {
# idから島を取得
$H2::currentNumber = $H2::idToNumber{$H2::currentID};
my($island) = $H2::islands[$H2::currentNumber];
$H2::currentName = $island->{'name'};
# パスワード
if(!checkPassword($island->{'password'},$H2::inputPassword)) {
# password間違い
unlock();
tempWrongPassword();
return;
}
# モードで分岐
my($command) = $island->{'command'};
if($H2::commandMode eq 'delete') {
slideFront($command, $H2::commandPlanNumber);
tempCommandDelete();
} elsif(($H2::commandKind == $H2::comAutoPrepare) ||
($H2::commandKind == $H2::comAutoPrepare2)) {
# フル整地、フル地ならし
# 座標配列を作る
makeRandomPointArray();
my($land) = $island->{'land'};
# コマンドの種類決定
my($kind) = $H2::comPrepare;
if($H2::commandKind == $H2::comAutoPrepare2) {
$kind = $H2::comPrepare2;
}
my($i) = 0;
my($j) = 0;
while(($j < $H2::pointNumber) && ($i < $H2::commandMax)) {
my($x) = $H2::rpx[$j];
my($y) = $H2::rpy[$j];
if($land->[$x][$y] == $H2::landWaste) {
slideBack($command, $H2::commandPlanNumber);
$command->[$H2::commandPlanNumber] = {
'kind' => $kind,
'target' => 0,
'x' => $x,
'y' => $y,
'arg' => 0
};
$i++;
}
$j++;
}
tempCommandAdd();
} elsif($H2::commandKind == $H2::comAutoDelete) {
# 全消し
my($i);
for($i = 0; $i < $H2::commandMax; $i++) {
slideFront($command, $H2::commandPlanNumber);
}
tempCommandDelete();
} else {
if($H2::commandMode eq 'insert') {
slideBack($command, $H2::commandPlanNumber);
}
tempCommandAdd();
# コマンドを登録
$command->[$H2::commandPlanNumber] = {
'kind' => $H2::commandKind,
'target' => $H2::commandTarget,
'x' => $H2::commandX,
'y' => $H2::commandY,
'arg' => $H2::commandArg
};
}
# データの書き出し
writeIslandsFile($H2::currentID);
# owner modeへ
ownerMain();
}
#----------------------------------------------------------------------
# コメント入力モード
#----------------------------------------------------------------------
# メイン
sub commentMain {
# idから島を取得
$H2::currentNumber = $H2::idToNumber{$H2::currentID};
my($island) = $H2::islands[$H2::currentNumber];
$H2::currentName = $island->{'name'};
# パスワード
if(!checkPassword($island->{'password'},$H2::inputPassword)) {
# password間違い
unlock();
tempWrongPassword();
return;
}
# メッセージを更新
$island->{'comment'} = htmlEscape($H2::message);
# データの書き出し
writeIslandsFile($H2::currentID);
# コメント更新メッセージ
tempComment();
# owner modeへ
ownerMain();
}
#----------------------------------------------------------------------
# ローカル掲示板モード
#----------------------------------------------------------------------
# メイン
sub localBbsMain {
# idから島番号を取得
$H2::currentNumber = $H2::idToNumber{$H2::currentID};
my($island) = $H2::islands[$H2::currentNumber];
# なぜかその島がない場合
if($H2::currentNumber eq '') {
unlock();
tempProblem();
return;
}
# 削除モードじゃなくて名前かメッセージがない場合
if($H2::lbbsMode != 2) {
if(($H2::lbbsName eq '') || ($H2::lbbsName eq '')) {
unlock();
tempLbbsNoMessage();
return;
}
}
# 観光者モードじゃない時はパスワードチェック
if($H2::lbbsMode != 0) {
if(!checkPassword($island->{'password'},$H2::inputPassword)) {
# password間違い
unlock();
tempWrongPassword();
return;
}
}
my($lbbs);
$lbbs = $island->{'lbbs'};
# モードで分岐
if($H2::lbbsMode == 2) {
# 削除モード
# メッセージを前にずらす
slideBackLbbsMessage($lbbs, $H2::commandPlanNumber);
tempLbbsDelete();
} else {
# 記帳モード
# メッセージを後ろにずらす
slideLbbsMessage($lbbs);
# メッセージ書き込み
my($message);
if($H2::lbbsMode == 0) {
$message = '0';
} else {
$message = '1';
}
$H2::lbbsName = "$H2::islandTurn:" . htmlEscape($H2::lbbsName);
$H2::lbbsMessage = htmlEscape($H2::lbbsMessage);
$lbbs->[0] = "$message>$H2::lbbsName>$H2::lbbsMessage";
tempLbbsAdd();
}
# データ書き出し
writeIslandsFile($H2::currentID);
# もとのモードへ
if($H2::lbbsMode == 0) {
printIslandMain();
} else {
ownerMain();
}
}
# ローカル掲示板のメッセージを一つ後ろにずらす
sub slideLbbsMessage {
my($lbbs) = @_;
my($i);
# pop(@$lbbs);
# push(@$lbbs, $lbbs->[0]);
pop(@$lbbs);
unshift(@$lbbs, $lbbs->[0]);
}
# ローカル掲示板のメッセージを一つ前にずらす
sub slideBackLbbsMessage {
my($lbbs, $number) = @_;
my($i);
splice(@$lbbs, $number, 1);
$lbbs->[$H2::lbbsMax - 1] = '0>>';
}
#----------------------------------------------------------------------
# 島の地図
#----------------------------------------------------------------------
# 情報の表示
sub islandInfo {
my($island) = $H2::islands[$H2::currentNumber];
# 情報表示
my($rank) = $H2::currentNumber + 1;
my($farm) = $island->{'farm'};
my($factory) = $island->{'factory'};
my($mountain) = $island->{'mountain'};
$farm = ($farm == 0) ? "保有せず" : "${farm}0$H2::unitPop";
$factory = ($factory == 0) ? "保有せず" : "${factory}0$H2::unitPop";
$mountain = ($mountain == 0) ? "保有せず" : "${mountain}0$H2::unitPop";
my($mStr1) = '';
my($mStr2) = '';
if(($H2::hideMoneyMode == 1) || ($H2::mainMode eq 'owner')) {
# 無条件またはownerモード
$mStr1 = "
${H2::tagTH_}資金${H2::_tagTH} | ";
$mStr2 = "$island->{'money'}$H2::unitMoney | ";
} elsif($H2::hideMoneyMode == 2) {
my($mTmp) = aboutMoney($island->{'money'});
# 1000億単位モード
$mStr1 = "${H2::tagTH_}資金${H2::_tagTH} | ";
$mStr2 = "$mTmp | ";
}
out(<
| ${H2::tagTH_}順位${H2::_tagTH} |
${H2::tagTH_}人口${H2::_tagTH} |
$mStr1
${H2::tagTH_}食料${H2::_tagTH} |
${H2::tagTH_}面積${H2::_tagTH} |
${H2::tagTH_}農場規模${H2::_tagTH} |
${H2::tagTH_}工場規模${H2::_tagTH} |
${H2::tagTH_}採掘場規模${H2::_tagTH} |
| ${H2::tagNumber_}$rank${H2::_tagNumber} |
$island->{'pop'}$H2::unitPop |
$mStr2
$island->{'food'}$H2::unitFood |
$island->{'area'}$H2::unitArea |
${farm} |
${factory} |
${mountain} |
END
}
# 地図の表示
# 引数が1なら、ミサイル基地等をそのまま表示
sub islandMap {
my($mode) = @_;
my($island);
$island = $H2::islands[$H2::currentNumber];
out(<
END
# 地形、地形値を取得
my($land) = $island->{'land'};
my($landValue) = $island->{'landValue'};
my($l, $lv);
# コマンド取得
my($command) = $island->{'command'};
my($com, @comStr, $i);
if($H2::mainMode eq 'owner') {
for($i = 0; $i < $H2::commandMax; $i++) {
my($j) = $i + 1;
$com = $command->[$i];
if($com->{'kind'} < 20) {
$comStr[$com->{'x'}][$com->{'y'}] .=
" [${j}]$H2::comName[$com->{'kind'}]";
}
}
}
# 座標(上)を出力
out(" ");
# 各地形および改行を出力
my($x, $y);
for($y = 0; $y < $H2::islandSize; $y++) {
# 偶数行目なら番号を出力
if(($y % 2) == 0) {
out(" ");
}
# 各地形を出力
for($x = 0; $x < $H2::islandSize; $x++) {
$l = $land->[$x][$y];
$lv = $landValue->[$x][$y];
landString($l, $lv, $x, $y, $mode, $comStr[$x][$y]);
}
# 奇数行目なら番号を出力
if(($y % 2) == 1) {
out(" ");
}
# 改行を出力
out(" ");
}
out(" |
\n");
}
sub landString {
my($l, $lv, $x, $y, $mode, $comStr) = @_;
my($point) = "($x,$y)";
my($image, $alt);
if($l == $H2::landSea) {
if($lv == 1) {
# 浅瀬
$image = 'land14.gif';
$alt = '海(浅瀬)';
} else {
# 海
$image = 'land0.gif';
$alt = '海';
}
} elsif($l == $H2::landWaste) {
# 荒地
if($lv == 1) {
$image = 'land13.gif'; # 着弾点
$alt = '荒地';
} else {
$image = 'land1.gif';
$alt = '荒地';
}
} elsif($l == $H2::landPlains) {
# 平地
$image = 'land2.gif';
$alt = '平地';
} elsif($l == $H2::landForest) {
# 森
if($mode == 1) {
$image = 'land6.gif';
$alt = "森(${lv}$H2::unitTree)";
} else {
# 観光者の場合は木の本数隠す
$image = 'land6.gif';
$alt = '森';
}
} elsif($l == $H2::landTown) {
# 町
my($p, $n);
if($lv < 30) {
$p = 3;
$n = '村';
} elsif($lv < 100) {
$p = 4;
$n = '町';
} else {
$p = 5;
$n = '都市';
}
$image = "land${p}.gif";
$alt = "$n(${lv}$H2::unitPop)";
} elsif($l == $H2::landFarm) {
# 農場
$image = 'land7.gif';
$alt = "農場(${lv}0${H2::unitPop}規模)";
} elsif($l == $H2::landFactory) {
# 工場
$image = 'land8.gif';
$alt = "工場(${lv}0${H2::unitPop}規模)";
} elsif($l == $H2::landBase) {
if($mode == 0) {
# 観光者の場合は森のふり
$image = 'land6.gif';
$alt = '森';
} else {
# ミサイル基地
my($level) = expToLevel($l, $lv);
$image = 'land9.gif';
$alt = "ミサイル基地 (レベル ${level}/経験値 $lv)";
}
} elsif($l == $H2::landSbase) {
# 海底基地
if($mode == 0) {
# 観光者の場合は海のふり
$image = 'land0.gif';
$alt = '海';
} else {
my($level) = expToLevel($l, $lv);
$image = 'land12.gif';
$alt = "海底基地 (レベル ${level}/経験値 $lv)";
}
} elsif($l == $H2::landDefence) {
# 防衛施設
if($mode == 0 && $H2::dBaseHide) {
# 観光者の場合は森のふり
$image = 'land6.gif';
$alt = '森';
} else {
$image = 'land10.gif';
$alt = '防衛施設';
}
} elsif($l == $H2::landHaribote) {
# ハリボテ
$image = 'land10.gif';
if($mode == 0) {
# 観光者の場合は防衛施設のふり
$alt = '防衛施設';
} else {
$alt = 'ハリボテ';
}
} elsif($l == $H2::landOil) {
# 海底油田
$image = 'land16.gif';
$alt = '海底油田';
} elsif($l == $H2::landMountain) {
# 山
my($str);
$str = '';
if($lv > 0) {
$image = 'land15.gif';
$alt = "山(採掘場${lv}0${H2::unitPop}規模)";
} else {
$image = 'land11.gif';
$alt = '山';
}
} elsif($l == $H2::landMonument) {
# 記念碑
$image = $H2::monumentImage[$lv];
$alt = $H2::monumentName[$lv];
} elsif($l == $H2::landMonster) {
# 怪獣
my($kind, $name, $hp) = monsterSpec($lv);
my($special) = $H2::monsterSpecial[$kind];
$image = $H2::monsterImage[$kind];
# 硬化中?
if((($special == 3) && (($H2::islandTurn % 2) == 1)) ||
(($special == 4) && (($H2::islandTurn % 2) == 0))) {
# 硬化中
$image = $H2::monsterImage2[$kind];
}
$alt = "怪獣$name(体力${hp})";
}
# 開発画面の場合は、座標設定
if($mode == 1) {
out("");
}
out("
");
# 座標設定閉じ
if($mode == 1) {
out("");
}
}
#----------------------------------------------------------------------
# テンプレートその他
#----------------------------------------------------------------------
# 個別ログ表示
sub logPrintLocal {
my($mode) = @_;
my($i);
for($i = 0; $i < $H2::logMax; $i++) {
logFilePrint($i, $H2::currentID, $mode);
}
}
# ○○島へようこそ!!
sub tempPrintIslandHead {
out(<
${H2::tagBig_}${H2::tagName_}「${H2::currentName}島」${H2::_tagName}へようこそ!!${H2::_tagBig}
$H2::tempBack
END
}
# ○○島開発計画
sub tempOwner {
my($campId) =$H2::islands[$H2::currentNumber]->{'score'};
my($camp) = $H2::camp[$H2::idToCampNumber{$campId}];
my($campbbs) = '';
if ($H2::campOnlyBbs) {
$campbbs = "{'bbs'}\">${H2::tagBig_}$camp->{'name'}掲示板へ${H2::_tagBig}";
}
out(<
${H2::tagBig_}${H2::tagName_}${H2::currentName}島${H2::_tagName}開発計画${H2::_tagBig}
$H2::tempBack
${H2::tagBig_}$camp->{'name'}作戦本部へ${H2::_tagBig}
$campbbs
END
islandInfo();
out(<
|
|
END
islandMap(1); # 島の地図、所有者モード
out(<
|
END
for($i = 0; $i < $H2::commandMax; $i++) {
tempCommand($i, $H2::islands[$H2::currentNumber]->{'command'}->[$i]);
}
out(<
| |
${H2::tagBig_}コメント更新${H2::_tagBig}
END
}
# 入力済みコマンド表示
sub tempCommand {
my($number, $command) = @_;
my($kind, $target, $x, $y, $arg) =
(
$command->{'kind'},
$command->{'target'},
$command->{'x'},
$command->{'y'},
$command->{'arg'}
);
my($name) = "$H2::tagComName_${H2::comName[$kind]}$H2::_tagComName";
my($point) = "$H2::tagName_($x,$y)$H2::_tagName";
$target = $H2::idToName{$target};
if($target eq '') {
$target = "無人";
}
$target = "$H2::tagName_${target}島$H2::_tagName";
my($value) = $arg * $H2::comCost[$kind];
if($value == 0) {
$value = $H2::comCost[$kind];
}
if($value < 0) {
$value = -$value;
$value = "$value$H2::unitFood";
} else {
$value = "$value$H2::unitMoney";
}
$value = "$H2::tagName_$value$H2::_tagName";
my($j) = sprintf("%02d:", $number + 1);
out("$H2::tagNumber_$j$H2::_tagNumber");
if(($kind == $H2::comDoNothing) ||
($kind == $H2::comGiveup)) {
out("$name");
} elsif(($kind == $H2::comMissileNM) ||
($kind == $H2::comMissilePP) ||
($kind == $H2::comMissileST) ||
($kind == $H2::comMissileLD)) {
# ミサイル系
my($n) = ($arg == 0 ? '無制限' : "${arg}発");
out("$target$pointへ$name($H2::tagName_$n$H2::_tagName)");
} elsif($kind == $H2::comSendMonster) {
# 怪獣派遣
out("$targetへ$name");
} elsif($kind == $H2::comSell) {
# 食料輸出
out("$name$value");
} elsif($kind == $H2::comPropaganda) {
# 誘致活動
out("$name");
} elsif(($kind == $H2::comMoney) ||
($kind == $H2::comFood)) {
# 援助
out("$targetへ$name$value");
} elsif($kind == $H2::comDestroy) {
# 掘削
if($arg != 0) {
out("$pointで$name(予算${value})");
} else {
out("$pointで$name");
}
} else {
# 座標付き
out("$pointで$name");
}
out("
");
}
# ローカル掲示板
sub tempLbbsHead {
my($string);
if ($H2::keepSecretLbbs) {
$string = "秘密通信";
} else {
$string = "観光者通信";
}
out(<
${H2::tagBig_}${H2::tagName_}${H2::currentName}島${H2::_tagName}$string(全角80文字まで)${H2::_tagBig}
END
}
# ローカル掲示板入力フォーム
sub tempLbbsInput {
out(<
END
}
# ローカル掲示板入力フォーム owner mode用
sub tempLbbsInputOW {
out(<
END
}
# ローカル掲示板内容
sub tempLbbsContents {
my($lbbs, $line);
$lbbs = $H2::islands[$H2::currentNumber]->{'lbbs'};
out(<
| 番号 |
記帳内容 |
END
my($i);
for($i = 0; $i < $H2::lbbsMax; $i++) {
$line = $lbbs->[$i];
if($line =~ /([0-9]*)\>(.*)\>(.*)$/) {
my($j) = $i + 1;
out("| $H2::tagNumber_$j$H2::_tagNumber | ");
if($1 == 0) {
# 観光者
out("$H2::tagLbbsSS_$2 > $3$H2::_tagLbbsSS |
");
} else {
# 島主
out("$H2::tagLbbsOW_$2 > $3$H2::_tagLbbsOW | ");
}
}
}
out(<
END
}
# ローカル掲示板で名前かメッセージがない場合
sub tempLbbsNoMessage {
out(<
END
}
# コマンド登録
sub tempLbbsAdd {
out(<
END
}
# コマンド削除
sub tempCommandDelete {
out(<
END
}
# コマンド登録
sub tempCommandAdd {
out(<
END
}
# コメント変更成功
sub tempComment {
out(<
END
}
# 近況
sub tempRecent {
my($mode) = @_;
out(<
${H2::tagBig_}${H2::tagName_}${H2::currentName}島${H2::_tagName}の近況${H2::_tagBig}
END
logPrintLocal($mode);
}
# 帝国の興亡各種拡張データ表示
sub islandData {
my(@data) = @{$H2::islands[$H2::currentNumber]->{'ext'}};
# 前処理
$data[1] = int($data[1] / 10);
$data[2] .= $data[2] ? '基' : 'なし';
$data[3] .= $data[3] ? '基' : 'なし';
$data[4] .= $data[4] ? '00人' : 'なし';
$data[5] .= $data[5] ? '発' : 'なし';
$data[6] .= $data[6] ? '発' : 'なし';
$data[7] .= $data[7] ? '発' : 'なし';
out(<
| ${H2::tagTH_}貢献度${H2::_tagTH} |
${H2::tagTH_}防撃破${H2::_tagTH} |
${H2::tagTH_}ミ撃破${H2::_tagTH} |
${H2::tagTH_}民救出${H2::_tagTH} |
${H2::tagTH_}ミ飛来${H2::_tagTH} |
${H2::tagTH_}ミ発射${H2::_tagTH} |
${H2::tagTH_}ミ防御${H2::_tagTH} |
| $data[1] |
$data[2] |
$data[3] |
$data[4] |
$data[5] |
$data[6] |
$data[7] |
END
}
1;