Fix: result record, ranking board bug
This commit is contained in:
@@ -346,9 +346,9 @@ DBConnectManager.prototype.requestHowToPlay = function(appID, onSucceededListene
|
||||
xhr.send("AppID=" + appID);
|
||||
}
|
||||
|
||||
DBConnectManager.prototype.updateAppHighestRecord = function(maestroID, playerID, appID, record) {
|
||||
DBConnectManager.prototype.updateResultRecord = function(maestroID, playerID, appID, record) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/record/update_app_highest_record.php", true);
|
||||
xhr.open("POST", this.phpPath + "server/record/update_result_record.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send(
|
||||
"MaestroID=" + maestroID
|
||||
|
||||
@@ -15,25 +15,31 @@ function HistoryBoard(type) {
|
||||
this.textMyRanking = game.add.text(posX, posY + 100, '', arrayTabStyle)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
var today = new Date();
|
||||
var date = DateUtil.getYYYYMMDD(today);
|
||||
this.dbConnectManager.requestPlayerHistory(
|
||||
sessionStorageManager.getMaestroID(),
|
||||
date,
|
||||
(function(historyRecordManager) {
|
||||
if(historyRecordManager.getCount() == 0) {
|
||||
console.log("history board - no data");
|
||||
return;
|
||||
}
|
||||
setTimeout(
|
||||
(function() {
|
||||
var today = new Date();
|
||||
var date = DateUtil.getYYYYMMDD(today);
|
||||
this.dbConnectManager.requestPlayerHistory(
|
||||
sessionStorageManager.getMaestroID(),
|
||||
date,
|
||||
(function(historyRecordManager) {
|
||||
if(historyRecordManager.getCount() == 0) {
|
||||
console.log("history board - no data");
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i = 0; i < historyRecordManager.getCount(); i++) {
|
||||
var data = historyRecordManager.getAt(i);
|
||||
this.printRecord(i, data.date, data.bestRecord);
|
||||
for(var i = 0; i < historyRecordManager.getCount(); i++) {
|
||||
var data = historyRecordManager.getAt(i);
|
||||
this.printRecord(i, data.date, data.bestRecord);
|
||||
|
||||
if(date == data.date)
|
||||
this.todayBestRecord = data.bestRecord;
|
||||
}
|
||||
}).bind(this)
|
||||
if(date == data.date)
|
||||
this.todayBestRecord = data.bestRecord;
|
||||
}
|
||||
}).bind(this)
|
||||
);
|
||||
}).bind(this),
|
||||
|
||||
RecordBoard.DELAY_UPDATING_RESULT_RECORD_MS
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,15 @@ function RankingBoard(type) {
|
||||
this.makeMedalSprites();
|
||||
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_HOUR);
|
||||
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_DAY);
|
||||
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_MONTH);
|
||||
setTimeout(
|
||||
(function() {
|
||||
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_HOUR);
|
||||
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_DAY);
|
||||
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_MONTH);
|
||||
}).bind(this),
|
||||
|
||||
RecordBoard.DELAY_UPDATING_RESULT_RECORD_MS
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,4 +50,6 @@ RecordBoard.prototype.printSeperator = function() {
|
||||
RecordBoard.HEADER_BAR_HEIGHT_PX = 60;
|
||||
|
||||
RecordBoard.TYPE_SAMPLE = "sample";
|
||||
RecordBoard.TYPE_DB = "db";
|
||||
RecordBoard.TYPE_DB = "db";
|
||||
|
||||
RecordBoard.DELAY_UPDATING_RESULT_RECORD_MS = 500;
|
||||
@@ -39,17 +39,20 @@ var Result = {
|
||||
|
||||
// contents
|
||||
this.printRecord();
|
||||
this.uploadRecord();
|
||||
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
||||
this.updateResultRecord();
|
||||
}
|
||||
|
||||
this.makeRestartButton();
|
||||
|
||||
|
||||
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
||||
var recordBoard = new RecordBoard(RecordBoard.TYPE_SAMPLE);
|
||||
this.announceBox = new AnnounceBox(50, 648);
|
||||
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
|
||||
} else {
|
||||
var recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
|
||||
this.printTodayBestRecord();
|
||||
var recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,12 +151,8 @@ var Result = {
|
||||
}
|
||||
},
|
||||
|
||||
uploadRecord: function() {
|
||||
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
||||
return;
|
||||
}
|
||||
|
||||
this.dbConnectManager.updateAppHighestRecord(
|
||||
updateResultRecord: function() {
|
||||
this.dbConnectManager.updateResultRecord(
|
||||
sessionStorageManager.getMaestroID(),
|
||||
sessionStorageManager.getPlayerID(),
|
||||
sessionStorageManager.getPlayingAppID(),
|
||||
|
||||
+6
-6
@@ -16,15 +16,15 @@ $prev_best_record_id = -1;
|
||||
$prev_best_record = 0;
|
||||
|
||||
$prev_best_record_id = get_best_record($maestro_id, $app_id, $player_id);
|
||||
// echo "id : ".$prev_best_record_id." ".$prev_best_record;
|
||||
echo "id : ".$prev_best_record_id." ".$prev_best_record;
|
||||
|
||||
if($prev_best_record_id === null || $prev_best_record_id < 0) {
|
||||
// echo "insert";
|
||||
echo "insert";
|
||||
insert_best_record($maestro_id, $app_id, $player_id, $record);
|
||||
} else {
|
||||
// echo $record." ".$prev_best_record;
|
||||
echo $record." ".$prev_best_record;
|
||||
if($record > $prev_best_record) {
|
||||
// echo "update";
|
||||
echo "update";
|
||||
update_best_record($prev_best_record_id, $record);
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ function get_best_record($maestro_id, $app_id, $player_id) {
|
||||
SELECT BestRecordID, BestRecord
|
||||
FROM best_record
|
||||
WHERE MaestroID = ? AND AppID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW())
|
||||
/*AND HOUR(RecordDateTime) = HOUR(NOW())*/
|
||||
AND HOUR(RecordDateTime) = HOUR(NOW())
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("iii", $maestro_id, $app_id, $player_id);
|
||||
@@ -91,7 +91,7 @@ function update_best_record($prev_best_record_id, $record) {
|
||||
UPDATE best_record
|
||||
SET BestRecord = ?, RecordDateTime = NOW()
|
||||
WHERE BestRecordID = ? AND DATE(RecordDateTime) = DATE(NOW())
|
||||
/* AND HOUR(RecordDateTime) = HOUR(NOW()) */
|
||||
AND HOUR(RecordDateTime) = HOUR(NOW())
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('di', $record, $prev_best_record_id);
|
||||
Reference in New Issue
Block a user