From 9f6a68d52660aa7f6c6a83d9069ef7760ac04abd Mon Sep 17 00:00:00 2001 From: Astrologies Date: Fri, 31 Dec 2021 03:02:35 -0500 Subject: [PATCH] Game impl update --- globals/Dependencies/Games/Game.php | 28 +++++++++++++++++++++++++ html_api/RoleSets/GetRoleSetForUser.php | 5 ++++- html_api/game/pbs/configure.php | 5 ++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/globals/Dependencies/Games/Game.php b/globals/Dependencies/Games/Game.php index b60c084..833c45d 100644 --- a/globals/Dependencies/Games/Game.php +++ b/globals/Dependencies/Games/Game.php @@ -238,6 +238,34 @@ namespace Alphaland\Games { return false; } + public static function RemovePersonalBuildServerRank(int $placeid, int $userid) + { + $remove = $GLOBALS['pdo']->prepare("DELETE FROM personal_build_ranks WHERE placeid = :pid AND userid = :uid"); + $remove->bindParam(":pid", $placeid, PDO::PARAM_INT); + $remove->bindParam(":uid", $userid, PDO::PARAM_INT); + $remove->execute(); + if ($remove->rowCount() > 0) { + return true; + } + return false; + } + + public static function GetPersonalBuildServerRank(int $placeid, int $userid) + { + if ($userid == Asset::GetAssetInfo($placeid)->CreatorId) { + return 255; + } else { + $rank = $GLOBALS['pdo']->prepare("SELECT * FROM personal_build_ranks WHERE placeid = :pid AND userid = :uid"); + $rank->bindParam(":pid", $placeid, PDO::PARAM_INT); + $rank->bindParam(":uid", $userid, PDO::PARAM_INT); + $rank->execute(); + if ($rank->rowCount() > 0) { + return $rank->fetch(PDO::FETCH_OBJ)->rank; + } + } + return 10; //no rank. consider them Visitor rank + } + public static function PersonalBuildRankToName($rank) { switch ($rank) diff --git a/html_api/RoleSets/GetRoleSetForUser.php b/html_api/RoleSets/GetRoleSetForUser.php index 9bb18a1..65cc577 100644 --- a/html_api/RoleSets/GetRoleSetForUser.php +++ b/html_api/RoleSets/GetRoleSetForUser.php @@ -6,6 +6,9 @@ Alphaland 2021 */ //headers + +use Alphaland\Games\Game; + header("Access-Control-Allow-Origin: https://www.alphaland.cc"); header("access-control-allow-credentials: true"); @@ -21,7 +24,7 @@ $userid = $_GET['userId']; $userInfo = array( "data" => array( - "Rank" => getBuildServerRank($placeid, $userid), + "Rank" => Game::GetPersonalBuildServerRank($placeid, $userid), ) ); diff --git a/html_api/game/pbs/configure.php b/html_api/game/pbs/configure.php index a8d0868..3d72b55 100644 --- a/html_api/game/pbs/configure.php +++ b/html_api/game/pbs/configure.php @@ -64,7 +64,10 @@ else else if ($removeuser) { $userid = $data->userid; - $message = removePBSUser($assetid, $userid); + $message = null; + if (Game::RemovePersonalBuildServerRank($assetid, $userid)) { + $message = true; + } } else if ($whitelistuser) {