Fix: restructing sessionManager (incompleted)

This commit is contained in:
2018-09-14 11:58:50 +09:00
parent 1a2d9e6800
commit 72e7c1a28f
6 changed files with 157 additions and 45 deletions
+20 -20
View File
@@ -3,7 +3,7 @@ const LANGUAGE_ENGLISH = "english";
const MODE_RELEASE = "release";
const MODE_DEBUG = "debug";
const runMode = MODE_DEBUG;
const runMode = MODE_RELEASE;
function isDebugMode() {
// console.log("debug mode ? " + runMode);
@@ -23,19 +23,19 @@ const GAME_SCREEN_SIZE = { x: 1024, y: 768 }
let sessionStorageManager = new SessionStorageManager();
{
if(isDebugMode()) {
console.log("maestroID : " + sessionStorageManager.maestroID);
console.log("maestroAccountType : " + sessionStorageManager.maestroAccountType);
console.log("playerName : " + sessionStorageManager.playerName);
console.log("playerID : " + sessionStorageManager.playerID);
console.log("playerAccountType : " + sessionStorageManager.playerAccountType);
console.log("playingAppID : " + sessionStorageManager.playingAppID);
console.log("playingAppName : " + sessionStorageManager.playingAppName);
console.log("playingAppKoreanName : " + sessionStorageManager.playingAppKoreanName);
console.log("record : " + sessionStorageManager.record);
console.log("bestRecord : " + sessionStorageManager.bestRecord);
console.log("maestroID : " + sessionStorageManager.getMaestroID());
console.log("maestroAccountType : " + sessionStorageManager.getMaestroAccountType());
console.log("playerName : " + sessionStorageManager.getPlayerName());
console.log("playerID : " + sessionStorageManager.getPlayerID());
console.log("playerAccountType : " + sessionStorageManager.getPlayerAccountType());
console.log("playingAppID : " + sessionStorageManager.getPlayingAppID());
console.log("playingAppName : " + sessionStorageManager.getPlayingAppName());
console.log("playingAppKoreanName : " + sessionStorageManager.getPlayingAppKoreanName());
console.log("record : " + sessionStorageManager.getRecord());
console.log("bestRecord : " + sessionStorageManager.getBestRecord());
}
if(sessionStorageManager.maestroID === null && !isLogin()) {
if(sessionStorageManager.getMaestroID() === null && !isLogin()) {
goLogin();
}
}
@@ -52,17 +52,17 @@ function goLogin() {
}
function isTypingGame() {
if(sessionStorageManager.playingAppName === null)
if(sessionStorageManager.getPlayingAppName() === null)
return false;
if(sessionStorageManager.playingAppName.indexOf("typing") < 0)
if(sessionStorageManager.getPlayingAppName().indexOf("typing") < 0)
return false;
return true;
}
function isTypingPracticeStage() {
let appName = sessionStorageManager.playingAppName;
let appName = sessionStorageManager.getPlayingAppName();
if(appName.indexOf("practice_") > -1)
return true;
@@ -71,7 +71,7 @@ function isTypingPracticeStage() {
}
function isTypingTestStage() {
let appName = sessionStorageManager.playingAppName;
let appName = sessionStorageManager.getPlayingAppName();
if(appName.indexOf("test_") > -1)
return true;
@@ -80,21 +80,21 @@ function isTypingTestStage() {
}
function isEnglishTypingStage() {
if(sessionStorageManager.playingAppName.indexOf("english") > -1)
if(sessionStorageManager.getPlayingAppName().indexOf("english") > -1)
return true;
return false;
}
function isKoreanTypingStage() {
if(sessionStorageManager.playingAppName.indexOf("korean") > -1)
if(sessionStorageManager.getPlayingAppName().indexOf("korean") > -1)
return true;
return false;
}
function isTypingWordStage() {
let appName = sessionStorageManager.playingAppName;
let appName = sessionStorageManager.getPlayingAppName();
if(appName.indexOf("_word") > -1)
return true;
@@ -106,7 +106,7 @@ function isTypingWordStage() {
}
function isTypingSentenceStage() {
let appName = sessionStorageManager.playingAppName;
let appName = sessionStorageManager.getPlayingAppName();
if(appName.indexOf("_sentence") > -1)
return true;
+3 -3
View File
@@ -79,9 +79,9 @@ function GameAppButton(x, y, type, iconName, buttonText, appInfo) {
GameAppButton.prototype.clickEvent = function() {
sessionStorageManager.playingAppID = this.appInfo.AppID;
sessionStorageManager.playingAppName = this.appInfo.AppName;
sessionStorageManager.playingAppKoreanName = this.appInfo.KoreanName;
sessionStorageManager.getPlayingAppID() = this.appInfo.AppID;
sessionStorageManager.getPlayingAppName() = this.appInfo.AppName;
sessionStorageManager.getPlayingAppKoreanName() = this.appInfo.KoreanName;
location.href = '../../web/client/start.html';
}
+3 -3
View File
@@ -98,9 +98,9 @@ function TypingAppButton(type, x, y, iconName, buttonText, appInfo) {
}
TypingAppButton.prototype.clickEvent = function() {
sessionStorageManager.playingAppID = this.appInfo.AppID;
sessionStorageManager.playingAppName = this.appInfo.AppName;
sessionStorageManager.playingAppKoreanName = this.appInfo.KoreanName;
sessionStorageManager.setPlayingAppID(this.appInfo.AppID);
sessionStorageManager.setPlayingAppName(this.appInfo.AppName);
sessionStorageManager.setPlayingAppKoreanName(this.appInfo.KoreanName);
location.href = '../../web/client/start.html';
}
+113 -1
View File
@@ -1,3 +1,114 @@
function SessionStorageManager() {
}
SessionStorageManager.prototype.clear = function() {
sessionStorage.clear();
}
SessionStorageManager.prototype.removeItem = function(key) {
return sessionStorage.removeItem(key);
}
// maestro ID
SessionStorageManager.prototype.setMaestroID = function(value) {
sessionStorage.setItem("maestroID", value);
}
SessionStorageManager.prototype.getMaestroID = function() {
return sessionStorage.getItem("maestroID");
}
// maestro account type
SessionStorageManager.prototype.setMaestroAccountType = function(value) {
sessionStorage.setItem("maestroAccountType", value);
}
SessionStorageManager.prototype.getMaestroAccountType = function() {
return sessionStorage.getItem("maestroAccountType");
}
// player name
SessionStorageManager.prototype.setPlayerName = function(value) {
sessionStorage.setItem("playerName", value);
}
SessionStorageManager.prototype.getPlayerName = function() {
return sessionStorage.getItem("playerName");
}
// player player ID
SessionStorageManager.prototype.setPlayerID = function(value) {
sessionStorage.setItem("playerID", value);
}
SessionStorageManager.prototype.getPlayerID = function() {
return sessionStorage.getItem("playerID");
}
// player account type
SessionStorageManager.prototype.setPlayerAccountType = function(value) {
sessionStorage.setItem("playerAccountType", value);
}
SessionStorageManager.prototype.getPlayerAccountType = function() {
return sessionStorage.getItem("playerAccountType");
}
// playing app id
SessionStorageManager.prototype.setPlayingAppID = function(value) {
sessionStorage.setItem("playingAppID", value);
}
SessionStorageManager.prototype.getPlayingAppID = function() {
return sessionStorage.getItem("playingAppID");
}
// playing app name
SessionStorageManager.prototype.setPlayingAppName = function(value) {
sessionStorage.setItem("playingAppName", value);
}
SessionStorageManager.prototype.getPlayingAppName = function() {
return sessionStorage.getItem("playingAppName");
}
// playing app korean name
SessionStorageManager.prototype.setPlayingAppKoreanName = function(value) {
sessionStorage.setItem("playingAppKoreanName", value);
}
SessionStorageManager.prototype.getPlayingAppKoreanName = function() {
return sessionStorage.getItem("playingAppKoreanName");
}
// record
SessionStorageManager.prototype.setRecord = function(value) {
sessionStorage.setItem("record", value);
}
SessionStorageManager.prototype.getRecord = function() {
return sessionStorage.getItem("record");
}
// best record
SessionStorageManager.prototype.setBestRecord = function(value) {
sessionStorage.setItem("bestRecord", value);
}
SessionStorageManager.prototype.getBestRecord = function() {
return sessionStorage.getItem("bestRecord");
}
// best record
SessionStorageManager.prototype.setIsNewBestRecord = function(value) {
sessionStorage.setItem("isNewBestRecord", value);
}
SessionStorageManager.prototype.getIsNewBestRecord = function() {
return sessionStorage.getItem("isNewBestRecord");
}
SessionStorageManager.prototype.resetPlayingAppData = function() {
this.removeItem(playingAppID);
this.removeItem(playingAppName);
this.removeItem(playingAppKoreanName);
this.removeItem(record);
this.removeItem(bestRecord);
}
/*
class SessionStorageManager {
constructor() {
@@ -108,4 +219,5 @@ class SessionStorageManager {
}
}
}
*/
+3 -3
View File
@@ -47,9 +47,9 @@ var MenuApp = {
// var playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
// ScreenBottomUI.printCenterText(playingAppName);
screenBottomUI.printCenterText("메뉴");
screenBottomUI.printRightText(sessionStorageManager.playerName);
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
new WelcomePlayerText(sessionStorageManager.playerName);
new WelcomePlayerText(sessionStorageManager.getPlayerName());
this.loadAppData();
@@ -60,7 +60,7 @@ var MenuApp = {
loadAppData: function() {
var dbConnectManager = new DBConnectManager();
dbConnectManager.requestMenuAppList(
sessionStorageManager.maestroID,
sessionStorageManager.getMaestroID(),
(function(replyJSON) {
this.loadSucceeded(replyJSON);
}).bind(this),
+15 -15
View File
@@ -31,11 +31,11 @@ class Start {
// contents
this.loadHowToPlay(sessionStorageManager.playingAppID);
this.loadHowToPlay(sessionStorageManager.getPlayingAppID());
this.makeStartButton();
this.makeRankingButton();
if(sessionStorageManager.maestroAccountType >= 100) { // experience account
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
this.printSampleChart();
this.announceBox = new AnnounceBox(50, 648);
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
@@ -47,27 +47,27 @@ class Start {
// bottom ui
var screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftText("오늘의 최고 기록 : ");
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
screenBottomUI.printRightText(sessionStorageManager.playerName);
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
this.dbConnectManager.requestTodayBestRecord(
sessionStorageManager.maestroID,
sessionStorageManager.playerID,
sessionStorageManager.playingAppID,
sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayerID(),
sessionStorageManager.getPlayingAppID(),
(function(replyJSON) {
sessionStorageManager.bestRecord = Number(replyJSON["BestRecord"]);
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
sessionStorageManager.getBestRecord() = Number(replyJSON["BestRecord"]);
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
}).bind(this),
(function(replyJSON) { // no data
sessionStorageManager.bestRecord = 0;
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
sessionStorageManager.getBestRecord() = 0;
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
}).bind(this)
);
}
loadHowToPlay(appID) {
this.dbConnectManager.requestHowToPlay(
sessionStorageManager.playingAppID, // space_invaders app ID
sessionStorageManager.getPlayingAppID(), // space_invaders app ID
(function(jsonData) {
var howToPlayText = jsonData["HowToPlay"].replace(/\\n/g, "\n");
this.howToPlay.printHowToPlay(howToPlayText);
@@ -83,7 +83,7 @@ class Start {
var today = new Date();
var date = DateUtil.getYYYYMMDD(today);
this.dbConnectManager.requestPlayerHistory(
sessionStorageManager.maestroID,
sessionStorageManager.getMaestroID(),
date,
(function(historyRecordManager) {
if(historyRecordManager.count == 0) {
@@ -158,7 +158,7 @@ class Start {
location.href = '../../web/client/ranking.html';
})
);
if(sessionStorageManager.maestroAccountType == 100)
if(sessionStorageManager.getMaestroAccountType() == 100)
rankingButton.inputEnabled = false;
}
@@ -169,7 +169,7 @@ class Start {
else if(isTypingTestStage())
location.href = "../../web/client/typing_test.html";
else
location.href = "../../web/client/" + sessionStorageManager.playingAppName + ".html";
location.href = "../../web/client/" + sessionStorageManager.getPlayingAppName() + ".html";
}
}