Procházet zdrojové kódy

Small_Changes

master
rvaken před 3 roky
rodič
revize
21d1c7c815
6 změnil soubory, kde provedl 51 přidání a 19 odebrání
  1. 6
    1
      board.php
  2. 6
    0
      functies.php
  3. 18
    7
      game.php
  4. 3
    0
      index.php
  5. 18
    11
      login.php
  6. binární
      registration.db

+ 6
- 1
board.php Zobrazit soubor

@@ -1,4 +1,7 @@
<?php

// Na verloop van vorige code liep ik op een dood einde. Na lessen van opnieuw te bekijken ivm klasses heb ik nu dit.

require_once 'ship.php';

class Board
@@ -11,7 +14,6 @@ class Board

function __construct($difficulty)
{

$this->initShips($difficulty);
}

@@ -36,6 +38,7 @@ class Board
}

//Overlapping fixen

protected function legalShipPosition()
{
// $this->currentShip[0]->returnPosBegin() >
@@ -67,6 +70,8 @@ class Board
} else {


// Liep wat vast bij het verwijderen van het huidige shot, heb hiervoor de raad van klasgenoten gevraagd.

if (!empty($shots)) {
if (
in_array($x, $shots)

+ 6
- 0
functies.php Zobrazit soubor

@@ -1,7 +1,11 @@
<?php

require_once 'board.php';

session_start();

// Ships initializen naar gelang de difficulty

function assignShips($difficulty)
{
$_SESSION['currentShips'] = new Board($difficulty);
@@ -10,6 +14,8 @@ function assignShips($difficulty)
}
}

// We checken of ons shot raak of mis is

function hitOrMis($shot)
{


+ 18
- 7
game.php Zobrazit soubor

@@ -6,7 +6,10 @@ include 'functies.php';
session_start();

$form_state = 0;
var_dump($_SESSION['difficulty']);

// Display current difficulty

echo "Difficulty: " . ($_SESSION['difficulty']);

// Log out

@@ -24,13 +27,7 @@ if (isset($_POST['btnShot'])) {
echo hitOrMis($shot);
}

// Als ammo op is

if ($_SESSION['ammo'] == 0) {
echo "Game Over, try again";
assignShips($_SESSION['difficulty']);
unset($_SESSION['shots']);
}

?>

@@ -48,7 +45,13 @@ if ($_SESSION['ammo'] == 0) {
</head>

<body>


<?php

// Naar tweede form state na shot

if (isset($_POST['shot'])) {
$form_state = 1;
$_SESSION['shot'] = $_POST['shot'];
@@ -103,6 +106,14 @@ if ($_SESSION['ammo'] == 0) {
unset($_SESSION['shots']);
}

// Als ammo op is -> game over en game reset

if ($_SESSION['ammo'] === 0) {
echo "Game Over, try again";
assignShips($_SESSION['difficulty']);
unset($_SESSION['shots']);
}

// Als currentships niet meer bestaat

if (!isset($_SESSION['currentShips'])) {

+ 3
- 0
index.php Zobrazit soubor

@@ -1,4 +1,7 @@
<?php

// Register Form

session_start();


+ 18
- 11
login.php Zobrazit soubor

@@ -1,21 +1,28 @@
<?php

// Login Form

session_start();


if (isset($_POST['login'])){

//Registratie form
function checkLogin ($username, $password) {}
$db = new SQLite3 ("registration.db");
$username = $_POST['username'];
$password = $_POST['password_1'];
//Login Form
//$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$stmt = $db->prepare("SELECT * FROM users WHERE login = :usrn AND password = :passw");
$stmt->bindValue(":usrn", $username, SQLITE3_TEXT);
$stmt->bindValue(":pass", $password, SQLITE3_TEXT);
$res = $stmt->execute();

function checkLogin ($username, $password) {
$db = new SQLite3 ("registration.db");
$username = $_POST['username'];
$password = $_POST['password_1'];
//Login Form
//$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$stmt = $db->prepare("SELECT * FROM users WHERE login = :usrn AND password = :passw");
$stmt->bindValue(":usrn", $username, SQLITE3_TEXT);
$stmt->bindValue(":pass", $password, SQLITE3_TEXT);
$res = $stmt->execute();
}

if ($row = $res->fetchArray(SQLITE3_ASSOC)){
$id = $row['id'];

binární
registration.db Zobrazit soubor


Načítá se…
Zrušit
Uložit