Try removing the / from Template::show(‘/’);
class spiel4 extends CodonModule
{
public function index()
{
Template::Show(‘spiel4/poker.tpl’);
}
public function pageone()
{
Template::Show(‘spiel4/card_results.tpl’);
}
public function pagetwo()
{
Template::Show(‘spiel4/card_new_game.tpl’);
}
}
–> Just realised,try changing your form action to this in your case <?php echo SITE_URL; ?>/index.php/spiel4/page_one">
Ok thx, that worked for me…but I think it’s to complex to add external scripts or modules to phpvms.
Now the error is:
Fatal error : Cannot redeclare checkWinner() (previously declared in /var/www/web1112/html/va/core/templates/spiel4/card_results.tpl:59) in /var/www/web1112/html/va/core/templates/spiel4/card_results.tpl on line 95
The code from card_results.tpl:
session_start();
<?php
/* Poker Ranks
1 = Royal Straight Flush
2 = Straight Flush
3 = 4 Of A Kind
4 = Full House
5 = Flush
6 = Straight
7 = 3 Of A Kind
8 = 2 Pair
9 = 1 Pair
10 = High Card
*/
/*
displayCards() Results:
1 = Win
2 = Loss
3 = Tie
*/
if(isset($_POST[‘swap’]) && $_SESSION[‘state’] == 1)
{
checkWinner();
}
elseif(isset($_POST[‘new_game’]))
{
session_destroy();
session_start();
include “poker.tpl”;
}
elseif(isset($_POST[‘stay’]))
{
checkWinner();
}
else
{
include “card_new_game.tpl”;
}
function checkWinner()
{
$_SESSION[‘state’] = 0;
for($x=1; $x<6; $x++)
{
if(isset($_POST[‘chk_’ . $x]))
{
$_SESSION[‘counter’]++;
$temp = explode(‘-’, $_SESSION[‘deck’][9 + $_SESSION[‘counter’]]);
$_SESSION[‘player_cards’][$x-1] = $temp[0];
$_SESSION[‘player_suits’][$x-1] = $temp[1];
}
}
if(pokerRank($_SESSION[‘player_cards’], $_SESSION[‘player_suits’]) > pokerRank($_SESSION[‘dealer_cards’], $_SESSION[‘dealer_suits’]))
{
displayCards(‘1’);
}
elseif(pokerRank($_SESSION[‘player_cards’], $_SESSION[‘player_suits’]) == pokerRank($_SESSION[‘dealer_cards’], $_SESSION[‘dealer_suits’]))
{
if(highestCard($_SESSION[‘player_cards’]) > highestCard($_SESSION[‘dealer_cards’]))
{
displayCards(‘1’);
}
elseif(highestCard($_SESSION[‘player_cards’]) == highestCard($_SESSION[‘dealer_cards’]))
{
displayCards(‘3’);
}
else
{
displayCards(‘2’);
}
}
else
{
displayCards(‘2’);
}
}
function displayCards($result)
{
switch($result)
{
case 1:
$msg = “You have won…”;
break;
case 2:
$msg = “You have lost…”;
break;
case 3:
$msg = “A tie somehow…”;
break;
}
include “poker.tpl”;
}
function highestCard($cards)
{
sort($cards);
return $cards[0];
}
function pokerRank($cards, $suits)
{
//reassign some cards if needed by number to make it easier to check for straights.
for($x=0; $x<count($cards); $x++)
{
switch ($cards[$x])
{
case “j”:
$cards[$x] = 11;
break;
case “q”:
$cards[$x] = 12;
break;
case “k”:
$cards[$x] = 13;
break;
case “a”:
$cards[$x] = 14;
break;
}
}
sort($cards);
//check for one pair
if ($cards[0] == $cards[1] || $cards[1] == $cards[2] || $cards[2] == $cards[3] || $cards[3] == $cards[4])
$pokerRank = 9;
//check for two pair
if( ($cards[0] == $cards[1] && $cards[2] == $cards[3]) ||
($cards[0] == $cards[1] && $cards[3] == $cards[4]) ||
($cards[1] == $cards[2] && $cards[3] == $cards[4]))
$pokerRank = 8;
//check for 3 of a kind.
if( ($cards[0] == $cards[1] && $cards[1] == $cards[2]) ||
($cards[1] == $cards[2] && $cards[2] == $cards[3]) ||
($cards[2] == $cards[3] && $cards[3] == $cards[4]))
$pokerRank = 7;
//check for straight
if( ( $cards[0]+1 == $cards[1] && $cards[1]+1 == $cards[2] && $cards[2]+1 == $cards[3] && $cards[3]+1 == $cards[4]) ||
($cards[4] == “14” && $cards[0] == “2” && $cards[1] == “3” && $cards[2] == “4” && $cards[3] == “5”) )
$pokerRank = 6;
//check for flush
if($suits[0] == $suits[1] && $suits[0] == $suits[1] && $suits[0] == $suits[2] && $suits[0] == $suits[3] & $suits[0] == $suits[4])
{
//check for royal straight flush
if($pokerRank == 6 && $cards[4] == 14)
{
$pokerRank = 1;
}
//check for a straight flush
elseif($pokerRank == 6)
{
$pokerRank = 2;
}
else
{
$pokerRank = 5;
}
}
//check for full house
if( ($cards[0] == $cards[1] && $cards[0] == $cards[2] && $cards[3] == $cards[4]) ||
($cards[0] == $cards[1] && $cards[2] == $cards[3] && $cards[3] == $cards[4]) )
$pokerRank = 4;
//check for four of a kind
if( ( $cards[0] == $cards[1] && $cards[1] == $cards[2] && $cards[2] = $cards[3]) ||
($cards[1] == $cards[2] && $cards[2] == $cards[3] && $cards[3] == $cards[4]) )
$pokerRank = 3;
return $pokerRank;
}
?>