<?php include($phpbb_root_path . 'rpg/function_rpg.'.$phpEx); if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
	exit;
} $returnurl = '<br /><br /><a href="rpg.php?action=race">返回上一頁</a>'; $template->set_filenames(array(
	'menu' => 'rpg_header.tpl',
	'body' => 'rpg_race.tpl')
); // 取得個人資料
$profiledata = get_userdata(intval($userdata['uid']));
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$act = trim($act);
/*if (!isset($act) or $act=="") {
  $act="horse";
}*/ $postuname = $profiledata['uname'];
$rpg_race_result = "";
if ($HTTP_POST_VARS['act']=="horse")
{
	$mony=trim(addslashes($mon));
	$usermoney =  $profiledata['user_money'];
	if ($mony<100 || $mony>10000)
	{
		$rpg_race_result .="對不起，您的下注金額不在規定的範圍內!!";
	}
	else if ($usermoney<$mony)
	{
		$rpg_race_result .="對不起，您的現金不夠!!";
	}
	else {
		$sql= "UPDATE xoops_users SET
		user_money=user_money-".$mony." WHERE uid='".$profiledata[uid]."'";
	if( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, "無法更新會員的現金!!", "", __LINE__, __FILE__, $sql);
	}
	$horse=Array(1=>"龍在江湖",2=>"不稀",3=>"聾沒耳",4=>"董老大",5=>"不來耳",6=>"泥河魯",7=>"小犬蠢一狼",8=>"蠻得辣");
	?> <script>
function Horse_timelinePlay(tmLnName, myID) {
if (document.Horse_Time == null) Horse_initTimelines();
tmLn = document.Horse_Time[tmLnName];
if(myID == null) { myID = ++tmLn.ID; firstTime=true;}
setTimeout('Horse_timelinePlay("'+tmLnName+'",'+myID+')',tmLn.delay);
fNew = ++tmLn.curFrame;
for (i=0; i<tmLn.length; i++) {
sprite = tmLn[i];
if (sprite.obj) {
numKeyFr = sprite.keyFrames.length; firstKeyFr = sprite.keyFrames[0];
if (fNew >= firstKeyFr && fNew <= sprite.keyFrames[numKeyFr-1]) {
keyFrm=1;
for (j=0; j<sprite.values.length; j++) {
props = sprite.values[j];
if (numKeyFr != props.length) {
if (props.prop2 == null) sprite.obj[props.prop] = props[fNew-firstKeyFr];
else sprite.obj[props.prop2][props.prop] = props[fNew-firstKeyFr];
}else{
while (keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm]) keyFrm++;
if (firstTime || fNew==sprite.keyFrames[keyFrm-1]) {
if (props.prop2 == null) sprite.obj[props.prop] = props[keyFrm-1];
else sprite.obj[props.prop2][props.prop] = props[keyFrm-1];
}}}}
}}
}
function Horse_initTimelines() {
document.Horse_Time = new Array();
document.Horse_Time[0] = new Array();
document.Horse_Time["horse"] = document.Horse_Time[0];
<?
for ($intj=0;$intj<8;$intj++)
{
for ($i=0;$i<30;$i++)
{
$intnum=pack(c,rand(0,10)+48);
$intnum1=$intnum1+$intnum*3;
if (!isset($tol)) $tol=$intnum1;
else $tol=$tol.",".$intnum1;
}
if($intnum1 > $fff){$fff=$intnum1;$no=$intj+1;}
$intj1=$intj+1;?>
document.Horse_Time[0][<?echo $intj;?>]=new String("sprite");
document.Horse_Time[0][<?echo $intj;?>].obj=document.all ? document.all["h<?echo $intj1;?>"] : null;
document.Horse_Time[0][<?echo $intj;?>].keyFrames=new Array(1,30);
document.Horse_Time[0][<?echo $intj;?>].values=new Array(2);
document.Horse_Time[0][<?echo $intj;?>].values[0]=new Array(<?echo $tol;?>);
document.Horse_Time[0][<?echo $intj;?>].values[0].prop="left";
document.Horse_Time[0][<?echo $intj;?>].values[1]=new Array();
document.Horse_Time[0][<?echo $intj;?>].values[0].prop2="style";
<?
$tol=0;
$intnum1=0;
}
$fff=$fff-15;
if($no == 1) {$horsename=$horse[1];}
elseif($no == 2) {$horsename=$horse[2];}
elseif($no == 3) {$horsename=$horse[3];}
elseif($no == 4) {$horsename=$horse[4];}
elseif($no == 5) {$horsename=$horse[5];}
elseif($no == 6) {$horsename=$horse[6];}
elseif($no == 7) {$horsename=$horse[7];}
elseif($no == 8) {$horsename=$horse[8];}
if($yourchoose == $no){
	$jessie = $mony*8;
	$sql= "UPDATE xoops_users SET
		user_money=user_money+".$jessie." WHERE uid='".$profiledata[uid]."'";
	if( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, "無法更新會員的現金!!", "", __LINE__, __FILE__, $sql);
	}

$message="<br />恭喜， ".$profiledata[uname]." 您贏了!!<br />獲得彩金 ".$jessie." 元!!";
}else{
$message="<br />很遺憾， ".$profiledata[uname]." 您輸了....";
}
/*
此處可以加錢的設定,寫到文件
*/
?>
document.Horse_Time[0][8]=new String("sprite");
document.Horse_Time[0][9]=new String("sprite");
document.Horse_Time[0][9].obj = document.all ? document.all["sysMsg"] : null;
document.Horse_Time[0][9].keyFrames=new Array(1,30);
document.Horse_Time[0][9].values=new Array();
document.Horse_Time[0][9].values[0]=new Array();
document.Horse_Time[0][9].values[0].prop="left";
document.Horse_Time[0][9].values[1]=new Array();
document.Horse_Time[0][9].values[0]=new Array("hidden","inherit");
document.Horse_Time[0][9].values[0].prop="visibility";
document.Horse_Time[0][9].values[0].prop2="style";
for(i=0;i<document.Horse_Time.length;i++){document.Horse_Time[i].curFrame=0;document.Horse_Time[i].delay=200;}
}
</script> <body onLoad="Horse_timelinePlay('horse')">
<div id=h1 style=position:absolute;top:240px><img src=images/horse/h1.gif></div>
<div id=h2 style=position:absolute;top:280px><img src=images/horse/h2.gif></div>
<div id=h3 style=position:absolute;top:320px><img src=images/horse/h3.gif></div>
<div id=h4 style=position:absolute;top:360px><img src=images/horse/h4.gif></div>
<div id=h5 style=position:absolute;top:400px><img src=images/horse/h5.gif></div>
<div id=h6 style=position:absolute;top:440px><img src=images/horse/h6.gif></div>
<div id=h7 style=position:absolute;top:480px><img src=images/horse/h7.gif></div>
<div id=h8 style=position:absolute;top:520px><img src=images/horse/h8.gif></div>
<div id=sysMsg style="position:absolute;width:250;height:50%;left:60%;visibility: hidden">
<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor=FF0000>
<tr bgcolor=FFFFFF>
<td colspan=2 align=center bgcolor=FF0000><font color=FFFFFF>比賽結果</font><?echo $message;?></td>
</tr>
<tr>
<td width="40%" align=center>第 1 名： (<?echo $no;?>) <?echo $horsename;?></td>
</tr>
</table>
</div>
<br />
<table width="100%" height="20" cellpadding="2" cellspacing="0" border="0">
<tr>
<td><br />您選擇: <b><font color="red"><?echo $yourchoose;?></font> <?echo $horse[$yourchoose];?></b></td>
</tr>
</table>
<table width=100% cellpadding=5 cellspacing=1 bgcolor=F0F0F0 border=0>
<tr bgcolor=84CF1D align=right>
<td height=39 width=<?echo $fff;?></td><td class="gen"><font color=FFFFFF><?echo $horse[1];?></font></td></tr>
<tr bgcolor=84CF1D align=right>
<td height=39></td><td class="gen"><font color=FFFFFF><?echo $horse[2];?></font></td></tr>
<tr bgcolor=84CF1D align=right>
<td height=39></td><td class="gen"><font color=FFFFFF><?echo $horse[3];?></font></td></tr>
<tr bgcolor=84CF1D align=right>
<td height=39></td><td class="gen"><font color=FFFFFF><?echo $horse[4];?></font></td></tr>
<tr bgcolor=84CF1D align=right>
<td height=39></td><td class="gen"><font color=FFFFFF><?echo $horse[5];?></font></td></tr>
<tr bgcolor=84CF1D align=right>
<td height=39></td><td class="gen"><font color=FFFFFF><?echo $horse[6];?></font></td></tr>
<tr bgcolor=84CF1D align=right>
<td height=39></td><td class="gen"><font color=FFFFFF><?echo $horse[7];?></font></td></tr>
<tr bgcolor=84CF1D align=right>
<td height=39></td><td class="gen"><font color=FFFFFF><?echo $horse[8];?></font></td></tr>
</table>
<br />
<?
	}
}

// 產生資料頁面
$page_title = "水怪大陸 RPG 首頁";

$template->assign_vars(array(
	'USERNAME' => $profiledata['uname'],
	'AVATAR_IMG' => GetAvatar($profiledata),
	'RPG_MONEY' => number_format($profiledata['user_money']),
	'RACE_RESULT' => $rpg_race_result,
	'L_NOWMENU' => '水怪賽馬遊戲') );

if ( $act == 'horse' )
{
        $template->assign_block_vars('race_result', array());
}

$template->pparse('menu');
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>