its cool game but anyone having it in html version
[wap] Rock-paper-scissors For Lavalair
Collapse
X
-
<div class='quotetop'>QUOTE (johnny @ Jan 10 2009, 10:03 AM) <{POST_SNAPBACK}></div>its cool game but anyone having it in html version[/b]
it takes MAX 10 minutes to convert it...
if you got smoke brake inbetween...It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt.
ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ â“â“¡â“” â“ⓑⓛⓔ ⓣⓞ â“—â“”â“â“¡ !
ιη тнєσÑу, тнє ÏÑα¢тι¢є ιѕ α Ñєѕυℓт σƒ тнє тнєσÑу, вυт ιη ÏÑα¢тι¢є ιѕ тнє σÏÏσѕιтє.
Comment
-
i added this for xhtml but in this shoot option dont work in xhtml so need a bit help n hoow must i add game in fun menu</br><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?php
include("config.php");
include("core.php");
connectdb();
$action=$_GET["action"];
$id=$_GET["id"];
$sid = $_GET["sid"];
$rid=$_GET["rid"];
$rpw=$_GET["rpw"];
$brws = explode(" ",$HTTP_USER_AGENT);
$ubr = $brws[0];
$uip = getip();
$who = $_GET["who"];
$uid = getuid_sid($sid);
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo "<head>\n";
echo "<title>FriendsZone</title>";
echo "<meta http-equiv=\"Cache-Control\" content=\"max-age=0\">\n";
$thid = mysql_fetch_array(mysql_query("SELECT thid FROM ibwf_mypage WHERE uid='".$uid."'"));
if($thid[0]==""||$thid[0]==0)$thid[0]=1;
$thinfo = mysql_fetch_array(mysql_query("SELECT bgc, txc, lnk, hdc, hbg FROM ibwf_themes WHERE id='".$thid[0]."'"));
echo "<style type=\"text/css\">";
echo "body {background-color:#$thinfo[0]; color:#$thinfo[1]}";
echo "h3 {background-color:#$thinfo[4]; color:#$thinfo[3]}";
echo "a:link {color:#$thinfo[2]}";
echo "a:visited {color:#$thinfo[2]}";
echo "</style>";
echo "</head>\n";
echo "<body>\n";
$bcon = connectdb();
if (!$bcon)
{
echo "<img src=\"../images/exit.gif\" alt=\"*\"/>
";
echo "ERROR! cannot connect to database
";
echo "This error happens usually when backing up the database, please be patient, The site will be up any minute
";
echo "you can temperoray be in this site <a href=\"http://chatheaven.wen.ru\">$site_name</a> while $site_name is offline
";
echo "THANK YOU VERY MUCH";
echo "</p>";
echo "</html>";
echo "</body>";
exit();
}
$brws = explode(" ",$_SERVER[HTTP_USER_AGENT] );
$ubr = $brws[0];
$uip = getip();
$action = $_GET["action"];
$sid = $_GET["sid"];
$page = $_GET["page"];
$who = $_GET["who"];
$uid = getuid_sid($sid);
connectdb();
//clearnc();
$action=$_GET["action"];
$id=$_GET["id"];
$sid = $_GET["sid"];
$botid = "eeb070e74e366473";
$input = $_POST["input"];
$custid=$_POST["custid"];
$hostname = "www.pandorabots.com";
$hostpath = "/pandora/talk-xml";
if(islogged($sid)==false)
{
echo "<p align=\"center\">";
echo "You are not logged in
";
echo "Or Your session has been expired
";
echo "<a href=\"index.php\">Login</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit();
}
$uid = getuid_sid($sid);
if(isbanned($uid))
{
echo "<p align=\"center\">";
echo "<img src=\"images/notok.gif\" alt=\"x\"/>
";
echo "You are Banned
";
$banto = mysql_fetch_array(mysql_query("SELECT timeto FROM ibwf_penalties WHERE uid='".$uid."' AND penalty='1'"));
$remain = $banto[0]- time();
$rmsg = gettimemsg($remain);
echo "Time to finish your penalty: $rmsg
";
//echo "<a href=\"index.php\">Login</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit();
}
function canplay_rps($uid)
{
$sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
if($sql[0]>=15)
{
return true;
}else{
return false;
}
}
function gup($uid)
{
$sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
return $sql[0];
}
function get_winner($x,$y)
{
if($x==1&&$y==2)
{
$win = 2;
}else if($x==1&&$y==3)
{
$win = 1;
}else if($x==2&&$y==1)
{
$win = 1;
}else if($x==3&&$y==1)
{
$win = 2;
}else if($x==2&&$y==3)
{
$win = 2;
}else if($x==3&&$y==2)
{
$win = 1;
}else{
$win = 0;
}
return $win;
}
function get_left($x)
{
switch($x)
{
case 1:
$ret = 'rock_l';
break;
case 2:
$ret = 'paper_l';
break;
case 3:
$ret = 'scissor_l';
break;
}
return $ret;
}
function get_right($x)
{
switch($x)
{
case 1:
$ret = 'rock_r';
break;
case 2:
$ret = 'paper_r';
break;
case 3:
$ret = 'scissor_r';
break;
}
return $ret;
}
if(!$bcon)
{
echo '<card id="main" title="Database Error">';
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'Database Connection Error, please try again later!';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid. 9;">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid. 9;">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
echo '</html>';
exit();
}
if(!islogged($sid))
{
echo '<card id="main" title="Login Error">';
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'You are not logged in or your session has expired!';
echo '
';
echo 'Login';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=main&sid='.$sid. 9;">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
echo '</html>';
exit();
}
if(isbanned($uid))
{
echo '<card id="main" title="Login Error">';
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo '';
echo 'You are Banned
';
echo '
';
$sql = "SELECT timeto, pnreas, exid
FROM ibwf_parusa
WHERE uid='".$uid."'
AND penalty='1' OR uid='".$uid."'
AND penalty='2'
";
$banto = mysql_fetch_array(mysql_query($sql));
$banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
$remain = $banto[0] - time();
$rmsg = gettimemsg($remain);
echo 'Time Left: '.$rmsg.'';
echo '
';
$nick = getnick_uid($banto[2]);
echo 'By: '.$nick.'';
echo '
';
echo 'Reason: '.$banto[1].'';
echo '';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=main&sid='.$sid. 9;">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
echo '</html>';
exit();
}
if(!canplay_rps($uid))
{
echo '<card id="main" title="Error">';
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'You must have atleast 15 plusses to play Rock-Paper-Scissors!';
echo '
';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid. 9;">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid. 9;">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
echo '</html>';
exit();
}
if($action=='play')
{
echo '<card id="main" title="Rock-Paper-Scissors">';
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo 'Call: ';
echo '<select name="op">';
echo '<option value="1">Rock</option>';
echo '<option value="2">Paper</option>';
echo '<option value="3">Scissors</option>';
echo '</select>';
echo '
';
echo '<anchor>[Shoot]<go href="rps.php?action=go&sid='.$sid.'" method="post">';
echo '<postfield name="op" value="$(op)"/>';
echo '<postfield name="init" value="1"/>';
echo '</go></anchor>';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid. 9;">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid. 9;">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
}else if($action=='go')
{
if(isset($_POST['init'])&&$_POST['init']==1)
{
$op = $_POST['op'];
$ac = rand(1,3);
$res = get_winner($op,$ac);
$_SESSION['turn'] = isset($_SESSION['turn']) ? $_SESSION['turn'] : 1;
$turn = $_SESSION['turn'];
$imgl = get_left($op);
$imgr = get_right($ac);
$_SESSION['w'] = isset($_SESSION['w']) ? $_SESSION['w'] : 0;
$_SESSION['l'] = isset($_SESSION['l']) ? $_SESSION['l'] : 0;
$_SESSION['d'] = isset($_SESSION['d']) ? $_SESSION['d'] : 0;
echo '<card id="main" title="Rock-Paper-Scissors">';
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo '[img]images/'.$imgl.'.png[/img][img]images/vs.png[/img][img]images/'.$imgr.'.png[/img]';
echo '
';
if($res==1)
{
$_SESSION['w']++;
echo 'You Won!';
echo '
';
}else if($res==2)
{
$_SESSION['l']++;
echo 'You Lost!';
echo '
';
}else{
$_SESSION['d']++;
$_SESSION['turn']--;
echo 'Draw!';
echo '
';
}
echo '
';
if($_SESSION['turn']<3)
{
echo 'Call: ';
echo '<select name="op">';
echo '<option value="1">Rock</option>';
echo '<option value="2">Paper</option>';
echo '<option value="3">Scissors</option>';
echo '</select>';
echo '
';
echo '<anchor>[Shoot]<a href="rps.php?action=go&sid='.$sid.'" method="post">';
echo '<postfield name="op" value="$(op)"/>';
echo '<postfield name="init" value="1"/>';
echo '</go></anchor>';
$_SESSION['turn']++;
}else{
echo ''.$_SESSION['w'].':'.$_SESSION['l'].'';
echo '
';
echo '
';
$xup = gup($uid);
if($_SESSION['w']>$_SESSION['l'])
{
$plus = $xup + 15;
$add = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
if($add)
{
echo 'You Won: $15';
echo '
';
echo 'You Plusses: '.$plus.'';
}
}
if($_SESSION['w']<$_SESSION['l']){
$plus = $xup - 15;
if($plus<0)
{
$plus = 0;
}
$min = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
if($min)
{
echo 'You Lost: $15';
echo '
';
echo 'You Plusses: '.$plus.'';
}
}
unset($_SESSION['turn']);
unset($_SESSION['w']);
unset($_SESSION['l']);
unset($_SESSION['d']);
echo '
';
echo '
';
echo 'Play Again';
echo '
';
}
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid. 9;">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid. 9;">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
}else{
echo '<card id="main" title="Rock-Paper-Scissors">';
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo 'Do not try to cheat here!!!';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid. 9;">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid. 9;">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
}
}else{
echo '<card id="main" title="Rock-Paper-Scissors">';
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo 'Think you can outmatch [bot name] at Rock Paper Scissors? Well wage 15 plusses with a payout to match to find out. The best 2 out of 3 wins!!';
echo '
';
echo 'If you think you got what it takes, click below:';
echo '
';
echo 'Play Now';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid. 9;">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid. 9;">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
}
echo '</html>';
?></div>
Comment
-
For the ppl asking for xhtml version. u need to add ur own stylesheet though
PHP Code:<?php
/**
* @Copyright wizard <mc_jayrulez@yahoo.com.au>
* @File: rps.php
* @param: $sid
*/
session_start();
header('Content-type: text/html');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml">';
function head($title='Rock-Paper-Scissors')
{
echo '
<head>
<title>'.$title.'</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="style.css" type="text/css"/>
</head>
<body>
';
}
include("config.php");
include("core.php");
$bcon = connectdb();
$sid = $_GET['sid'];
$uid = getuid_sid($sid);
$action = $_GET['action'];
function canplay_rps($uid)
{
$sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
if($sql[0]>=15)
{
return true;
}else{
return false;
}
}
function gup($uid)
{
$sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
return $sql[0];
}
function get_winner($x,$y)
{
if($x==1&&$y==2)
{
$win = 2;
}else if($x==1&&$y==3)
{
$win = 1;
}else if($x==2&&$y==1)
{
$win = 1;
}else if($x==3&&$y==1)
{
$win = 2;
}else if($x==2&&$y==3)
{
$win = 2;
}else if($x==3&&$y==2)
{
$win = 1;
}else{
$win = 0;
}
return $win;
}
function get_left($x)
{
switch($x)
{
case 1:
$ret = 'rock_l';
break;
case 2:
$ret = 'paper_l';
break;
case 3:
$ret = 'scissor_l';
break;
}
return $ret;
}
function get_right($x)
{
switch($x)
{
case 1:
$ret = 'rock_r';
break;
case 2:
$ret = 'paper_r';
break;
case 3:
$ret = 'scissor_r';
break;
}
return $ret;
}
if(!$bcon)
{
head('Database Error');
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'Database Connection Error, please try again later!';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</body>';
echo '</html>';
exit();
}
if(!islogged($sid))
{
head('Login Error');
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'You are not logged in or your session has expired!';
echo '
';
echo 'Login';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</body>';
echo '</html>';
exit();
}
if(isbanned($uid))
{
head('Login Error');
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo '';
echo 'You are Banned
';
echo '
';
$sql = "SELECT timeto, pnreas, exid
FROM ibwf_parusa
WHERE uid='".$uid."'
AND penalty='1' OR uid='".$uid."'
AND penalty='2'
";
$banto = mysql_fetch_array(mysql_query($sql));
$banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
$remain = $banto[0] - time();
$rmsg = gettimemsg($remain);
echo 'Time Left: '.$rmsg.'';
echo '
';
$nick = getnick_uid($banto[2]);
echo 'By: '.$nick.'';
echo '
';
echo 'Reason: '.$banto[1].'';
echo '';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</body>';
echo '</html>';
exit();
}
if(!canplay_rps($uid))
{
head('Error');
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'You must have atleast 15 plusses to play Rock-Paper-Scissors!';
echo '
';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</body>';
echo '</html>';
exit();
}
if($action=='play')
{
head();
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo '<form action="rps.php?action=go&sid='.$sid.'" method="post">';
echo 'Call: ';
echo '<select name="op">';
echo '<option value="1">Rock</option>';
echo '<option value="2">Paper</option>';
echo '<option value="3">Scissors</option>';
echo '</select>';
echo '
';
echo '<input type="hidden" name="init" value="1"/>';
echo '<input type="submit" value="Shoot"/>';
echo '</form>';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</body>';
}else if($action=='go')
{
if(isset($_POST['init'])&&$_POST['init']==1)
{
$op = $_POST['op'];
$ac = rand(1,3);
$res = get_winner($op,$ac);
$_SESSION['turn'] = isset($_SESSION['turn']) ? $_SESSION['turn'] : 1;
$turn = $_SESSION['turn'];
$imgl = get_left($op);
$imgr = get_right($ac);
$_SESSION['w'] = isset($_SESSION['w']) ? $_SESSION['w'] : 0;
$_SESSION['l'] = isset($_SESSION['l']) ? $_SESSION['l'] : 0;
$_SESSION['d'] = isset($_SESSION['d']) ? $_SESSION['d'] : 0;
head();
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo '[img]images/'.$imgl.'.png[/img][img]images/vs.png[/img][img]images/'.$imgr.'.png[/img]';
echo '
';
if($res==1)
{
$_SESSION['w']++;
echo 'You Won!';
echo '
';
}else if($res==2)
{
$_SESSION['l']++;
echo 'You Lost!';
echo '
';
}else{
$_SESSION['d']++;
$_SESSION['turn']--;
echo 'Draw!';
echo '
';
}
echo '
';
if($_SESSION['turn']<3)
{
echo '<form action="rps.php?action=go&sid='.$sid.'" method="post">';
echo 'Call: ';
echo '<select name="op">';
echo '<option value="1">Rock</option>';
echo '<option value="2">Paper</option>';
echo '<option value="3">Scissors</option>';
echo '</select>';
echo '
';
echo '<input type="hidden" name="init" value="1"/>';
echo '<input type="submit" value="Shoot"/>';
echo '</form>';
$_SESSION['turn']++;
}else{
echo ''.$_SESSION['w'].':'.$_SESSION['l'].'';
echo '
';
echo '
';
$xup = gup($uid);
if($_SESSION['w']>$_SESSION['l'])
{
$plus = $xup + 15;
$add = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
if($add)
{
echo 'You Won: $15';
echo '
';
echo 'You Plusses: '.$plus.'';
}
}
if($_SESSION['w']<$_SESSION['l']){
$plus = $xup - 15;
if($plus<0)
{
$plus = 0;
}
$min = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
if($min)
{
echo 'You Lost: $15';
echo '
';
echo 'You Plusses: '.$plus.'';
}
}
unset($_SESSION['turn']);
unset($_SESSION['w']);
unset($_SESSION['l']);
unset($_SESSION['d']);
echo '
';
echo '
';
echo 'Play Again';
echo '
';
}
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</body>';
}else{
head();
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo 'Do not try to cheat here!!!';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</body>';
}
}else{
head();
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo 'Think you can outmatch [bot name] at Rock Paper Scissors? Well wage 15 plusses with a payout to match to find out. The best 2 out of 3 wins!!';
echo '
';
echo 'If you think you got what it takes, click below:';
echo '
';
echo 'Play Now';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</body>';
}
echo '</html>';
?>
Comment
-
It can be coded in short by applying some maths in it like
Code:<?php /***************** Rock , Paper , Scissors Game By DNS [url]http://forum.wapfuns.com[/url] ******************/ $choice = $_POST["choice"]; if($choice!="") { $select = array ("Rock" , "Paper" , "Scissors"); $computer = rand(0,2); echo "You chose $select[$choice] . "; echo "Computer chose $select[$computer] . "; $result = $choice - $computer; if($result == 1 || $result == -2) { echo "You Win :)"; } else if($result==0) { echo "Draw !"; } else { echo "You lose :("; } exit(); } ?> <html> <head><title> Rock Paper Scissors Game By DNS</title></head> <body> Choose <form action ="<?php $PHP_SELF;?>" method="post"> <select name ="choice"> <option value ="0" selected>Rock</option> <option value ="1">Paper</option> <option value ="2">Scissors</option> </select> <input type="submit" value="Play"> </form> </body> </html>
Comment
-
<div class='quotetop'>QUOTE (rukiya @ Jan 11 2009, 05:43 AM) <{POST_SNAPBACK}></div>It can be coded in short by applying some maths in it like
Code:<?php /***************** Rock , Paper , Scissors Game By DNS [url]http://forum.wapfuns.com[/url] ******************/ $choice = $_POST["choice"]; if($choice!="") { $select = array ("Rock" , "Paper" , "Scissors"); $computer = rand(0,2); echo "You chose $select[$choice] . "; echo "Computer chose $select[$computer] . "; $result = $choice - $computer; if($result == 1 || $result == -2) { echo "You Win :)"; } else if($result==0) { echo "Draw !"; } else { echo "You lose :("; } exit(); } ?> <html> <head><title> Rock Paper Scissors Game By DNS</title></head> <body> Choose <form action ="<?php $PHP_SELF;?>" method="post"> <select name ="choice"> <option value ="0" selected>Rock</option> <option value ="1">Paper</option> <option value ="2">Scissors</option> </select> <input type="submit" value="Play"> </form> </body> </html>
Comment
-
Oh f.c.o.l save a lot of coding, at least make ur script neat.
function rpsResult($bet1,$bet2){
//bet1 is person dat accepts d challenge
if($bet1==$bet2){ return 0; }//draw
if(($bet1==1 && $bet2==2) || ($bet1==2 && $bet2==3) || ($bet1==3 && $bet2==1)){ return 2; }//bet1 lost, bet2 won
if(($bet1==1 && $bet2==3) || ($bet1==2 && $bet2==1) || ($bet1==3 && $bet2==2)){ return 1; }//bet2 lost, bet1 won
}
usage
betcodes
- 1 = paper
- 2 = scissors
- 3 = rock
pseudo code
if(rpsResult($challengedsBet,$challengersBet) == 0){ echo "RESULT TIE"; }elseif(rpsResult($challengedsBet,$challengersBet) == 1){ echo "RESULT: YOU WIN"; }elseif(rpsResult($challengedsBet,$challengersBet) == 2){ echo "RESULT: YOU LOST"; }
Comment
Comment