hakoniwa2/hako-top.cgi

267 lines
7.9 KiB
Plaintext
Raw Permalink Normal View History

new file: css/main.css new file: hako-main.cgi new file: hako-map.cgi new file: hako-mente.cgi new file: hako-readme.txt new file: hako-top.cgi new file: hako-turn.cgi new file: images/black.gif new file: images/f02.gif new file: images/hakoniwa.gif new file: images/land0.gif new file: images/land1.gif new file: images/land10.gif new file: images/land11.gif new file: images/land12.gif new file: images/land13.gif new file: images/land14.gif new file: images/land15.gif new file: images/land16.gif new file: images/land2.gif new file: images/land3.gif new file: images/land4.gif new file: images/land5.gif new file: images/land6.gif new file: images/land7.gif new file: images/land8.gif new file: images/land9.gif new file: images/monster0.gif new file: images/monster1.gif new file: images/monster2.gif new file: images/monster3.gif new file: images/monster4.gif new file: images/monster5.gif new file: images/monster6.gif new file: images/monster7.gif new file: images/monster8.gif new file: images/monument0.gif new file: images/monument1.gif new file: images/monument2.gif new file: images/prize0.gif new file: images/prize1.gif new file: images/prize10.gif new file: images/prize11.gif new file: images/prize2.gif new file: images/prize3.gif new file: images/prize4.gif new file: images/prize5.gif new file: images/prize6.gif new file: images/prize7.gif new file: images/prize8.gif new file: images/prize9.gif new file: images/space.gif new file: images/space0.gif new file: images/space1.gif new file: images/space10.gif new file: images/space11.gif new file: images/space2.gif new file: images/space3.gif new file: images/space4.gif new file: images/space5.gif new file: images/space6.gif new file: images/space7.gif new file: images/space8.gif new file: images/space9.gif new file: images/spacep.gif new file: images/xbar.gif new file: jcode.pl new file: manual/advanced.html new file: manual/beginner.html new file: manual/intermediate.html new file: manual/man-discovered.png new file: manual/man-goto.png new file: manual/man-listed.png new file: manual/man-name.png new file: manual/man-new.png new file: manual/man-owner.png new file: manual/man-ownerm.png new file: manual/man-register.png new file: manual/man-tourist.png
2024-12-03 05:32:59 +00:00
#----------------------------------------------------------------------
# 箱庭諸島 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;