PHP - RPS - 'Multiplayer' rock, paper, scissors mini game - How to store and pass variables? -
i have made structure of game (i can play vs bot), want make player vs player game. how store , pass variables then? should store in database (one table game id, 1 'move' id) or there simpler way? not intent keep score count or store next time same player want's play again.
here code have far (the player vs bot/ structure of game. not include form , other html on page):
$x = $_post['x']; $y = rand(1, 3); $a = $x-$y+3; $r = fmod($a, 3); if ($r == 0) { echo 'draw!'; } elseif ($r == 1) { echo 'you won!'; } elseif ($r == 2) { echo 'you lost!'; } else { echo 'an error occurred!'; }
if want see full script, please let me know.
my idea of database , tables:
table: users userid username (i don't include email, password , salt here...) 1 espen 2 test table: games gameid participant1 participant2 winner 1 1 2 1 1 1 2 2 table: moves moveid gameid userid move 1 1 1 2 2 1 2 1 3 2 1 3 4 2 2 1
values of moves: 1-rock, 2-paper, 3-scissors
thanks in advance!
-espen
Comments
Post a Comment