Skip to content

Commit

Permalink
Implement playergateway
Browse files Browse the repository at this point in the history
  • Loading branch information
thekabal committed Mar 11, 2018
1 parent a75e43a commit 222789f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 42 deletions.
7 changes: 2 additions & 5 deletions classes/Bases.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ public function buildBase(\PDO $pdo_db, array $langvars, int $planet_id, int $se
echo "<br><br>";

// Get playerinfo from database
$sql = "SELECT * FROM ::prefix::ships WHERE email=:email LIMIT 1";
$stmt = $pdo_db->prepare($sql);
$stmt->bindParam(':email', $_SESSION['username'], \PDO::PARAM_STR);
$stmt->execute();
$playerinfo = $stmt->fetch(\PDO::FETCH_ASSOC);
$players_gateway = new Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls
$playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']);

$sql = "SELECT * FROM ::prefix::planets WHERE planet_id=:planet_id LIMIT 1";
$stmt = $pdo_db->prepare($sql);
Expand Down
10 changes: 2 additions & 8 deletions classes/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,8 @@ public function kill(\PDO $pdo_db, int $ship_id, array $langvars, Reg $tkireg, b
public function getInsignia(\PDO $pdo_db, string $a_username, array $langvars) : string
{
// Lookup players score.
$sql = "SELECT score FROM ::prefix::ships WHERE email =:email";
$stmt = $pdo_db->prepare($sql);
$stmt->bindParam(':email', $a_username, \PDO::PARAM_STR);
$stmt->execute();
Db::logDbErrors($pdo_db, $sql, __LINE__, __FILE__);
$res = $stmt->fetch();
$playerinfo = array();
$playerinfo['score'] = $res['score'];
$players_gateway = new Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls
$playerinfo = $players_gateway->selectPlayerInfo($a_username);

for ($i = 0; $i < 20; $i++)
{
Expand Down
23 changes: 4 additions & 19 deletions classes/PlanetReportCE.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,8 @@ public static function collectCredits(\PDO $pdo_db, $db, array $langvars, array
$current_state = "GO"; // Current State
$playerinfo = Array();

// Look up the info for the player that wants to collect the credits.
$sql = "SELECT * FROM ::prefix::ships WHERE email=:email LIMIT 1";
$stmt = $pdo_db->prepare($sql);
$sql_test = \Tki\Db::logDbErrors($pdo_db, $sql, __LINE__, __FILE__);
if ($sql_test === true)
{
$stmt->bindParam(':email', $_SESSION['username'], \PDO::PARAM_STR);
$stmt->execute();
$playerinfo = $stmt->fetch(\PDO::FETCH_ASSOC);
}
$players_gateway = new \Tki\Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls
$playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']);

// Set s_p_pair as an array.
$s_p_pair = array();
Expand Down Expand Up @@ -99,15 +91,8 @@ public static function takeCredits(\PDO $pdo_db, array $langvars, int $planet_id
$planetinfo = Array();

// Get playerinfo from database
$sql = "SELECT * FROM ::prefix::ships WHERE email=:email LIMIT 1";
$stmt = $pdo_db->prepare($sql);
$sql_test = \Tki\Db::logDbErrors($pdo_db, $sql, __LINE__, __FILE__);
if ($sql_test === true)
{
$stmt->bindParam(':email', $_SESSION['username'], \PDO::PARAM_STR);
$stmt->execute();
$playerinfo = $stmt->fetch(\PDO::FETCH_ASSOC);
}
$players_gateway = new \Tki\Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls
$playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']);

// Get planetinfo from database
$sql = "SELECT * FROM ::prefix::planets WHERE planet_id=:planet_id LIMIT 1";
Expand Down
7 changes: 2 additions & 5 deletions classes/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ public static function auth(\PDO $pdo_db, string $lang, array $langvars, Reg $tk

if ($_SESSION['username'] !== null && $_SESSION['password'] !== null)
{
$sql = "SELECT password, ip_address, last_login, ship_id, ship_destroyed, dev_escapepod FROM ::prefix::ships WHERE email=:email LIMIT 1";
$stmt = $pdo_db->prepare($sql);
$stmt->bindParam(':email', $_SESSION['username'], \PDO::PARAM_STR);
$stmt->execute();
$playerinfo = $stmt->fetch();
$players_gateway = new Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls
$playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']);

if ($playerinfo !== false)
{
Expand Down
7 changes: 2 additions & 5 deletions classes/Realspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ class Realspace
{
public static function realSpaceMove(\PDO $pdo_db, array $langvars, int $destination, Reg $tkireg): string
{
$sql = "SELECT * FROM ::prefix::ships WHERE email=:email";
$stmt = $pdo_db->prepare($sql);
$stmt->bindParam(':email', $_SESSION['username'], \PDO::PARAM_STR);
$stmt->execute();
$playerinfo = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$players_gateway = new Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls
$playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']);

$sql = "SELECT angle1, angle2, distance FROM ::prefix::universe WHERE sector_id=:playersector";
$stmt = $pdo_db->prepare($sql);
Expand Down

0 comments on commit 222789f

Please sign in to comment.