Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //pole všech karet v podobě označení karet číslovaných automaticky od číselného klíče 0
- $balicek = array ("♠2", "♣2", "♥2", "♦2",
- "♠3", "♣3", "♥3", "♦3",
- "♠4", "♣4", "♥4", "♦4",
- "♠5", "♣5", "♥5", "♦5",
- "♠6", "♣6", "♥6", "♦6",
- "♠7", "♣7", "♥7", "♦7",
- "♠8", "♣8", "♥8", "♦8",
- "♠9", "♣9", "♥9", "♦9",
- "♠10", "♣10", "♥10", "♦10",
- "♠J", "♣J", "♥J", "♦J",
- "♠Q", "♣Q", "♥Q", "♦Q",
- "♠K", "♣K", "♥K", "♦K",
- "♠A", "♣A", "♥A", "♦A");
- if(isset($_GET["old_cards"])){
- $old_cards = $_GET["old_cards"];
- }
- if(isset($_GET["kartu"])){ //aby se nedavaly automaticky
- srand();
- $cislo_karty = rand(0, 51);
- $start = 0; //start pro substr()
- if(stristr($balicek[$cislo_karty], "♠")){
- $start = strlen("♠");
- }else if(stristr($balicek[$cislo_karty], "♣")){
- $start = strlen("♣");
- }else if(stristr($balicek[$cislo_karty], "♥")){
- $start = strlen("♥");
- }else if(stristr($balicek[$cislo_karty], "♦")){
- $start = strlen("♦");
- }
- $value = substr($balicek[$cislo_karty], $start); //odeberu obrazek a pracuji s hodnotou karty
- if(!is_numeric($value)){ //pokud znak neni cislo
- switch($value){ //tak jej prepisu na jeho ciselnou hodnotu
- case "J": $value=10; break;
- case "Q": $value=10; break;
- case "K": $value=10; break;
- case "A": $value=11; break;
- }
- }
- $dalsi_karty = "";
- if(isset($_GET["old_cards"])){
- $arr_old_cards = explode(",", $_GET["old_cards"]);
- for($i = 0; $i < count($arr_old_cards); $i++){
- $cur_old_card = $arr_old_cards[$i];
- $dalsi_karty.= "<table cellspacing='5'><tr>\n
- <td width='70px' height='100px' style='border: 2px solid black; text-align:center;'>".$balicek[$cur_old_card]."
- </td></tr>\n</table>";
- }
- }
- if(isset($_GET["karty"])){
- $old_cards = $_GET["old_cards"];
- $value2 = $_GET["karty"]+$value;
- $old_cards.= ",".$cislo_karty;
- }else{
- $value2 = $value;
- $old_cards = $cislo_karty;
- }
- echo $value2."<br />\n";
- echo "<table cellspacing='5'><tr>";
- echo "<td width='70px' height='100px' style='border: 2px solid black; text-align:center;'>".$balicek[$cislo_karty]."</td>";
- echo "</tr></table>";
- echo $dalsi_karty;
- $to_form = "<input type='hidden' name='karty' value='$value2' />\n";
- $to_form.= "<input type='hidden' name='old_cards' value='$old_cards' />\n";
- }else if(!isset($_GET["kartu"])){
- $to_form = "";
- }
- if(isset($_GET["stop"])){
- srand();
- $value = $_GET["karty"];
- echo "Vaše skore: ".$value."<br />\n";
- $to_form = "<input type='hidden' name='karty' value='0' />\n";
- $to_form.= "<input type='hidden' name='old_cards' value='' />\n";
- }
- ?>
- <form method='get' action='karty.php'>
- <input type='submit' name='kartu' value='kartu' />
- <?php
- echo "<input type='submit' name='stop' value='stop' />\n";
- echo $to_form;
- ?>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement