Fix: remove old codes - best record

This commit is contained in:
2018-10-23 23:41:20 +09:00
parent f0dc660018
commit c7a5926b21
16 changed files with 47 additions and 401 deletions
-13
View File
@@ -32,7 +32,6 @@ let sessionStorageManager = new SessionStorageManager();
console.log("playingAppName : " + sessionStorageManager.getPlayingAppName()); console.log("playingAppName : " + sessionStorageManager.getPlayingAppName());
console.log("playingAppKoreanName : " + sessionStorageManager.getPlayingAppKoreanName()); console.log("playingAppKoreanName : " + sessionStorageManager.getPlayingAppKoreanName());
console.log("record : " + sessionStorageManager.getRecord()); console.log("record : " + sessionStorageManager.getRecord());
// console.log("bestRecord : " + sessionStorageManager.getBestRecord());
console.log("appHighestRecord : " + sessionStorageManager.getAppHighestRecord()); console.log("appHighestRecord : " + sessionStorageManager.getAppHighestRecord());
} }
@@ -52,18 +51,6 @@ function goLogin() {
location.href = "login.html"; location.href = "login.html";
} }
/*
function isTypingGame() {
if(sessionStorageManager.getPlayingAppName() === null)
return false;
if(sessionStorageManager.getPlayingAppName().indexOf("typing") < 0)
return false;
return true;
}
*/
function isTypingGameApp() { function isTypingGameApp() {
if(sessionStorageManager.getPlayingAppName() == null) if(sessionStorageManager.getPlayingAppName() == null)
return false; return false;
-54
View File
@@ -205,27 +205,6 @@ DBConnectManager.prototype.parseJSONtoHistoryRecord = function(json) {
} }
return historyRecordManager; return historyRecordManager;
/*
var startIndex = 0;
var endIndex = jsonRankingList.length;
var recordArray = [];
for(var i = startIndex; i < endIndex; i++) {
var bestRecordRow = [];
var strDate = jsonRankingList[i]['Date'];
var dateArray = strDate.split("-");
var recordDate = new Date(dateArray[0], dateArray[1], dateArray[2]);
bestRecordRow[0] = recordDate.getMonth() + "월 " + recordDate.getDate() + "일";
bestRecordRow[1] = Math.floor(jsonRankingList[i]['BestRecord']);
bestRecordRow[2] = getStageNameForKorean(jsonRankingList[i]['StageName']);
// console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
recordArray.push(bestRecordRow);
}
return recordArray;
*/
} }
DBConnectManager.prototype.requestRanking = function(type, maestroID, date, time, listener) { DBConnectManager.prototype.requestRanking = function(type, maestroID, date, time, listener) {
@@ -367,18 +346,6 @@ DBConnectManager.prototype.requestHowToPlay = function(appID, onSucceededListene
xhr.send("AppID=" + appID); xhr.send("AppID=" + appID);
} }
DBConnectManager.prototype.updateTodayBestRecord = function(maestroID, playerID, appID, record) {
var xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/record/update_best_record.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(
"MaestroID=" + maestroID
+ "&PlayerID=" + playerID
+ "&AppID=" + appID
+ "&BestRecord=" + record
);
}
DBConnectManager.prototype.updateAppHighestRecord = function(maestroID, playerID, appID, record) { DBConnectManager.prototype.updateAppHighestRecord = 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_app_highest_record.php", true);
@@ -391,27 +358,6 @@ DBConnectManager.prototype.updateAppHighestRecord = function(maestroID, playerID
); );
} }
DBConnectManager.prototype.requestTodayBestRecord = function(maestroID, playerID, appID, onSucceededListener, onFailedListener) {
var xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/record/request_best_record.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
var replyJSON = JSON.parse(xhr.responseText);
if(replyJSON != null && replyJSON["BestRecord"] != null)
onSucceededListener(replyJSON);
else
onFailedListener(replyJSON);
}
};
xhr.send(
"MaestroID=" + maestroID
+ "&PlayerID=" + playerID
+ "&AppID=" + appID
);
}
DBConnectManager.prototype.requestAppHighestRecord = function(maestroID, playerID, appID, onSucceededListener, onFailedListener) { DBConnectManager.prototype.requestAppHighestRecord = function(maestroID, playerID, appID, onSucceededListener, onFailedListener) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/record/request_app_highest_record.php", true); xhr.open("POST", this.phpPath + "server/record/request_app_highest_record.php", true);
+1 -1
View File
@@ -62,7 +62,7 @@ ScreenBottomUI.prototype.printText = function(textObject, text, align) {
return textObject; return textObject;
} }
ScreenBottomUI.prototype.printLeftTextWithBestRecord = function(bestRecord) { ScreenBottomUI.prototype.printLeftTextWithAppHighestRecord = function(bestRecord) {
var roundUpBestRecord = Math.round(bestRecord); var roundUpBestRecord = Math.round(bestRecord);
var highScoreWithCommas = NumberUtil.numberWithCommas(roundUpBestRecord); var highScoreWithCommas = NumberUtil.numberWithCommas(roundUpBestRecord);
this.printLeftText("최고 기록 : " + highScoreWithCommas); this.printLeftText("최고 기록 : " + highScoreWithCommas);
+5 -129
View File
@@ -83,15 +83,7 @@ SessionStorageManager.prototype.getRecord = function() {
return Number(sessionStorage.getItem("record")); return Number(sessionStorage.getItem("record"));
} }
// best record // app highest record
// SessionStorageManager.prototype.setBestRecord = function(value) {
// sessionStorage.setItem("bestRecord", value);
// }
// SessionStorageManager.prototype.getBestRecord = function() {
// return Number(sessionStorage.getItem("bestRecord"));
// }
// best record
SessionStorageManager.prototype.setAppHighestRecord = function(value) { SessionStorageManager.prototype.setAppHighestRecord = function(value) {
sessionStorage.setItem("appHighestRecord", value); sessionStorage.setItem("appHighestRecord", value);
} }
@@ -100,11 +92,11 @@ SessionStorageManager.prototype.getAppHighestRecord = function() {
} }
// best record // best record
SessionStorageManager.prototype.setIsNewBestRecord = function(value) { SessionStorageManager.prototype.setIsNewAppHighestRecord = function(value) {
sessionStorage.setItem("isNewBestRecord", value); sessionStorage.setItem("isNewAppHighestRecord", value);
} }
SessionStorageManager.prototype.getIsNewBestRecord = function() { SessionStorageManager.prototype.getIsNewAppHighestRecord = function() {
return sessionStorage.getItem("isNewBestRecord"); return sessionStorage.getItem("isNewAppHighestRecord");
} }
SessionStorageManager.prototype.resetPlayingAppData = function() { SessionStorageManager.prototype.resetPlayingAppData = function() {
@@ -112,121 +104,5 @@ SessionStorageManager.prototype.resetPlayingAppData = function() {
this.removeItem("playingAppName"); this.removeItem("playingAppName");
this.removeItem("playingAppKoreanName"); this.removeItem("playingAppKoreanName");
this.removeItem("record"); this.removeItem("record");
this.removeItem("bestRecord");
this.removeItem("appHighestRecord"); this.removeItem("appHighestRecord");
} }
/*
class SessionStorageManager {
constructor() {
}
clear() {
sessionStorage.clear();
}
removeItem(key) {
return sessionStorage.removeItem(key);
}
// maestro ID
set maestroID(value) {
sessionStorage.setItem("maestroID", value);
}
get maestroID() {
return sessionStorage.getItem("maestroID");
}
// maestro account type
set maestroAccountType(value) {
sessionStorage.setItem("maestroAccountType", value);
}
get maestroAccountType() {
return sessionStorage.getItem("maestroAccountType");
}
// player name
set playerName(value) {
sessionStorage.setItem("playerName", value);
}
get playerName() {
return sessionStorage.getItem("playerName");
}
// player player ID
set playerID(value) {
sessionStorage.setItem("playerID", value);
}
get playerID() {
return sessionStorage.getItem("playerID");
}
// player account type
set playerAccountType(value) {
sessionStorage.setItem("playerAccountType", value);
}
get playerAccountType() {
return sessionStorage.getItem("playerAccountType");
}
// playing app id
set playingAppID(value) {
sessionStorage.setItem("playingAppID", value);
}
get playingAppID() {
return sessionStorage.getItem("playingAppID");
}
// playing app name
set playingAppName(value) {
sessionStorage.setItem("playingAppName", value);
}
get playingAppName() {
return sessionStorage.getItem("playingAppName");
}
// playing app korean name
set playingAppKoreanName(value) {
sessionStorage.setItem("playingAppKoreanName", value);
}
get playingAppKoreanName() {
return sessionStorage.getItem("playingAppKoreanName");
}
// record
set record(value) {
sessionStorage.setItem("record", value);
}
get record() {
return sessionStorage.getItem("record");
}
// best record
set bestRecord(value) {
sessionStorage.setItem("bestRecord", value);
}
get bestRecord() {
return sessionStorage.getItem("bestRecord");
}
// best record
set isNewBestRecord(value) {
sessionStorage.setItem("isNewBestRecord", value);
}
get isNewBestRecord() {
return sessionStorage.getItem("isNewBestRecord");
}
resetPlayingAppData() {
sessionStorage.playingAppID = null;
sessionStorage.playingAppName = null;
sessionStorage.playingAppKoreanName = null;
sessionStorage.record = null;
sessionStorage.bestRecord = null;
}
}
*/
+5 -5
View File
@@ -112,24 +112,24 @@ var MenuTypingPractice = {
return false; return false;
}, },
getBestRecord: function(jsonList, appID) { getAppHighestRecord: function(jsonList, appID) {
var count = jsonList.length; // Object.keys(jsonList).length; var count = jsonList.length; // Object.keys(jsonList).length;
for(var i = 0; i < count; i++) { for(var i = 0; i < count; i++) {
if(jsonList[i].AppID === appID) if(jsonList[i].AppID === appID)
return jsonList[i].BestRecord; return jsonList[i].AppHighestRecord;
} }
return 0; return 0;
}, },
getIconImage: function(jsonList, appID) { getIconImage: function(jsonList, appID) {
var bestRecord = this.getBestRecord(jsonList, appID); var appHighestRecord = this.getAppHighestRecord(jsonList, appID);
if(bestRecord === 0) if(appHighestRecord === 0)
return "snail_shadow"; return "snail_shadow";
var animalLevel = Animal.animalLevelIDByRecord(bestRecord, Animal.TYPE_PRACTICE); var animalLevel = Animal.animalLevelIDByRecord(appHighestRecord, Animal.TYPE_PRACTICE);
return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon; return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon;
}, },
+5 -5
View File
@@ -114,24 +114,24 @@ var MenuTypingTest = {
return false; return false;
}, },
getBestRecord: function(jsonList, appID) { getAppHighestRecord: function(jsonList, appID) {
var count = jsonList.length; // Object.keys(jsonList).length; var count = jsonList.length; // Object.keys(jsonList).length;
for(var i = 0; i < count; i++) { for(var i = 0; i < count; i++) {
if(jsonList[i].AppID === appID) if(jsonList[i].AppID === appID)
return jsonList[i].BestRecord; return jsonList[i].AppHighestRecord;
} }
return 0; return 0;
}, },
getIconImage: function(jsonList, appID) { getIconImage: function(jsonList, appID) {
var bestRecord = this.getBestRecord(jsonList, appID); var appHighestRecord = this.getAppHighestRecord(jsonList, appID);
if(bestRecord === 0) if(appHighestRecord === 0)
return "snail_shadow"; return "snail_shadow";
var animalLevel = Animal.animalLevelIDByRecord(bestRecord, Animal.TYPE_TEST); var animalLevel = Animal.animalLevelIDByRecord(appHighestRecord, Animal.TYPE_TEST);
return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon; return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon;
}, },
+5 -5
View File
@@ -3,7 +3,7 @@ var Game = {
create: function() { create: function() {
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d'; this.game.stage.backgroundColor = "#000000"; // '#4d4d4d';
sessionStorageManager.setIsNewBestRecord(false); sessionStorageManager.setIsNewAppHighestRecord(false);
var experienceAppTimer = new ExperienceAppTimer(); var experienceAppTimer = new ExperienceAppTimer();
experienceAppTimer.setTimeOverListener( experienceAppTimer.setTimeOverListener(
@@ -30,10 +30,10 @@ var Game = {
scoreBoard.printScore(NumberUtil.numberWithCommas(score)); scoreBoard.printScore(NumberUtil.numberWithCommas(score));
}); });
scoreManager.addOnChangeHighScoreListener( function(highScore) { scoreManager.addOnChangeHighScoreListener( function(highScore) {
console.log(highScore); // console.log(highScore);
sessionStorageManager.setAppHighestRecord(highScore); // sessionStorageManager.setAppHighestRecord(highScore);
sessionStorageManager.setIsNewBestRecrd(true); sessionStorageManager.setIsNewBestRecrd(true);
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); // screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
}); });
var heartGauge = new HeartGauge(heartManager); var heartGauge = new HeartGauge(heartManager);
@@ -80,7 +80,7 @@ var Game = {
// bottom ui // bottom ui
var screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
+1 -14
View File
@@ -55,7 +55,7 @@ var Result = {
// bottom ui // bottom ui
var screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftTextWithBestRecord(Math.floor(sessionStorageManager.getAppHighestRecord())); screenBottomUI.printLeftTextWithAppHighestRecord(Math.floor(sessionStorageManager.getAppHighestRecord()));
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
}, },
@@ -131,19 +131,13 @@ var Result = {
bestRecordText.stroke = "#333"; bestRecordText.stroke = "#333";
bestRecordText.strokeThickness = 5; bestRecordText.strokeThickness = 5;
// if(sessionStorageManager.getBestRecord() == 'undefined' || sessionStorageManager.getBestRecord() == null)
// sessionStorageManager.setBestRecord(0);
if(sessionStorageManager.getAppHighestRecord() == 'undefined' || sessionStorageManager.getAppHighestRecord() == null) if(sessionStorageManager.getAppHighestRecord() == 'undefined' || sessionStorageManager.getAppHighestRecord() == null)
sessionStorageManager.setAppHighestRecord(0); sessionStorageManager.setAppHighestRecord(0);
var todayBestRecord = 0; var todayBestRecord = 0;
// var flooredBestRecord = Math.floor(sessionStorageManager.getBestRecord());
var flooredBestRecord = Math.floor(sessionStorageManager.getAppHighestRecord()); var flooredBestRecord = Math.floor(sessionStorageManager.getAppHighestRecord());
var bestRecordWithCommas = NumberUtil.numberWithCommas(flooredBestRecord); var bestRecordWithCommas = NumberUtil.numberWithCommas(flooredBestRecord);
// if(sessionStorageManager.getRecord() >= sessionStorageManager.getBestRecord()) {
// sessionStorageManager.setBestRecord(sessionStorageManager.getRecord());
if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord()) { if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord()) {
sessionStorageManager.setAppHighestRecord(sessionStorageManager.getRecord()); sessionStorageManager.setAppHighestRecord(sessionStorageManager.getRecord());
@@ -159,13 +153,6 @@ var Result = {
return; return;
} }
// this.dbConnectManager.updateTodayBestRecord(
// sessionStorageManager.getMaestroID(),
// sessionStorageManager.getPlayerID(),
// sessionStorageManager.getPlayingAppID(),
// sessionStorageManager.getRecord()
// );
this.dbConnectManager.updateAppHighestRecord( this.dbConnectManager.updateAppHighestRecord(
sessionStorageManager.getMaestroID(), sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayerID(), sessionStorageManager.getPlayerID(),
+2 -17
View File
@@ -54,20 +54,6 @@ var Start = {
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
// this.dbConnectManager.requestTodayBestRecord(
// sessionStorageManager.getMaestroID(),
// sessionStorageManager.getPlayerID(),
// sessionStorageManager.getPlayingAppID(),
// (function(replyJSON) {
// sessionStorageManager.setBestRecord(Number(replyJSON["BestRecord"]));
// screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
// }).bind(this),
// (function(replyJSON) { // no data
// sessionStorageManager.setBestRecord(0);
// screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
// }).bind(this)
// );
this.dbConnectManager.requestAppHighestRecord( this.dbConnectManager.requestAppHighestRecord(
sessionStorageManager.getMaestroID(), sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayerID(), sessionStorageManager.getPlayerID(),
@@ -75,15 +61,14 @@ var Start = {
(function(replyJSON) { (function(replyJSON) {
var appHighestRecord = replyJSON["AppHighestRecord"]; var appHighestRecord = replyJSON["AppHighestRecord"];
console.log("appHighestRecord : " + appHighestRecord); console.log("appHighestRecord : " + appHighestRecord);
// sessionStorageManager.setBestRecord(Number(appHighestRecord));
sessionStorageManager.setAppHighestRecord(Number(appHighestRecord)); sessionStorageManager.setAppHighestRecord(Number(appHighestRecord));
screenBottomUI.printLeftTextWithBestRecord(appHighestRecord); screenBottomUI.printLeftTextWithAppHighestRecord(appHighestRecord);
}).bind(this), }).bind(this),
(function(replyJSON) { // no data (function(replyJSON) { // no data
var appHighestRecord = replyJSON["AppHighestRecord"]; var appHighestRecord = replyJSON["AppHighestRecord"];
console.log("appHighestRecord : " + appHighestRecord); console.log("appHighestRecord : " + appHighestRecord);
sessionStorageManager.setAppHighestRecord(0); sessionStorageManager.setAppHighestRecord(0);
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
}).bind(this) }).bind(this)
); );
}, },
+1 -3
View File
@@ -6,7 +6,7 @@ var TypingPractice = {
this.isOnStage = false; this.isOnStage = false;
this.initTypingData(); this.initTypingData();
sessionStorageManager.setIsNewBestRecord(false); sessionStorageManager.setIsNewAppHighestRecord(false);
var experienceAppTimer = new ExperienceAppTimer(); var experienceAppTimer = new ExperienceAppTimer();
experienceAppTimer.setTimeOverListener( experienceAppTimer.setTimeOverListener(
@@ -158,8 +158,6 @@ var TypingPractice = {
goResult: function() { goResult: function() {
sessionStorageManager.setRecord(this.typingScore.score()); sessionStorageManager.setRecord(this.typingScore.score());
// if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord())
// sessionStorageManager.setAppHighestRecord(sessionStorageManager.getRecord());
location.href = '../../web/client/result.html'; location.href = '../../web/client/result.html';
}, },
+2 -4
View File
@@ -4,7 +4,7 @@ var TypingTest = {
var self = this; var self = this;
this.initTypingData(); this.initTypingData();
sessionStorageManager.setIsNewBestRecord(false); sessionStorageManager.setIsNewAppHighestRecord(false);
var experienceAppTimer = new ExperienceAppTimer(); var experienceAppTimer = new ExperienceAppTimer();
experienceAppTimer.setTimeOverListener( experienceAppTimer.setTimeOverListener(
@@ -110,7 +110,7 @@ var TypingTest = {
// bottom ui // bottom ui
var screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
@@ -173,8 +173,6 @@ var TypingTest = {
goResult: function() { goResult: function() {
sessionStorageManager.setRecord(this.typingRecordTotal); sessionStorageManager.setRecord(this.typingRecordTotal);
// if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord())
// sessionStorageManager.setAppHighestRecord(sessionStorageManager.record);
location.href = '../../web/client/result.html'; location.href = '../../web/client/result.html';
}, },
+3 -5
View File
@@ -6,7 +6,7 @@ var WhacAMole = {
this.isOnStage = false; this.isOnStage = false;
this.initTypingData(); this.initTypingData();
sessionStorageManager.setIsNewBestRecord(false); sessionStorageManager.setIsNewAppHighestRecord(false);
var experienceAppTimer = new ExperienceAppTimer(); var experienceAppTimer = new ExperienceAppTimer();
experienceAppTimer.setTimeOverListener( experienceAppTimer.setTimeOverListener(
@@ -32,9 +32,9 @@ var WhacAMole = {
this.scoreManager.addOnChangeHighScoreListener( this.scoreManager.addOnChangeHighScoreListener(
(function(highScore) { (function(highScore) {
console.log(highScore); console.log(highScore);
sessionStorageManager.setBestRecord(highScore); // sessionStorageManager.setAppHighestRecord(highScore);
sessionStorageManager.setIsNewBestRecrd(true); sessionStorageManager.setIsNewBestRecrd(true);
this.screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getAppHighestRecord()); // this.screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
}).bind(this) }).bind(this)
); );
@@ -179,8 +179,6 @@ var WhacAMole = {
goResult: function() { goResult: function() {
sessionStorageManager.setRecord(this.scoreManager.getScore()); sessionStorageManager.setRecord(this.scoreManager.getScore());
// if(sessionStorageManager.getRecord() > sessionStorageManager.getAppHighestRecord())
// sessionStorageManager.setAppHighestRecord(sessionStorageManager.getRecord());
location.href = '../../web/client/result.html'; location.href = '../../web/client/result.html';
}, },
@@ -109,7 +109,7 @@ function get_high_score_list($maestro_id, $player_id, $appList) {
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('iii', $app_id_list, $maestro_id, $player_id); $stmt->bind_param('iii', $app_id_list, $maestro_id, $player_id);
$stmt->execute(); $stmt->execute();
$stmt->bind_result($best_record); $stmt->bind_result($highest_record);
$returnValue = $stmt->fetch(); $returnValue = $stmt->fetch();
$stmt->close(); $stmt->close();
@@ -120,10 +120,10 @@ function get_high_score_list($maestro_id, $player_id, $appList) {
// $row_array['maestro_id'] = $maestro_id; // $row_array['maestro_id'] = $maestro_id;
// $row_array['player_id'] = $player_id; // $row_array['player_id'] = $player_id;
$row_array['AppID'] = $app_id_list; $row_array['AppID'] = $app_id_list;
if($best_record === NULL) if($highest_record === NULL)
$row_array['BestRecord'] = 0; $row_array['AppHighestRecord'] = 0;
else else
$row_array['BestRecord'] = $best_record; $row_array['AppHighestRecord'] = $highest_record;
array_push($return_array, $row_array); array_push($return_array, $row_array);
} }
@@ -101,15 +101,20 @@ function get_high_score_list($maestro_id, $player_id, $appList) {
$app_id_list = $appList[$i]['AppID']; $app_id_list = $appList[$i]['AppID'];
$query = " $query = "
SELECT MAX(BR.BestRecord) SELECT MAX(AHR.HighestRecord)
FROM app AS A FROM app AS A
INNER JOIN best_record AS BR INNER JOIN app_highest_record AS AHR
ON A.AppID = ? AND A.AppID = BR.AppID AND BR.MaestroID = ? AND BR.PlayerID = ? ON A.AppID = ? AND A.AppID = AHR.AppID AND AHR.MaestroID = ? AND AHR.PlayerID = ?
ORDER BY A.AppID ASC"; ORDER BY A.AppID ASC";
// SELECT MAX(BR.AppHighestRecord)
// FROM app AS A
// INNER JOIN best_record AS BR
// ON A.AppID = ? AND A.AppID = BR.AppID AND BR.MaestroID = ? AND BR.PlayerID = ?
// ORDER BY A.AppID ASC";
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('iii', $app_id_list, $maestro_id, $player_id); $stmt->bind_param('iii', $app_id_list, $maestro_id, $player_id);
$stmt->execute(); $stmt->execute();
$stmt->bind_result($best_record); $stmt->bind_result($highest_record);
$returnValue = $stmt->fetch(); $returnValue = $stmt->fetch();
$stmt->close(); $stmt->close();
@@ -120,10 +125,10 @@ function get_high_score_list($maestro_id, $player_id, $appList) {
// $row_array['maestro_id'] = $maestro_id; // $row_array['maestro_id'] = $maestro_id;
// $row_array['player_id'] = $player_id; // $row_array['player_id'] = $player_id;
$row_array['AppID'] = $app_id_list; $row_array['AppID'] = $app_id_list;
if($best_record === NULL) if($highest_record === NULL)
$row_array['BestRecord'] = 0; $row_array['AppHighestRecord'] = 0;
else else
$row_array['BestRecord'] = $best_record; $row_array['AppHighestRecord'] = $highest_record;
array_push($return_array, $row_array); array_push($return_array, $row_array);
} }
@@ -1,41 +0,0 @@
<?php
header('Content-Type: application/json');
$maestro_id = $_POST["MaestroID"];
$player_id = $_POST["PlayerID"];
$app_id = $_POST["AppID"];
include "./../setup/connect_db.php";
$replyJSON = array();
$replyJSON["BestRecord"] = get_best_record($maestro_id, $app_id, $player_id);
if($replyJSON.length === 0) {
send_error_message($replyJSON, "히스토리 기록 없음");
$db_conn->close();
exit;
}
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
function get_best_record($maestro_id, $app_id, $player_id) {
global $db_conn;
$query = "
SELECT BestRecord
FROM best_record
WHERE MaestroID = ? AND AppID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW())
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("iii", $maestro_id, $app_id, $player_id);
$stmt->execute();
$stmt->bind_result($best_record);
$stmt->fetch();
$stmt->close();
return $best_record;
}
?>
@@ -1,93 +0,0 @@
<?php
header('Content-Type: application/json');
$maestro_id = $_POST["MaestroID"];
$player_id = $_POST["PlayerID"];
$app_id = $_POST["AppID"];
$best_record = $_POST["BestRecord"];
// echo $best_record." / ";
include "./../setup/connect_db.php";
include "./../lib/app_highest_record.php";
$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;
if($prev_best_record_id === null || $prev_best_record_id < 0) {
// echo "insert";
insert_best_record($maestro_id, $app_id, $player_id, $best_record);
} else {
// echo $best_record." ".$prev_best_record;
if($best_record > $prev_best_record) {
// echo "update";
update_best_record($prev_best_record_id, $best_record);
}
}
$app_highest_record = get_app_highest_record($maestro_id, $app_id, $player_id);
if($app_highest_record == null) {
insert_app_highest_record($maestro_id, $app_id, $player_id, $best_record);
}
else if($best_record > $app_highest_record) {
remove_app_highest_record($maestro_id, $app_id, $player_id);
insert_app_highest_record($maestro_id, $app_id, $player_id, $best_record);
}
$db_conn->close();
function get_best_record($maestro_id, $app_id, $player_id) {
global $db_conn;
global $prev_best_record_id, $prev_best_record;
$query = "
SELECT BestRecordID, BestRecord
FROM best_record
WHERE MaestroID = ? AND AppID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW())
/*AND HOUR(RecordDateTime) = HOUR(NOW())*/
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("iii", $maestro_id, $app_id, $player_id);
$stmt->execute();
$stmt->bind_result($prev_best_record_id, $prev_best_record);
$stmt->fetch();
$stmt->close();
$GLOBALS["prev_best_record_id"] = $prev_best_record_id;
$GLOBALS["prev_best_record"] = $prev_best_record;
return $prev_best_record_id;
}
function insert_best_record($maestro_id, $app_id, $player_id, $best_record) {
global $db_conn;
$query = "
INSERT INTO best_record (MaestroID, PlayerID, AppID, BestRecord, RecordDateTime)
VALUES (?, ?, ?, ?, NOW());
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iiid', $maestro_id, $player_id, $app_id, $best_record);
$stmt->execute();
}
function update_best_record($prev_best_record_id, $best_record) {
global $db_conn;
$query = "
UPDATE best_record
SET BestRecord = ?, RecordDateTime = NOW()
WHERE BestRecordID = ? AND DATE(RecordDateTime) = DATE(NOW())
/* AND HOUR(RecordDateTime) = HOUR(NOW()) */
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('di', $best_record, $prev_best_record_id);
$stmt->execute();
}
?>