267 lines
7.9 KiB
Plaintext
267 lines
7.9 KiB
Plaintext
|
#----------------------------------------------------------------------
|
||
|
# 箱庭諸島 ver2.30
|
||
|
# トップモジュール(ver1.00)
|
||
|
# 使用条件、使用方法等は、hako-readme.txtファイルを参照
|
||
|
#
|
||
|
# 箱庭諸島のページ: http://www.bekkoame.ne.jp/~tokuoka/hakoniwa.html
|
||
|
#----------------------------------------------------------------------
|
||
|
|
||
|
|
||
|
#----------------------------------------------------------------------
|
||
|
# トップページモード
|
||
|
#----------------------------------------------------------------------
|
||
|
# メイン
|
||
|
sub topPageMain {
|
||
|
# 開放
|
||
|
unlock();
|
||
|
|
||
|
# テンプレート出力
|
||
|
tempTopPage();
|
||
|
}
|
||
|
|
||
|
# トップページ
|
||
|
sub tempTopPage {
|
||
|
my $timestamp = $HislandLastTime + $HunitTime;
|
||
|
my ($sec, $min, $hour, $day, $mon, $year) = localtime($timestamp);
|
||
|
$year += 1900;
|
||
|
$mon += 1;
|
||
|
my $nextTurnDate = sprintf("%04d/%02d/%02d %02d:%02d", $year, $mon, $day, $hour, $min);
|
||
|
my $turnLength = $HunitTime / 60 / 60;
|
||
|
|
||
|
# Calculate time until next turn
|
||
|
my $currentTime = time();
|
||
|
my $timeUntilNextTurn = $timestamp - $currentTime;
|
||
|
my $hoursUntilNextTurn = int($timeUntilNextTurn / 3600);
|
||
|
my $minutesUntilNextTurn = int(($timeUntilNextTurn % 3600) / 60);
|
||
|
|
||
|
# タイトル
|
||
|
out(<<END);
|
||
|
${HtagTitle_}$Htitle${H_tagTitle}
|
||
|
END
|
||
|
# デバッグモードなら「ターンを進める」ボタン
|
||
|
if($Hdebug == 1) {
|
||
|
out(<<END);
|
||
|
<FORM action="$HthisFile" method="POST">
|
||
|
<INPUT TYPE="submit" VALUE="Advance to next turn" NAME="TurnButton">
|
||
|
</FORM>
|
||
|
END
|
||
|
}
|
||
|
|
||
|
my($mStr1) = '';
|
||
|
if($HhideMoneyMode != 0) {
|
||
|
$mStr1 = "<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Funds${H_tagTH}</NOBR></TH>";
|
||
|
}
|
||
|
|
||
|
# フォーム
|
||
|
out(<<END);
|
||
|
${HtagHeader_}Turn $HislandTurn${H_tagHeader}
|
||
|
<div><small>Next turn: $nextTurnDate (UTC) ($hoursUntilNextTurn hours $minutesUntilNextTurn mins)</small></div>
|
||
|
<div><small>Turns are automated to occur once every $turnLength hours.</small></div>
|
||
|
|
||
|
<HR>
|
||
|
${HtagHeader_}Go to your island${H_tagHeader}
|
||
|
<FORM action="$HthisFile" method="POST">
|
||
|
What is the name of your island?<BR>
|
||
|
<SELECT NAME="ISLANDID">
|
||
|
$HislandList
|
||
|
</SELECT><BR>
|
||
|
|
||
|
Password please!!<BR>
|
||
|
<INPUT TYPE="password" NAME="PASSWORD" VALUE="$HdefaultPassword" SIZE=32 MAXLENGTH=32><BR>
|
||
|
<INPUT TYPE="submit" VALUE="To development" NAME="OwnerButton"><BR>
|
||
|
</FORM>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
${HtagHeader_}Island status${H_tagHeader}
|
||
|
<P>
|
||
|
Click on the name of an island to take a <B>tour</B>.
|
||
|
</P>
|
||
|
<div class="tableContainer"><TABLE BORDER>
|
||
|
<TR>
|
||
|
<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Rank${H_tagTH}</NOBR></TH>
|
||
|
<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Island${H_tagTH}</NOBR></TH>
|
||
|
<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Population${H_tagTH}</NOBR></TH>
|
||
|
<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Area${H_tagTH}</NOBR></TH>
|
||
|
$mStr1
|
||
|
<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Food${H_tagTH}</NOBR></TH>
|
||
|
<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Farms${H_tagTH}</NOBR></TH>
|
||
|
<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Factories${H_tagTH}</NOBR></TH>
|
||
|
<TH $HbgTitleCell align=center nowrap=nowrap><NOBR>${HtagTH_}Mines${H_tagTH}</NOBR></TH>
|
||
|
</TR>
|
||
|
END
|
||
|
|
||
|
my($island, $j, $farm, $factory, $mountain, $name, $id, $prize, $ii);
|
||
|
for($ii = 0; $ii < $HislandNumber; $ii++) {
|
||
|
$j = $ii + 1;
|
||
|
$island = $Hislands[$ii];
|
||
|
|
||
|
$id = $island->{'id'};
|
||
|
$farm = $island->{'farm'};
|
||
|
$factory = $island->{'factory'};
|
||
|
$mountain = $island->{'mountain'};
|
||
|
$farm = ($farm == 0) ? "None owned" : "${farm}0$HunitPop";
|
||
|
$factory = ($factory == 0) ? "None owned" : "${factory}0$HunitPop";
|
||
|
$mountain = ($mountain == 0) ? "None owned" : "${mountain}0$HunitPop";
|
||
|
if($island->{'absent'} == 0) {
|
||
|
$name = "${HtagName_}$island->{'name'} Island${H_tagName}";
|
||
|
} else {
|
||
|
$name = "${HtagName2_}$island->{'name'} Island ($island->{'absent'})${H_tagName2}";
|
||
|
}
|
||
|
|
||
|
$prize = $island->{'prize'};
|
||
|
my($flags, $monsters, $turns);
|
||
|
$prize =~ /([0-9]*),([0-9]*),(.*)/;
|
||
|
$flags = $1;
|
||
|
$monsters= $2;
|
||
|
$turns = $3;
|
||
|
$prize = '';
|
||
|
|
||
|
# ターン杯の表示
|
||
|
while($turns =~ s/([0-9]*),//) {
|
||
|
$prize .= "<IMG SRC=\"prize0.gif\" ALT=\"$1${Hprize[0]}\" title=\"$1${Hprize[0]}\" WIDTH=16 HEIGHT=16> ";
|
||
|
}
|
||
|
|
||
|
# 名前に賞の文字を追加
|
||
|
my($f) = 1;
|
||
|
my($i);
|
||
|
for($i = 1; $i < 10; $i++) {
|
||
|
if($flags & $f) {
|
||
|
$prize .= "<IMG SRC=\"prize${i}.gif\" ALT=\"${Hprize[$i]}\" title=\"${Hprize[$i]}\" WIDTH=16 HEIGHT=16> ";
|
||
|
}
|
||
|
$f *= 2;
|
||
|
}
|
||
|
|
||
|
# 倒した怪獣リスト
|
||
|
$f = 1;
|
||
|
my($max) = -1;
|
||
|
my($mNameList) = '';
|
||
|
for($i = 0; $i < $HmonsterNumber; $i++) {
|
||
|
if($monsters & $f) {
|
||
|
$mNameList .= "[$HmonsterName[$i]] ";
|
||
|
$max = $i;
|
||
|
}
|
||
|
$f *= 2;
|
||
|
}
|
||
|
if($max != -1) {
|
||
|
$prize .= "<IMG SRC=\"${HmonsterImage[$max]}\" ALT=\"$mNameList\" title=\"$mNameList\" WIDTH=16 HEIGHT=16> ";
|
||
|
}
|
||
|
|
||
|
|
||
|
my($mStr1) = '';
|
||
|
if($HhideMoneyMode == 1) {
|
||
|
$mStr1 = "<TD $HbgInfoCell align=right>$island->{'money'}$HunitMoney</TD>";
|
||
|
} elsif($HhideMoneyMode == 2) {
|
||
|
my($mTmp) = aboutMoney($island->{'money'});
|
||
|
$mStr1 = "<TD $HbgInfoCell align=right>$mTmp</TD>";
|
||
|
}
|
||
|
|
||
|
out(<<END);
|
||
|
<TR>
|
||
|
<TD $HbgNumberCell ROWSPAN=2 align=center>${HtagNumber_}$j${H_tagNumber}</TD>
|
||
|
<TD $HbgNameCell ROWSPAN=2 align=left>
|
||
|
<A STYlE=\"text-decoration:none\" HREF="${HthisFile}?Sight=${id}">$name</A><BR>
|
||
|
$prize</TD>
|
||
|
<TD $HbgInfoCell align=right>$island->{'pop'}$HunitPop</TD>
|
||
|
<TD $HbgInfoCell align=right>$island->{'area'}$HunitArea</TD>
|
||
|
$mStr1
|
||
|
<TD $HbgInfoCell align=right>$island->{'food'}$HunitFood</TD>
|
||
|
<TD $HbgInfoCell align=right>$farm</TD>
|
||
|
<TD $HbgInfoCell align=right>$factory</TD>
|
||
|
<TD $HbgInfoCell align=right>$mountain</TD>
|
||
|
</TR>
|
||
|
<TR>
|
||
|
<TD $HbgCommentCell COLSPAN=7 align=left>${HtagTH_}Comment: ${H_tagTH}$island->{'comment'}</TD>
|
||
|
</TR>
|
||
|
END
|
||
|
}
|
||
|
|
||
|
out(<<END);
|
||
|
</TABLE></div>
|
||
|
|
||
|
<HR>
|
||
|
${HtagHeader_}Discover a new island${H_tagHeader}
|
||
|
END
|
||
|
|
||
|
if($HislandNumber < $HmaxIsland) {
|
||
|
out(<<END);
|
||
|
<FORM action="$HthisFile" method="POST">
|
||
|
What name do you plan to give your island?<BR>
|
||
|
<INPUT TYPE="text" NAME="ISLANDNAME" SIZE=32 MAXLENGTH=32> Island<BR>
|
||
|
And the password?<BR>
|
||
|
<INPUT TYPE="password" NAME="PASSWORD" SIZE=32 MAXLENGTH=32><BR>
|
||
|
Just to be sure, enter the password again<BR>
|
||
|
<INPUT TYPE="password" NAME="PASSWORD2" SIZE=32 MAXLENGTH=32><BR>
|
||
|
|
||
|
<INPUT TYPE="submit" VALUE="Discover" NAME="NewIslandButton">
|
||
|
</FORM>
|
||
|
END
|
||
|
} else {
|
||
|
out(<<END);
|
||
|
The maximum number of islands has been reached... a new island cannot be registered at this time.
|
||
|
END
|
||
|
}
|
||
|
|
||
|
out(<<END);
|
||
|
<HR>
|
||
|
${HtagHeader_}Change island name and password${H_tagHeader}
|
||
|
<P>
|
||
|
(Note) A name change costs $HcostChangeName${HunitMoney}.
|
||
|
</P>
|
||
|
<FORM action="$HthisFile" method="POST">
|
||
|
Which island?<BR>
|
||
|
<SELECT NAME="ISLANDID">
|
||
|
$HislandList
|
||
|
</SELECT>
|
||
|
<BR>
|
||
|
What would you like to change the name to? (only needed if you are changing the name)<BR>
|
||
|
<INPUT TYPE="text" NAME="ISLANDNAME" SIZE=32 MAXLENGTH=32> Island<BR>
|
||
|
And the password? (required)<BR>
|
||
|
<INPUT TYPE="password" NAME="OLDPASS" SIZE=32 MAXLENGTH=32><BR>
|
||
|
What is the new password? (only needed if you are changing the password)<BR>
|
||
|
<INPUT TYPE="password" NAME="PASSWORD" SIZE=32 MAXLENGTH=32><BR>
|
||
|
Just to be sure, enter the password again (only needed if you are changing the password)<BR>
|
||
|
<INPUT TYPE="password" NAME="PASSWORD2" SIZE=32 MAXLENGTH=32><BR>
|
||
|
|
||
|
<INPUT TYPE="submit" VALUE="Change" NAME="ChangeInfoButton">
|
||
|
</FORM>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
${HtagHeader_}Recent events${H_tagHeader}
|
||
|
END
|
||
|
logPrintTop();
|
||
|
out(<<END);
|
||
|
${HtagHeader_}Discovery history${H_tagHeader}
|
||
|
END
|
||
|
historyPrint();
|
||
|
}
|
||
|
|
||
|
# トップページ用ログ表示
|
||
|
sub logPrintTop {
|
||
|
my($i);
|
||
|
for($i = 0; $i < $HtopLogTurn; $i++) {
|
||
|
logFilePrint($i, 0, 0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# 記録ファイル表示
|
||
|
sub historyPrint {
|
||
|
open(HIN, "${HdirName}/hakojima.his");
|
||
|
my(@line, $l);
|
||
|
while($l = <HIN>) {
|
||
|
chomp($l);
|
||
|
push(@line, $l);
|
||
|
}
|
||
|
@line = reverse(@line);
|
||
|
|
||
|
foreach $l (@line) {
|
||
|
$l =~ /^([0-9]*),(.*)$/;
|
||
|
## out("<NOBR>${HtagNumber_}Turn ${1}${H_tagNumber}: ${2}</NOBR><BR>\n");
|
||
|
out("${HtagNumber_}Turn ${1}${H_tagNumber}: ${2}<BR>\n"); ## mod
|
||
|
}
|
||
|
close(HIN);
|
||
|
}
|
||
|
|
||
|
1;
|