/    Sign up×
Community /Pin to ProfileBookmark

keep track of score

attempting to make a taboo game similar to [url]www.playtaboo.com[/url]

I would like to display a random taboo card, and below the card allow the user to click on either correct or incorrect and when they click on the button, the current teams score will either be incremented, or decremented, and then it should move on to the next team with another random card.

here is what I have (please don’t make too much fun of me, it is very far from polished, just a cheap hack atm) so far. I am having trouble keeping track of the score. when the user clicks on either correct or incorrect the form will be submitted (multiple forms on this page…) but I think this will set everything else back to square one… (I suggest taking a look at playtaboo.com for a better idea of what I am shooting for, they seem to use:

[CODE]<input value=”CORRECT” name=”Input” type=”button” onclick=”location.href=’display4.php?act=increase'” />
<input value=”PASSED” name=”Input” type=”button” onclick=”location.href=’display4.php?act=decrease’;” />
<input value=”END ROUND” name=”Input” type=”button” onclick=”location.href=’display4.php?act=clear'” />[/CODE]

and I am not sure how they have it working)

anyhow, thank you.

[CODE]<html>
<head>
<title>Taboo</title>
</head>
<body>

<?php
/*
* driver.php
*
* Copyright 2008 Thomas Wolfe <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/

<a href=”addcard.php”>Add Card</a>

$cardStorage=new cardStorage();
$card=new card();
$currentTeam=1;
//$timestart=time();
//$timeend=time();
//

//$time=htmlentities($_GET[“time”]);
$maxNumTabooWords=htmlentities($_GET[“maxNumTabooWords”]);
$numCards=htmlentities($_GET[“numCards”]);
$numTeams=htmlentities($_GET[“numTeams”]);
$copyMaxNumTabooWords=$maxNumTabooWords;

$correct=htmlentities($_GET[“correct”]);
$incorrect=htmlentities($_GET[“incorrect”]);

if ($maxNumTabooWords == ” | $numCards == ” | $numTeams == ”)
{
echo(‘
<form action=”driver.php” method=”get”>
Maximum Number of taboo words: <input type=”text” name=”maxNumTabooWords” />
Number cards to play for game: <input type=”text” name=”numCards” />
Number of teams: <input type=”text” name=”numTeams” />
<input type=”submit” value=”submit options” />
</form>’);
}
else if ($time<2 | $maxNumTabooWords<1 | $numCards<3 | $numTeams<2 !is_numeric($time) | !is_numeric($maxNumTabooWords)
| !is_numeric($numCards) | !is_numeric($numTeams) | $numCards<$numTeams)
{
echo(‘
Valid input:
must be numeric
Number of cards must be greater than # of teams
time must be over 2 seconds
Maximum number of taboo words must be over 1
number of cards to pay must be over 3
number of Teams must be over 2
<form action=”driver.php” method=”get”>
Time (in seconds) between turns: <input type=”text” name=”time” />
Maximum Number of taboo words: <input type=”text” name=”maxNumTabooWords” />
Number cards to play for game: <input type=”text” name=”numCards” />
Number of teams: <input type=”text” name=”numTeams” />
<input type=”submit” value=”submit options” />
</form>’);
}
else
{
for(i=0;i<$numTeams;i++)
{
arrayTeam[i]=new Team();
i++;
}

while($numCards!=0)
{
if($currentTeam==$numTeams)
{
$currentTeam=1;
}
$card=cardStorage->getRandomCard();
$card->getTitle();
$tabooWords=$card->getTabooWords(); // should store array of all taboo words for card
$numTabooWords=sizeof($tabooWords); // stores num of elements in array

while($numTabooWords!=0 && $copyMaxNumTabooWords!=0)
{
echo “<p>$tabooWords”;
$numTabooWords–;
$copyMaxNumTabooWords–;
}
echo(‘
<form action=”driver.php” method=”get”>
<input type=”hidden” name=”correct” value=”correct” />
<input type=”submit” value=”correct” />
</form>
<form action=”driver.php” method=”get”>
<input type=”hidden” name=”incorrect” value=”incorrect” />
<input type=”submit” value=”incorrect” />
</form>’);

$if($correct==correct)
{
$arrayTeam[$currentTeam]->incScore();
}
else if($incorrect==incorrect)
{
$arrayTeam[$currentTeam]->incScore();
}
else
{
echo “weird error, was neither correct or incorrect”;
}

$numCards–;
$currentTeam++;
}

}
?>
</body>
</html>[/CODE]

basically, I just would like to know a simple way to keep score.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @blackphiber spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...