From 600316a94a7e40c5fef364d6f98abc3e509131ad Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Tue, 13 Mar 2012 11:36:26 +0100 Subject: Initial commit --- templates/404.tpl.php | 2 + templates/game.tpl.php | 167 +++++++++++++++++++++++++++++++++++++++++++ templates/head.tpl.php | 8 +++ templates/highscores.tpl.php | 35 +++++++++ templates/impressum.tpl.php | 9 +++ templates/invalid.tpl.php | 11 +++ templates/login.tpl.php | 6 ++ templates/logout.tpl.php | 2 + templates/menu.tpl.php | 11 +++ 9 files changed, 251 insertions(+) create mode 100644 templates/404.tpl.php create mode 100644 templates/game.tpl.php create mode 100644 templates/head.tpl.php create mode 100644 templates/highscores.tpl.php create mode 100644 templates/impressum.tpl.php create mode 100644 templates/invalid.tpl.php create mode 100644 templates/login.tpl.php create mode 100644 templates/logout.tpl.php create mode 100644 templates/menu.tpl.php (limited to 'templates') diff --git a/templates/404.tpl.php b/templates/404.tpl.php new file mode 100644 index 0000000..91fc6fb --- /dev/null +++ b/templates/404.tpl.php @@ -0,0 +1,2 @@ +

404

+

Site not found...

diff --git a/templates/game.tpl.php b/templates/game.tpl.php new file mode 100644 index 0000000..f7f67b8 --- /dev/null +++ b/templates/game.tpl.php @@ -0,0 +1,167 @@ +

New Game

+ + + +

+ +getCardInfo($card); + $cardPicture = $bjack->sixDecksWorkaround($card); /* Filename of card picture */ + + echo "card
"; + + $score = $_SESSION["score"]; /* Get score from session */ + echo "You finished the game with score $score.

"; + echo "New game"; + + /* + * Reset game data + */ + + unset($_SESSION["num"]); + unset($_SESSION["score"]); + + /* + * Save score to database + */ + + require_once(SITE_ROOT . "/models/" . "database.php"); + $database = new Database(); + $database->saveScore($_SESSION["user"], $score); + + /* + * Generate new deck and store it to session + */ + + $deck = $bjack->generateShuffledDeck(); + $_SESSION["deck"] = $deck; + + } else { + + $_SESSION["num"]++; /* Increase card counter */ + + $num = $_SESSION["num"]; + $score = $_SESSION["score"]; + $card = $_SESSION["deck"][$num]; + $info = $bjack->getCardInfo($card); + $cardPicture = $bjack->sixDecksWorkaround($card); + + /* + * Calculate new score + */ + + $score += $info[0]; + + /* + * Save score back to session + */ + + $_SESSION["score"] = $score; + + /* + * Display articles for Aces and Eights + */ + + if ($card == "1" || $card == "2" || $card == "3" || $card == "4" || $card == "25" || $card == "26" || $card == "27" || $card == "28") { + $n = "n"; + } else { + $n = ""; + } + + /* + * Display points for Aces + */ + + if ($card == "1" || $card == "2" || $card == "3" || $card == "4") { + $ace = " or 10"; + } else { + $ace = ""; + } + + echo "card
"; + echo "Your $num. card is a$n $info[1] and it gives you $info[0]$ace points.
Your score is now $score."; + + /* + * Display chance to go over 21 + * The complete deck has a value of 2040 points + */ + + if ($score <= 21) { + + $chance = $bjack->calculateChance($_SESSION["deck"], $num, $score); + $chance = round($chance, 0); /* We won't see a float number */ + + echo "
Chance to lose: $chance%

"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + + } else { + + /* + * Lost game + */ + + echo "You loose!

"; + echo "New game"; + + /* + * Reset session data + */ + + unset($_SESSION["num"]); + unset($_SESSION["score"]); + + /* + * Save score to database + */ + + require_once(SITE_ROOT . "/models/" . "database.php"); + $database = new Database(); + $database->saveScore($_SESSION["user"], $score); + + /* + * Generate new deck + */ + + $deck = $bjack->generateShuffledDeck(); + $_SESSION["deck"] = $deck; + + } + + } + +?> + +

+Back to menu diff --git a/templates/head.tpl.php b/templates/head.tpl.php new file mode 100644 index 0000000..9410f54 --- /dev/null +++ b/templates/head.tpl.php @@ -0,0 +1,8 @@ + + + <?php echo $site_title; ?> + " /> + + + + diff --git a/templates/highscores.tpl.php b/templates/highscores.tpl.php new file mode 100644 index 0000000..9bc889f --- /dev/null +++ b/templates/highscores.tpl.php @@ -0,0 +1,35 @@ +

Highscores

+ +getHighscores(); + + /* + * Sort multidimensional array according to $array[][1] + */ + + $sortArray = array(); + foreach ($highscores as $key => $value) { + $sortArray[$key] = $value[1]; + } + array_multisort($sortArray, SORT_DESC, SORT_NUMERIC, $highscores); + + $place = 0; + + foreach ($highscores as $highscore) { + if ($highscore[1] <= 21) { + $place++; + } + if ($place != 0) { + echo "Place $place: "; + } + $score = round($highscore[1], 2); + echo" $highscore[0] with $score Points in $highscore[2] games
\n"; + } + +?> + +

+Back to menu diff --git a/templates/impressum.tpl.php b/templates/impressum.tpl.php new file mode 100644 index 0000000..f6370a2 --- /dev/null +++ b/templates/impressum.tpl.php @@ -0,0 +1,9 @@ +

Impressum

+

+ Stefan 'xeno' Ritter
+ E-Mail: xeno (at) thehappy.de +

+ +
+
+Back to menu diff --git a/templates/invalid.tpl.php b/templates/invalid.tpl.php new file mode 100644 index 0000000..a05adf9 --- /dev/null +++ b/templates/invalid.tpl.php @@ -0,0 +1,11 @@ +

Error

+ +Something went terribly wrong!

+ +Wrong password?
+Username cannot be name
+Password cannot be password
+The developer is a dumbass

+ +Try again

+Back to menu diff --git a/templates/login.tpl.php b/templates/login.tpl.php new file mode 100644 index 0000000..073cafc --- /dev/null +++ b/templates/login.tpl.php @@ -0,0 +1,6 @@ +

Login

+
+
+
+ +
diff --git a/templates/logout.tpl.php b/templates/logout.tpl.php new file mode 100644 index 0000000..bb4a5f7 --- /dev/null +++ b/templates/logout.tpl.php @@ -0,0 +1,2 @@ +

User logged out

+Back to menu diff --git a/templates/menu.tpl.php b/templates/menu.tpl.php new file mode 100644 index 0000000..4c3913a --- /dev/null +++ b/templates/menu.tpl.php @@ -0,0 +1,11 @@ +" . $_SESSION["user"] . " (logout)"; + } +?> + + -- cgit v1.2.3