"; } } } function pesca(&$usciti,&$ordine,&$punteggio) { if(count($ordine) >= 40) return; $scelto = false; while(!$scelto){ $index = rand(0,39); if($usciti[$index] == false) { $ordine[] = $index; $usciti[$index] = true; echo "$index"; $scelto = true; aggiornaPunteggio($punteggio,$index); } } } function aggiornaPunteggio(&$punteggio,$index) { $valore = $index % 10; if($valore >= 1 && $valore <=7){ $punteggio += $valore; }else $punteggio +=0.5; } session_start(); if (!isset($_SESSION['array'])) $_SESSION['array'] = array_fill(0, 40, false); if (!isset($_SESSION['ordine']))$_SESSION['ordine'] = []; if (!isset($_SESSION['ordineB']))$_SESSION['ordineB'] = []; if (!isset($_SESSION['punteggio']))$_SESSION['punteggio'] = 0; if (!isset($_SESSION['punteggioB']))$_SESSION['punteggioB'] = 0; if (!isset($_SESSION['finito']))$_SESSION['finito'] = false; if (!isset($_SESSION['ingioco']))$_SESSION['ingioco'] = false; if (!isset($_SESSION['puntata']))$_SESSION['puntata'] = 1; if (isset($_POST['reset'])) { $_SESSION['array'] = array_fill(0, 40, false); $_SESSION['ordine'] = []; $_SESSION['ordineB'] = []; $_SESSION['punteggio'] = 0; $_SESSION['punteggioB'] = 0; $_SESSION['finito'] = false; $_SESSION['ingioco'] = false; } $usciti = $_SESSION['array']; $ordine = $_SESSION['ordine']; $ordineB = $_SESSION['ordineB']; $punteggio = $_SESSION['punteggio'] ?? 0; $punteggioB = $_SESSION['punteggioB'] ?? 0; $credito = $_POST['credito'] ?? $_SESSION['credito']; if($credito != null)$_SESSION['credito'] = $credito; else $credito = $_SESSION['credito']; $giocata = $_POST['giocata'] ?? null; if($giocata !=null)$_SESSION['puntata'] = $giocata; echo '

Sette emmezzo


' ; echo "

Giocata: ". $_SESSION['puntata'] . " Credito: " . $credito . "


"; $mazzo = "CARTE/retro.bmp"; $finito = $_POST['finito'] ?? null; if ($finito) $_SESSION['finito'] = true; if(!$_SESSION['ingioco']){ if($credito >= 1){ echo '

Inserisci puntata:



'; }else { echo '

Hai finito i soldi sei povero..

Torna a casa'; exit; } } if($giocata==null || $_SESSION['puntata'] ){ $printMazzo = $_SESSION['finito'] ? false : true; if($printMazzo) echo ""; carteUscite(0,$ordine); $carta = $_POST['carta'] ?? null; if($carta != null && $punteggio < 7.5 && $_SESSION['finito'] == false){ pesca($usciti,$ordine,$punteggio); $_SESSION['array'] = $usciti; $_SESSION['ordine'] = $ordine; $_SESSION['punteggio'] = $punteggio; $_SESSION['ingioco'] = true; header("Location: settemezzo.php"); exit; } if($punteggio > 7.5) echo "

HAI SBALLATO

"; echo "

Punteggio attuale: $punteggio

"; $_SESSION['array'] = $usciti; $_SESSION['ordine'] = $ordine; echo ''; if($printMazzo) { echo '
'; if($_SESSION['ingioco']){ echo '
'; } } if ($finito) { echo "

Banco

"; if($punteggioB == 0){ if($punteggio <=7.5){ while($punteggioB<=7.5 && $punteggioB<=$punteggio){ pesca($usciti,$ordineB,$punteggioB); } }else { pesca($usciti,$ordineB,$punteggioB); } $_SESSION['punteggioB'] = $punteggioB; }else { carteUscite(0,$ordineB); } echo '
'; $_SESSION['ordineB'] = $ordineB; echo "

Punteggio banco: $punteggioB

"; if(($punteggioB <=7.5 && $punteggio <= $punteggioB) || $punteggio>7.5){ echo "

HAI PERSO VINCE IL BANCO

"; $credito -= $_SESSION['puntata']; } else { echo "

HAI VINTO!!

"; $credito += $_SESSION['puntata']; } $_SESSION['credito'] = $credito; $_SESSION['puntata'] = 1; } } ?>