Add: ranking for app
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ranking</title>
|
||||
|
||||
|
||||
<!-- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> -->
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.2/phaser.js"></script> -->
|
||||
<script src="../../../resources/js/phaser.min.js"></script>
|
||||
|
||||
<!-- global source files -->
|
||||
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||
<script src="../../game/lib/score_manager.js"></script>
|
||||
<script src="../../game/lib/heart_manager.js"></script>
|
||||
<script src="../../game/global/global_variables.js"></script>
|
||||
|
||||
<!-- library source files -->
|
||||
<script src="../../game/lib/string_util.js"></script>
|
||||
<script src="../../game/lib/number_util.js"></script>
|
||||
<script src="../../game/lib/history_record_manager.js"></script>
|
||||
<script src="../../game/lib/input_type_text.js"></script>
|
||||
<script src="../../game/lib/button/round_rect_button.js"></script>
|
||||
<script src="../../game/lib/button/back_button.js"></script>
|
||||
<script src="../../game/lib/button/fullscreen_button.js"></script>
|
||||
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||
<script src="../../game/lib/screen_top_ui.js"></script>
|
||||
<script src="../../game/lib/screen_bottom_ui.js"></script>
|
||||
<script src="../../game/lib/game_over_text.js"></script>
|
||||
<script src="../../game/lib/animal.js"></script>
|
||||
|
||||
|
||||
<!-- Ranking : source files -->
|
||||
<script src="../../game/ranking/ranking.js"></script>
|
||||
<script src="../../game/ranking/main.js"></script>
|
||||
|
||||
|
||||
<style>
|
||||
body{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
canvas{
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="Ranking" style="text-align:center;" />
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "./../lib/send_reply_json.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$maestroID = $_POST["MaestroID"];
|
||||
$appID = $_POST["AppID"];
|
||||
|
||||
|
||||
$rankingHour = get_ranking_hour($maestroID, $appID);
|
||||
$rankingDay = get_ranking_day($maestroID, $appID);
|
||||
$rankingMonth = get_ranking_month($maestroID, $appID);
|
||||
|
||||
set_data("rankingHour", $rankingHour);
|
||||
set_data("rankingDay", $rankingDay);
|
||||
set_data("rankingMonth", $rankingMonth);
|
||||
send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
function get_ranking_hour($maestroID, $appID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord
|
||||
FROM best_record BR, player P
|
||||
WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND HOUR(BR.RecordDateTime) = HOUR(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
|
||||
GROUP BY BR.PlayerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ii', $maestroID, $appID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($playerID, $name, $bestRecord);
|
||||
|
||||
$bestRecordArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$best_record['PlayerID'] = $playerID;
|
||||
$best_record['Name'] = $name;
|
||||
$best_record['BestRecord'] = $bestRecord;
|
||||
array_push($bestRecordArray, $best_record);
|
||||
}
|
||||
return $bestRecordArray;
|
||||
}
|
||||
|
||||
function get_ranking_day($maestroID, $appID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord
|
||||
FROM best_record BR, player P
|
||||
WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
|
||||
GROUP BY BR.PlayerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ii', $maestroID, $appID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($playerID, $name, $bestRecord);
|
||||
|
||||
$bestRecordArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$best_record['PlayerID'] = $playerID;
|
||||
$best_record['Name'] = $name;
|
||||
$best_record['BestRecord'] = $bestRecord;
|
||||
array_push($bestRecordArray, $best_record);
|
||||
}
|
||||
return $bestRecordArray;
|
||||
}
|
||||
|
||||
function get_ranking_month($maestroID, $appID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord
|
||||
FROM best_record BR, player P
|
||||
WHERE BR.PlayerID = P.PlayerID AND MONTH(BR.RecordDateTime) = MONTH(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
|
||||
GROUP BY BR.PlayerID
|
||||
ORDER BY max(BR.BestRecord) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ii', $maestroID, $appID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($playerID, $name, $bestRecord);
|
||||
|
||||
$bestRecordArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$best_record['PlayerID'] = $playerID;
|
||||
$best_record['Name'] = $name;
|
||||
$best_record['BestRecord'] = $bestRecord;
|
||||
array_push($bestRecordArray, $best_record);
|
||||
}
|
||||
return $bestRecordArray;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user