Add: lowest is prefered app - highest record, ranking sorting sequence

This commit is contained in:
2019-05-10 11:09:07 +09:00
parent 6fb0872269
commit 20dfb711eb
12 changed files with 145 additions and 64 deletions
+10 -6
View File
@@ -1,8 +1,9 @@
// Chocoball.prototype = Object.create(Phaser.Sprite.prototype); // Chocoball.prototype = Object.create(Phaser.Sprite.prototype);
Chocoball.constructor = Chocoball; Chocoball.constructor = Chocoball;
function Chocoball(index, onClickHandler) { function Chocoball(index, difficulty, onClickHandler) {
this.index = index; this.index = index;
this.difficulty = difficulty;
this.onClickHandler = onClickHandler; this.onClickHandler = onClickHandler;
this.initVariables(); this.initVariables();
@@ -60,11 +61,11 @@ Chocoball.prototype.setNumber = function(number) {
this.number = number; this.number = number;
this.numberText.text = number; this.numberText.text = number;
this.setBodyColor(this.number, Chocoball.MODE_EASY); this.setBodyColor(this.number);
} }
Chocoball.prototype.setBodyColor = function(number, mode) { Chocoball.prototype.setBodyColor = function(number) {
if(mode == Chocoball.MODE_DIFFICULT) { if(this.difficulty == Chocoball.MODE_DIFFICULT) {
this.body.tint = Chocoball.COLOR_BLACK; this.body.tint = Chocoball.COLOR_BLACK;
return; return;
} }
@@ -85,8 +86,11 @@ Chocoball.prototype.setBodyColor = function(number, mode) {
Chocoball.prototype.setActive = function(isActivated) { Chocoball.prototype.setActive = function(isActivated) {
this.isActivated = isActivated; this.isActivated = isActivated;
this.body.visible = isActivated; }
this.gloss.visible = isActivated;
Chocoball.prototype.setVisible = function(visible) {
this.body.visible = visible;
this.gloss.visible = visible;
} }
Chocoball.prototype.onClick = function() { Chocoball.prototype.onClick = function() {
+26 -11
View File
@@ -1,6 +1,8 @@
var Game = { var Game = {
create: function() { create: function() {
this.initVariables();
this.dbConnectManager = new DBConnectManager(); this.dbConnectManager = new DBConnectManager();
sessionStorageManager.setRecord(0); sessionStorageManager.setRecord(0);
@@ -31,7 +33,6 @@ var Game = {
// init game elements // init game elements
this.initVariables();
this.drawObjects(); this.drawObjects();
@@ -47,8 +48,19 @@ var Game = {
}, },
initVariables: function() { initVariables: function() {
this.mode = "test";
this.nextNumber = 1; this.nextNumber = 1;
this.difficulty = Chocoball.MODE_DIFFICULT;
// if previous record is over 60 sec, play easy mode
var prevRecord = sessionStorageManager.getRecord()
// console.log(prevRecord);
var secForEasyMode = this.mode == "test" ? 1 : 60;
if(prevRecord > secForEasyMode) {
this.difficulty = Chocoball.MODE_EASY;
}
this.firstChocoballArray = this.makeChocoballArray(1, 25); this.firstChocoballArray = this.makeChocoballArray(1, 25);
this.secondChocoballArray = this.makeChocoballArray(26, 50); this.secondChocoballArray = this.makeChocoballArray(26, 50);
}, },
@@ -58,6 +70,7 @@ var Game = {
for(var i = 0; i < 25; i++) { for(var i = 0; i < 25; i++) {
var chocoball = new Chocoball( var chocoball = new Chocoball(
i, i,
this.difficulty,
(function(chocoball) { this.onClickChocoball(chocoball); }).bind(this) (function(chocoball) { this.onClickChocoball(chocoball); }).bind(this)
); );
chocoball.setNumber(this.firstChocoballArray[i]); chocoball.setNumber(this.firstChocoballArray[i]);
@@ -92,6 +105,7 @@ var Game = {
this.nextChocoball = new Chocoball( this.nextChocoball = new Chocoball(
100, 100,
this.difficulty,
(function(chocoball) { console.log("no event") }).bind(this) (function(chocoball) { console.log("no event") }).bind(this)
); );
this.nextChocoball.setNumber(this.nextNumber); this.nextChocoball.setNumber(this.nextNumber);
@@ -117,7 +131,7 @@ var Game = {
onClickChocoball: function(chocoball) { onClickChocoball: function(chocoball) {
// console.log(chocoball.index); // console.log(chocoball.index);
console.log(chocoball.number); // console.log(chocoball.number);
if(chocoball.number == 1) if(chocoball.number == 1)
this.stopWatch.start(); this.stopWatch.start();
@@ -135,7 +149,15 @@ var Game = {
chocoball.setNumber(this.secondChocoballArray[chocoball.index]); chocoball.setNumber(this.secondChocoballArray[chocoball.index]);
this.nextChocoball.setNumber(this.nextNumber); this.nextChocoball.setNumber(this.nextNumber);
} else { } else {
chocoball.setActive(false); chocoball.setVisible(false);
}
if(this.mode == "test") {
if(this.nextNumber == 3) {
console.log("time over");
this.timeOver();
}
return;
} }
if(chocoball.number == 50) { if(chocoball.number == 50) {
@@ -159,10 +181,6 @@ var Game = {
}, },
timeOver: function() { timeOver: function() {
var timeOverText = new TimeOverText();
if(!isExperienceMaestroAccount())
this.updateResultRecord();
var recordTime = this.stopWatch.stop(); var recordTime = this.stopWatch.stop();
sessionStorageManager.setRecord(recordTime); sessionStorageManager.setRecord(recordTime);
if(!isExperienceMaestroAccount()) if(!isExperienceMaestroAccount())
@@ -173,9 +191,6 @@ var Game = {
}, },
updateResultRecord: function() { updateResultRecord: function() {
console.log("update record : " + sessionStorageManager.getRecord());
return;
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
this.dbConnectManager.updateResultRecord( this.dbConnectManager.updateResultRecord(
sessionStorageManager.getMaestroID(), sessionStorageManager.getMaestroID(),
@@ -187,7 +202,7 @@ var Game = {
}, },
goResult: function() { goResult: function() {
location.href = '../../web/client/result.html'; location.href = '../../web/client/result.html?update=1905101';
}, },
} }
+2 -2
View File
@@ -1,5 +1,5 @@
function HistoryBoard(type) { function HistoryBoard(dataType) {
if(type === RecordBoard.TYPE_SAMPLE) { if(dataType === RecordBoard.TYPE_SAMPLE) {
this.printSample(); this.printSample();
return; return;
} }
+3 -3
View File
@@ -1,11 +1,11 @@
function RecordBoard(type) { function RecordBoard(dataType) {
this.chartGraphics = game.add.graphics(0, 0); this.chartGraphics = game.add.graphics(0, 0);
this.printRecordBoardHeader(); this.printRecordBoardHeader();
this.printSeperator(); this.printSeperator();
var historyBoard = new HistoryBoard(type); var historyBoard = new HistoryBoard(dataType);
var rankingBoard = new RankingBoard(type); var rankingBoard = new RankingBoard(dataType);
} }
+32 -25
View File
@@ -39,9 +39,6 @@ var Result = {
// contents // contents
this.printRecord(); this.printRecord();
// if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
// this.updateResultRecord();
// }
this.makeRestartButton(); this.makeRestartButton();
@@ -113,6 +110,31 @@ var Result = {
}, },
printTodayBestRecord: function() { printTodayBestRecord: function() {
// console.log(sessionStorageManager.getAppHighestRecord());
// console.log(sessionStorageManager.getRecord());
var appHighestRecord = sessionStorageManager.getAppHighestRecord();
var prevRecord = sessionStorageManager.getRecord();
if(appHighestRecord == 'undefined' || appHighestRecord == null) {
this.showHighestRecordEffect(prevRecord);
return;
}
if(this.isHighestRecordPreferApp()) {
console.log("highest record prefer");
if(prevRecord > appHighestRecord)
this.showHighestRecordEffect(prevRecord);
} else {
console.log("lowest record prefer");
if(appHighestRecord == 0)
this.showHighestRecordEffect(prevRecord);
else if(prevRecord < appHighestRecord)
this.showHighestRecordEffect(prevRecord);
}
},
showHighestRecordEffect: function(record) {
sessionStorageManager.setAppHighestRecord(record);
var newRecordEmitter = game.add.emitter(game.world.centerX, 140, 300); var newRecordEmitter = game.add.emitter(game.world.centerX, 140, 300);
newRecordEmitter.makeParticles('star'); newRecordEmitter.makeParticles('star');
newRecordEmitter.gravity = 300; newRecordEmitter.gravity = 300;
@@ -123,30 +145,15 @@ var Result = {
bestRecordText.stroke = "#333"; bestRecordText.stroke = "#333";
bestRecordText.strokeThickness = 5; bestRecordText.strokeThickness = 5;
if(sessionStorageManager.getAppHighestRecord() == 'undefined' || sessionStorageManager.getAppHighestRecord() == null) bestRecordText.text = "! : . 최고 기록 경신 . : !";
sessionStorageManager.setAppHighestRecord(0); newRecordEmitter.start(true, 2000, null, 20);
var todayBestRecord = 0;
var flooredBestRecord = Math.floor(sessionStorageManager.getAppHighestRecord());
var bestRecordWithCommas = NumberUtil.numberWithCommas(flooredBestRecord);
if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord()) {
sessionStorageManager.setAppHighestRecord(sessionStorageManager.getRecord());
bestRecordText.text = "! : . 최고 기록 경신 . : !";
newRecordEmitter.start(true, 2000, null, 20);
} else {
bestRecordText.text = "";
}
}, },
updateResultRecord: function() { isHighestRecordPreferApp: function() {
this.dbConnectManager.updateResultRecord( if(sessionStorageManager.getPlayingAppID() == 105)
sessionStorageManager.getMaestroID(), return false;
sessionStorageManager.getPlayerID(),
sessionStorageManager.getPlayingAppID(), return true;
sessionStorageManager.getRecord()
);
}, },
makeRestartButton: function() { makeRestartButton: function() {
+1 -1
View File
@@ -43,7 +43,7 @@
<script src="../../game/result/history_board.js"></script> <script src="../../game/result/history_board.js"></script>
<script src="../../game/result/ranking_board.js"></script> <script src="../../game/result/ranking_board.js"></script>
<script src="../../game/result/record_board.js"></script> <script src="../../game/result/record_board.js"></script>
<script src="../../game/result/result.js?update_date=191225"></script> <script src="../../game/result/result.js?update_date=190510"></script>
<script src="../../game/result/main.js"></script> <script src="../../game/result/main.js"></script>
+10
View File
@@ -0,0 +1,10 @@
<?php
function is_highest_record_prefer_app($app_id) {
if($app_id == 105)
return false;
return true;
}
?>
+16 -3
View File
@@ -3,6 +3,7 @@ header('Content-Type: application/json');
include "./../lib/send_reply_json.php"; include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php"; include "./../setup/connect_db.php";
include "./../lib/util_app.php";
$maestroID = $_POST["MaestroID"]; $maestroID = $_POST["MaestroID"];
$appID = $_POST["AppID"]; $appID = $_POST["AppID"];
@@ -27,8 +28,12 @@ function get_ranking_hour($maestroID, $appID) {
FROM best_record BR, player P 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 = ? 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 GROUP BY BR.PlayerID
ORDER BY max(BR.BestRecord) DESC; ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($appID))
$query = $query." DESC;";
else
$query = $query." ASC;";
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $appID); $stmt->bind_param('ii', $maestroID, $appID);
$stmt->execute(); $stmt->execute();
@@ -52,8 +57,12 @@ function get_ranking_day($maestroID, $appID) {
FROM best_record BR, player P FROM best_record BR, player P
WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND BR.MaestroID = ? AND BR.AppID = ? WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
GROUP BY BR.PlayerID GROUP BY BR.PlayerID
ORDER BY max(BR.BestRecord) DESC; ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($appID))
$query = $query." DESC;";
else
$query = $query." ASC;";
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $appID); $stmt->bind_param('ii', $maestroID, $appID);
$stmt->execute(); $stmt->execute();
@@ -77,8 +86,12 @@ function get_ranking_month($maestroID, $appID) {
FROM best_record BR, player P FROM best_record BR, player P
WHERE BR.PlayerID = P.PlayerID AND MONTH(BR.RecordDateTime) = MONTH(NOW()) AND BR.MaestroID = ? AND BR.AppID = ? WHERE BR.PlayerID = P.PlayerID AND MONTH(BR.RecordDateTime) = MONTH(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
GROUP BY BR.PlayerID GROUP BY BR.PlayerID
ORDER BY max(BR.BestRecord) DESC; ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($appID))
$query = $query." DESC;";
else
$query = $query." ASC;";
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $appID); $stmt->bind_param('ii', $maestroID, $appID);
$stmt->execute(); $stmt->execute();
+6 -1
View File
@@ -7,6 +7,7 @@ $date = $_POST["Date"];
$time = $_POST["Time"]; $time = $_POST["Time"];
include "./../setup/connect_db.php"; include "./../setup/connect_db.php";
include "./../lib/util_app.php";
$replyJSON = get_ranking_record_day($maestro_id, $date, $app_id); $replyJSON = get_ranking_record_day($maestro_id, $date, $app_id);
@@ -28,8 +29,12 @@ function get_ranking_record_day($maestro_id, $date, $app_id) {
FROM best_record BR, player U FROM best_record BR, player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND AppID = ? WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
GROUP BY BR.playerID GROUP BY BR.playerID
ORDER BY max(BR.BestRecord) DESC; ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($app_id))
$query = $query." DESC;";
else
$query = $query." ASC;";
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('isi', $maestro_id, $date, $app_id); $stmt->bind_param('isi', $maestro_id, $date, $app_id);
$stmt->execute(); $stmt->execute();
@@ -7,6 +7,7 @@ $date = $_POST["Date"];
$time = $_POST["Time"]; $time = $_POST["Time"];
include "./../setup/connect_db.php"; include "./../setup/connect_db.php";
include "./../lib/util_app.php";
$replyJSON = get_ranking_record_hour($maestro_id, $date, $time, $app_id); $replyJSON = get_ranking_record_hour($maestro_id, $date, $time, $app_id);
@@ -27,8 +28,12 @@ function get_ranking_record_hour($maestro_id, $date, $time, $app_id) {
FROM best_record BR, player U FROM best_record BR, player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ? WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
GROUP BY BR.playerID GROUP BY BR.playerID
ORDER BY max(BR.BestRecord) DESC; ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($app_id))
$query = $query." DESC;";
else
$query = $query." ASC;";
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('issi', $maestro_id, $date, $time, $app_id); $stmt->bind_param('issi', $maestro_id, $date, $time, $app_id);
$stmt->execute(); $stmt->execute();
@@ -7,6 +7,7 @@ $date = $_POST["Date"];
$time = $_POST["Time"]; $time = $_POST["Time"];
include "./../setup/connect_db.php"; include "./../setup/connect_db.php";
include "./../lib/util_app.php";
$replyJSON = get_ranking_record_month($maestro_id, $date, $time, $app_id); $replyJSON = get_ranking_record_month($maestro_id, $date, $time, $app_id);
@@ -28,8 +29,12 @@ function get_ranking_record_month($maestro_id, $date, $time, $app_id) {
FROM best_record BR, player U FROM best_record BR, player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ? WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
GROUP BY BR.playerID GROUP BY BR.playerID
ORDER BY max(BR.BestRecord) DESC; ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($app_id))
$query = $query." DESC;";
else
$query = $query." ASC;";
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('isi', $maestro_id, $date, $app_id); $stmt->bind_param('isi', $maestro_id, $date, $app_id);
$stmt->execute(); $stmt->execute();
+27 -10
View File
@@ -9,7 +9,7 @@ $record = $_POST["Record"];
include "./../setup/connect_db.php"; include "./../setup/connect_db.php";
include "./../lib/app_highest_record.php"; include "./../lib/app_highest_record.php";
include "./../lib/util_app.php";
// best record is for the saved data by every hour // best record is for the saved data by every hour
$prev_best_record_id = -1; $prev_best_record_id = -1;
@@ -23,9 +23,16 @@ if($prev_best_record_id === null || $prev_best_record_id < 0) {
insert_best_record($maestro_id, $app_id, $player_id, $record); insert_best_record($maestro_id, $app_id, $player_id, $record);
} else { } else {
echo $record." ".$prev_best_record; echo $record." ".$prev_best_record;
if($record > $prev_best_record) { if(is_highest_record_prefer_app($app_id)) {
echo "update"; if($record > $prev_best_record) {
update_best_record($prev_best_record_id, $record); echo "update";
update_best_record($prev_best_record_id, $record);
}
} else {
if($record < $prev_best_record) {
echo "update";
update_best_record($prev_best_record_id, $record);
}
} }
} }
@@ -37,12 +44,22 @@ echo "\napp_highest_record : $app_highest_record";
if($app_highest_record == null) { if($app_highest_record == null) {
insert_app_highest_record($maestro_id, $app_id, $player_id, $record); insert_app_highest_record($maestro_id, $app_id, $player_id, $record);
// echo "\ninsert_app_highest_record : $record"; // echo "\ninsert_app_highest_record : $record";
} } else {
else if($record > $app_highest_record) { if(is_highest_record_prefer_app($app_id)) {
remove_app_highest_record($maestro_id, $app_id, $player_id); if($record > $app_highest_record) {
// echo "\nremove_app_highest_record"; remove_app_highest_record($maestro_id, $app_id, $player_id);
insert_app_highest_record($maestro_id, $app_id, $player_id, $record); // echo "\nremove_app_highest_record";
// echo "\ninsert_app_highest_record : $record"; insert_app_highest_record($maestro_id, $app_id, $player_id, $record);
// echo "\ninsert_app_highest_record : $record";
}
} else {
if($record < $app_highest_record) {
remove_app_highest_record($maestro_id, $app_id, $player_id);
// echo "\nremove_app_highest_record";
insert_app_highest_record($maestro_id, $app_id, $player_id, $record);
// echo "\ninsert_app_highest_record : $record";
}
}
} }
$db_conn->close(); $db_conn->close();