Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- class Hledani {
- private $trefa;
- private $vedle;
- private $prachy;
- private $sance;
- public function __construct() {
- $this->trefa = 0;
- $this->vedle = 0;
- $this->prachy = 1000;
- $this->sance = 33;
- }
- public function zkuz_to($castka) {
- $vyhra = rand(1, 100) < $this->sance;
- if($vyhra) {
- $this->trefa++;
- $this->sance--;
- $this->prachy += $castka * 2;
- $text = "Uhodli jste<br/>\n";
- }
- else {
- $this->vedle++;
- $this->sance++;
- $this->prachy -= $castka;
- $text = "Smula<br/>\n";
- }
- $text .= "dobre: " . $this->trefa . "<br/>\n";
- $text .= "spatne: " . $this->vedle . "<br/>\n";
- $text .= "vase penize: " . $this->prachy;
- return $text;
- }
- }
- if(isset($_GET["reset"])) {
- unset($_SESSION["kulicky"]);
- }
- if(isset($_SESSION["kulicky"])) {
- $hra = unserialize($_SESSION["kulicky"]);
- }
- else {
- $hra = new Hledani();
- echo "mate 1000 penez";
- }
- if(isset($_GET["hadej"])) {
- echo $hra->zkuz_to($_GET["sazka"]);
- }
- ?>
- <br/>
- <form action="hledani_kulicky.php" method="get">
- Vase sazka: <input name="sazka"><br/>
- <input type="submit" name="hadej" value="Tady jsem">
- <input type="submit" name="hadej" value="Ne, tady">
- <input type="submit" name="hadej" value="Nene, tady!">
- <br/>
- <input type="submit" name="reset" value="Reset">
- </form>
- <?php
- $_SESSION["kulicky"] = serialize($hra);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement