///////////////////////////// // History board class HistoryBoard { constructor() { this.dbConnectManager = new DBConnectManager(); let arrayTabStyle = { font: "20px Arial", fill: "#fff", align: "left", tabs: [ 40, 80, 120 ] }; let posX = 40; let posY = game.world.height / 2 - 10; this.textMyRanking = game.add.text(posX, posY + 100, '', arrayTabStyle) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); let today = new Date(); let date = DateUtil.getYYYYMMDD(today); this.dbConnectManager.requestPlayerHistory( sessionStorageManager.maestroID, date, historyRecordManager => { if(historyRecordManager.count == 0) { console.log("history board - no data"); return; } for(let i = 0; i < historyRecordManager.count; i++) { let data = historyRecordManager.getAt(i); this.printRecord(i, data.date, data.bestRecord); } } ); } printRecord(index, date, bestRecord) { if(sessionStorageManager.playingAppName.indexOf("typing") < 0) this.printMouseAppHistory(index, date, bestRecord); else this.printTypingAppHistory(index, date, appName, bestRecord); } printMouseAppHistory(index, date, bestRecord) { let posX = 60; let posY = game.world.height / 2 + 90 + 30 * index; var style = { font: "20px Arial", fill: "#ffc", align: "right", boundsAlignH: "right", boundsAlignV: "top" }; style.boundsAlignH = "center"; game.add.text(posX, posY, StringUtil.printMonthDay(date), style) .setTextBounds(0, 0, 100, 60) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); style.boundsAlignH = "right"; game.add.text(posX + 80, posY, StringUtil.getRecordTextWithoutUnit(bestRecord), style) .setTextBounds(0, 0, 100, 60) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); } printTypingAppHistory(index, date, appName, bestRecord) { let posX = 60; let posY = game.world.height / 2 + 90 + 30 * index; var style = { font: "20px Arial", fill: "#ffc", align: "right", boundsAlignH: "right", boundsAlignV: "top" }; style.boundsAlignH = "center"; game.add.text(posX, posY, date, style) .setTextBounds(0, 0, 40, 40) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); game.add.text(posX + 60, posY, appName, style) .setTextBounds(0, 0, 60, 60) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); style.boundsAlignH = "right"; game.add.text(posX + 120, posY, StringUtil.getRecordTextWithoutUnit(bestRecord), style) .setTextBounds(0, 0, 80, 60) .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); } }