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