Fix: requestAppRanking -> requestRanking

This commit is contained in:
2019-06-05 21:40:04 +09:00
parent e6d23dd61b
commit 936faef3bc
2 changed files with 142 additions and 84 deletions
+138 -82
View File
@@ -8,12 +8,17 @@ var Ranking = {
this.dbConnectManager = new DBConnectManager(); this.dbConnectManager = new DBConnectManager();
this.jsonData = null; this.jsonData = null;
this.mode = Ranking.MODE_HOUR; this.timeType = Ranking.MODE_HOUR;
this.refreshTimeSec = Ranking.REFRESH_TIME_SEC; this.refreshTimeSec = Ranking.REFRESH_TIME_SEC;
this.showingPageIndex = 0; this.showingPageIndex = 0;
this.dateTime = null;
this.date = "";
this.time = "";
this.recordArray = null; this.recordArray = null;
this.getDateTimeNow();
// bg // bg
this.game.stage.backgroundColor = '#4d4d4d'; this.game.stage.backgroundColor = '#4d4d4d';
@@ -53,7 +58,7 @@ var Ranking = {
// date time // date time
this.textDateTime = game.add.text( this.textDateTime = game.add.text(
GAME_SCREEN_SIZE.x / 2, 104, GAME_SCREEN_SIZE.x / 2, 104,
"2019년 06월 05일, 14시", this.getYYYYMMDDHHText(),
resultTextStyle resultTextStyle
); );
this.textDateTime.fontSize = 34; this.textDateTime.fontSize = 34;
@@ -245,39 +250,60 @@ var Ranking = {
return new RoundRectButton(setting, RoundRectButton.NONE_ICON, buttonText, eventListener); return new RoundRectButton(setting, RoundRectButton.NONE_ICON, buttonText, eventListener);
}, },
getDateTimeType: function() {
var dateTimeType = -1;
switch(this.timeType) {
case Ranking.MODE_HOUR:
dateTimeType = DBConnectManager.TYPE_MY_RANKING_HOUR;
break;
case Ranking.MODE_DAY:
dateTimeType = DBConnectManager.TYPE_MY_RANKING_DAY;
break;
case Ranking.MODE_MONTH:
dateTimeType = DBConnectManager.TYPE_MY_RANKING_MONTH;
break;
}
return dateTimeType;
},
getRecordToRankingServer: function() { getRecordToRankingServer: function() {
// console.log("getRecordToRankingServer : " + this.mode); this.dbConnectManager.requestRanking(
this.dbConnectManager.requestAppRanking( this.getDateTimeType(),
sessionStorageManager.getMaestroID(), sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayingAppID(), this.date,
(function(jsonData) { this.showRanking(jsonData); }).bind(this), this.time,
(function(jsonData) { this.showRanking(null); }).bind(this) (type, rankingRecordManager) => {
this.showRanking(rankingRecordManager);
}
); );
}, },
showRankingHour: function() { showRankingHour: function() {
this.mode = Ranking.MODE_HOUR; this.timeType = Ranking.MODE_HOUR;
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 수업시간 순위"; this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 수업시간 순위";
this.textTitle.addColor("#ff6666", 0); this.textTitle.addColor("#ff6666", 0);
this.getRecordToRankingServer(); this.getRecordToRankingServer();
}, },
showRankingDay: function() { showRankingDay: function() {
this.mode = Ranking.MODE_DAY; this.timeType = Ranking.MODE_DAY;
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 오늘의 순위"; this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 오늘의 순위";
this.textTitle.addColor("#9999ff", 0); this.textTitle.addColor("#9999ff", 0);
this.getRecordToRankingServer(); this.getRecordToRankingServer();
}, },
showRankingMonth: function() { showRankingMonth: function() {
this.mode = Ranking.MODE_MONTH; this.timeType = Ranking.MODE_MONTH;
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 이달의 순위"; this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 이달의 순위";
this.textTitle.addColor("#99ff99", 0); this.textTitle.addColor("#99ff99", 0);
this.getRecordToRankingServer(); this.getRecordToRankingServer();
}, },
showRanking: function(jsonRankingData) { showRanking: function(rankingRecordManager) {
// console.log(jsonRankingData); // console.log(rankingRecordManager);
if(sessionStorageManager.getMaestroAccountType() == 101) { if(sessionStorageManager.getMaestroAccountType() == 101) {
this.recordArray = this.getDummyRankList(); this.recordArray = this.getDummyRankList();
@@ -286,7 +312,7 @@ var Ranking = {
return; return;
} }
if(jsonRankingData === null) { if(rankingRecordManager.rankingRecords.length === 0) {
var rankEmpty = [ ]; var rankEmpty = [ ];
this.textRanking1to10.parseList(rankEmpty); this.textRanking1to10.parseList(rankEmpty);
this.textRanking11to20.parseList(rankEmpty); this.textRanking11to20.parseList(rankEmpty);
@@ -294,23 +320,22 @@ var Ranking = {
return; return;
} }
var jsonRankingList = null; var rankingListCount = rankingRecordManager.rankingRecords.length;
if(this.mode === Ranking.MODE_HOUR) this.recordArray = [];
jsonRankingList = jsonRankingData.rankingHour; for(var i = 0; i < rankingListCount; i++) {
else if(this.mode === Ranking.MODE_DAY) var bestRecordRow = [];
jsonRankingList = jsonRankingData.rankingDay; // bestRecordRow[0] = jsonRankingList[i]['UserID'];
else if(this.mode === Ranking.MODE_MONTH) bestRecordRow[0] = i + 1;
jsonRankingList = jsonRankingData.rankingMonth; bestRecordRow[1] = rankingRecordManager.rankingRecords[i]['playerName'];
bestRecordRow[2] = RecordUtil.getRecordValueWithUnit(
rankingRecordManager.rankingRecords[i]['bestRecord'],
sessionStorageManager.getPlayingAppID()
);
// console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
if(jsonRankingList === null) { this.recordArray.push(bestRecordRow);
var rankEmpty = [ ];
this.textRanking1to10.parseList(rankEmpty);
this.textRanking11to20.parseList(rankEmpty);
return;
} }
this.recordArray = this.getRankingArrayFromJSON(jsonRankingList);
this.printRanking(); this.printRanking();
}, },
@@ -323,6 +348,7 @@ var Ranking = {
if(this.showingPageIndex * 20 > this.recordArray.length) if(this.showingPageIndex * 20 > this.recordArray.length)
this.showingPageIndex = 0; this.showingPageIndex = 0;
// prepare ranking list - top10 / top20
for(var i = 0; i < 10; i++) { for(var i = 0; i < 10; i++) {
var index = this.showingPageIndex * 20 + i; var index = this.showingPageIndex * 20 + i;
if(index < this.recordArray.length) if(index < this.recordArray.length)
@@ -330,9 +356,22 @@ var Ranking = {
if(index + 10 < this.recordArray.length) if(index + 10 < this.recordArray.length)
recordTop20.push(this.recordArray[index + 10]); recordTop20.push(this.recordArray[index + 10]);
} }
// print
this.textRanking1to10.parseList(recordTop10); this.textRanking1to10.parseList(recordTop10);
this.textRanking11to20.parseList(recordTop20); this.textRanking11to20.parseList(recordTop20);
this.updateRankingNavigationButtons();
},
updateRankingNavigationButtons: function() {
// console.log(this.recordArray);
if(this.recordArray == null) {
this.buttonPrevRanking.text.text = "X";
this.buttonNextRanking.text.text = "X";
return;
}
if(this.showingPageIndex > 0) if(this.showingPageIndex > 0)
this.buttonPrevRanking.text.text = "<"; this.buttonPrevRanking.text.text = "<";
else else
@@ -344,69 +383,83 @@ var Ranking = {
this.buttonNextRanking.text.text = "X"; this.buttonNextRanking.text.text = "X";
}, },
getRankingArrayFromJSON: function(jsonRankingList) {
if(isDebugMode())
return this.getDummyRankList();
var rankingListCount = jsonRankingList.length;
var recordArray = [];
for(var i = 0; i < rankingListCount; i++) {
var bestRecordRow = [];
// bestRecordRow[0] = jsonRankingList[i]['UserID'];
bestRecordRow[0] = i + 1;
bestRecordRow[1] = jsonRankingList[i]['Name'];
bestRecordRow[2] = RecordUtil.getRecordValueWithUnit(
jsonRankingList[i]['BestRecord'],
sessionStorageManager.getPlayingAppID()
);
// console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
recordArray.push(bestRecordRow);
}
return recordArray;
},
getDummyRankList: function() { getDummyRankList: function() {
var dummyRankList = [ var dummyRankList = [
[ '1', 'test1', '400' ], [ '1', 'test1', '600' ],
[ '2', 'test2', '300' ], [ '2', 'test2', '500' ],
[ '3', 'test3', '200' ], [ '3', 'test3', '450' ],
[ '4', 'test4', '100' ], [ '4', 'test4', '400' ],
[ '5', 'test5', '90' ], [ '5', 'test5', '350' ],
[ '6', 'test6', '80' ], [ '6', 'test6', '300' ],
[ '7', 'test7', '70' ], [ '7', 'test7', '250' ],
[ '8', 'test8', '60' ], [ '8', 'test8', '200' ],
[ '9', 'test9', '50' ], [ '9', 'test9', '150' ],
[ '10', 'test10', '40' ], [ '10', 'test10', '100' ],
[ '11', 'test11', '30' ], [ '11', 'test11', '90' ],
[ '12', 'test12', '20' ], [ '12', 'test12', '80' ],
[ '13', 'test13', '10' ], [ '13', 'test13', '70' ],
[ '14', 'test14', '9' ], [ '14', 'test14', '60' ],
[ '15', 'test15', '8' ], [ '15', 'test15', '50' ],
[ '16', 'test16', '7' ], [ '16', 'test16', '45' ],
[ '17', 'test17', '6' ], [ '17', 'test17', '40' ],
[ '18', 'test18', '5' ], [ '18', 'test18', '35' ],
[ '19', 'test19', '4' ], [ '19', 'test19', '30' ],
[ '20', 'test20', '3' ], [ '20', 'test20', '25' ],
[ '21', 'test21', '2' ], [ '21', 'test21', '20' ],
[ '22', 'test22', '1' ], [ '22', 'test22', '15' ],
[ '23', 'test23', '1' ], [ '23', 'test23', '10' ],
[ '24', 'test24', '1' ], [ '24', 'test24', '9' ],
[ '25', 'test25', '1' ], [ '25', 'test25', '8' ],
[ '26', 'test26', '1' ], [ '26', 'test26', '7' ],
[ '27', 'test27', '1' ], [ '27', 'test27', '6' ],
[ '28', 'test28', '1' ], [ '28', 'test28', '5' ],
[ '29', 'test29', '1' ], [ '29', 'test29', '4' ],
[ '30', 'test30', '1' ], [ '30', 'test30', '3' ],
[ '31', 'test31', '1' ], [ '31', 'test31', '2' ],
[ '32', 'test32', '1' ], [ '32', 'test32', '1' ],
]; ];
return dummyRankList; return dummyRankList;
}, },
getDateTimeNow: function() {
var now = new Date();
var hourTimeText = DateUtil.getYYYYMMDD(now) + "T" + now.getHours() + ":00:00";
this.dateTime = new Date(hourTimeText);
this.date = DateUtil.getYYYYMMDD(this.dateTime);
this.time = DateUtil.getHHMMSS(this.dateTime);
if(runMode == MODE_DEBUG) {
this.date = "2018-08-23";
this.time = "15:53:00";
this.dateTime = new Date(this.date + "T" + this.time);
}
},
increaseDateTime: function() {
},
decreaseDateTime: function() {
},
getDatetimeHour: function() {
return this.dateTime.getHours();
},
getDatetimeHourWith2Digits: function() {
return ("0" + this.dateTime.getHours()).slice(-2);
},
getYYYYMMDDHHText: function() {
return DateUtil.getFullYear(this.dateTime) + "년 "
+ DateUtil.getFullMonth(this.dateTime) + "월 "
+ DateUtil.getFullDate(this.dateTime) + "일, "
+ DateUtil.getFullHours(this.dateTime) + "시"
},
onClickPrevRanking: function() { onClickPrevRanking: function() {
if(this.recordArray == null)
return;
this.showingPageIndex--; this.showingPageIndex--;
if(this.showingPageIndex < 0) if(this.showingPageIndex < 0)
this.showingPageIndex = 0; this.showingPageIndex = 0;
@@ -415,6 +468,9 @@ var Ranking = {
}, },
onClickNextRanking: function() { onClickNextRanking: function() {
if(this.recordArray == null)
return;
if((this.showingPageIndex + 1) * 20 < this.recordArray.length) if((this.showingPageIndex + 1) * 20 < this.recordArray.length)
this.showingPageIndex++; this.showingPageIndex++;
this.printRanking(); this.printRanking();
+4 -2
View File
@@ -40,6 +40,7 @@
<script src="../../game/lib/global/global_variables.js?update_date=191224"></script> <script src="../../game/lib/global/global_variables.js?update_date=191224"></script>
<!-- library source files --> <!-- library source files -->
<script src="../../game/lib/util/date_util.js"></script>
<script src="../../game/lib/util/number_util.js"></script> <script src="../../game/lib/util/number_util.js"></script>
<script src="../../game/lib/util/string_util.js"></script> <script src="../../game/lib/util/string_util.js"></script>
<script src="../../game/lib/util/record_util.js"></script> <script src="../../game/lib/util/record_util.js"></script>
@@ -50,12 +51,13 @@
<script src="../../game/lib/text/screen_bottom_ui.js?update_date=191224"></script> <script src="../../game/lib/text/screen_bottom_ui.js?update_date=191224"></script>
<script src="../../game/lib/keyboard_shortcut.js"></script> <script src="../../game/lib/keyboard_shortcut.js"></script>
<script src="../../game/lib/history_record_manager.js"></script> <script src="../../game/lib/ranking_record_manager.js"></script>
<!-- <script src="../../game/lib/history_record_manager.js"></script> -->
<script src="../../game/lib/button/round_rect_button.js"></script> <script src="../../game/lib/button/round_rect_button.js"></script>
<script src="../../game/lib/button/back_button.js"></script> <script src="../../game/lib/button/back_button.js"></script>
<script src="../../game/lib/button/fullscreen_button.js"></script> <script src="../../game/lib/button/fullscreen_button.js"></script>
<script src="../../game/lib/db_connect_manager.js"></script> <script src="../../game/lib/db_connect_manager.js"></script>
<script src="../../game/typing/lib/animal.js"></script> <!-- <script src="../../game/typing/lib/animal.js"></script> -->
<!-- Ranking : source files --> <!-- Ranking : source files -->