Add: RankingRecordManager
This commit is contained in:
@@ -1,38 +1,76 @@
|
||||
class DBConnectManager {
|
||||
|
||||
constructor() {
|
||||
this.maestroID = 0;
|
||||
this.playerUserID = 0;
|
||||
this.appName = "";
|
||||
}
|
||||
|
||||
requestMyHistory(appName) {
|
||||
|
||||
setMaestro(maestroID) {
|
||||
this.maestroID = maestroID;
|
||||
}
|
||||
|
||||
requestRankingHour(appName) {
|
||||
|
||||
setPlayer(userID) {
|
||||
this.playerUserID = userID;
|
||||
}
|
||||
|
||||
requestRankingDay(appName) {
|
||||
|
||||
setAppName(appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
requestRankingMonth(appName) {
|
||||
|
||||
requestMyHistory(listener) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
listener(historyRecordManager);
|
||||
}
|
||||
|
||||
requestRankingHour(listener) {
|
||||
this.requestRanking(type, listener);
|
||||
}
|
||||
|
||||
requestRankingDay(listener) {
|
||||
this.requestRanking(type, listener);
|
||||
}
|
||||
|
||||
requestRankingMonth(listener) {
|
||||
this.requestRanking(type, listener);
|
||||
}
|
||||
|
||||
requestAllRankingHour(listener) {
|
||||
this.requestRanking(type, listener);
|
||||
}
|
||||
|
||||
requestAllRankingDay(listener) {
|
||||
this.requestRanking(type, listener);
|
||||
}
|
||||
|
||||
requestAllRankingMonth(listener) {
|
||||
this.requestRanking(type, listener);
|
||||
}
|
||||
|
||||
requestRanking(type, listener) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
listener(rankingRecordManager);
|
||||
}
|
||||
|
||||
|
||||
requestTempMyHistory() {
|
||||
this.historyRecordManager.clear();
|
||||
requestTempMyHistory(listener) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
this.historyRecordManager.push(new HistoryRecordData("05/10", 15460));
|
||||
this.historyRecordManager.push(new HistoryRecordData("05/11", 3040));
|
||||
this.historyRecordManager.push(new HistoryRecordData("05/12", 460));
|
||||
this.historyRecordManager.push(new HistoryRecordData("05/13", 60));
|
||||
this.historyRecordManager.push(new HistoryRecordData("05/14", 8));
|
||||
historyRecordManager.push(new HistoryRecord("05/10", "space_invaders", 15460));
|
||||
historyRecordManager.push(new HistoryRecord("05/11", "typing_korean_basic", 3040));
|
||||
historyRecordManager.push(new HistoryRecord("05/12", "typing_english_basic", 460));
|
||||
historyRecordManager.push(new HistoryRecord("05/13", "space_invaders", 60));
|
||||
historyRecordManager.push(new HistoryRecord("05/14", "space_invaders", 8));
|
||||
|
||||
this.printHistoryRecords();
|
||||
if(listener === null)
|
||||
return;
|
||||
|
||||
listener(historyRecordManager);
|
||||
}
|
||||
|
||||
requestTempRanking() {
|
||||
requestTempRanking(userID, appName, rankingRecordManager, listener) {
|
||||
let jsonRankingList = [
|
||||
{ "UserID":"17", "Name":"강경모", "BestRecord":"4400" },
|
||||
{ "UserID":"2", "Name":"강성태", "BestRecord":"3400" },
|
||||
@@ -52,7 +90,10 @@ class DBConnectManager {
|
||||
{ "UserID":"16", "Name":"하하하", "BestRecord":"4" },
|
||||
];
|
||||
|
||||
return jsonRankingList;
|
||||
if(listener === null)
|
||||
return;
|
||||
|
||||
listener();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
class HistoryRecord {
|
||||
|
||||
constructor(date, score) {
|
||||
constructor(date, appName, score) {
|
||||
this.date = date;
|
||||
this.appName = appName;
|
||||
this.score = score;
|
||||
}
|
||||
}
|
||||
@@ -40,6 +41,10 @@ class HistoryRecordManager {
|
||||
return this.historyRecords[index].date;
|
||||
}
|
||||
|
||||
getAppNameAt(index) {
|
||||
return this.historyRecords[index].appName;
|
||||
}
|
||||
|
||||
getScoreAt(index) {
|
||||
return this.historyRecords[index].score;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
class RankingRecord {
|
||||
|
||||
constructor(rank, userName, score) {
|
||||
this.rank = rank;
|
||||
this.userName = userName;
|
||||
this.score = score;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class RankingRecordManager {
|
||||
|
||||
constructor() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
push(RankingRecord) {
|
||||
this.rankingRecords.push(RankingRecord);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.rankingRecords = [];
|
||||
|
||||
this.minValueOfRecord = 0;
|
||||
this.maxValueOfRecord = 0;
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this.rankingRecords.length;
|
||||
}
|
||||
|
||||
getAt(index) {
|
||||
return this.rankingRecords[index];
|
||||
}
|
||||
|
||||
getRankAt(index) {
|
||||
return this.rankingRecords[index].rank;
|
||||
}
|
||||
|
||||
getUserNameAt(index) {
|
||||
return this.rankingRecords[index].userName;
|
||||
}
|
||||
|
||||
getScoreAt(index) {
|
||||
return this.rankingRecords[index].score;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,14 @@ class SessionStorageManager {
|
||||
return sessionStorage.removeItem(key);
|
||||
}
|
||||
|
||||
// maestro user ID
|
||||
set maestroID(value) {
|
||||
sessionStorage.setItem("maestroID", value);
|
||||
}
|
||||
get maestroID() {
|
||||
return sessionStorage.getItem("maestroID");
|
||||
}
|
||||
|
||||
// player name
|
||||
set playerName(value) {
|
||||
sessionStorage.setItem("playerName", value);
|
||||
|
||||
Reference in New Issue
Block a user