diff --git a/src/game/global/global_variables.js b/src/game/global/global_variables.js
index c8b3a1c..7bb0d04 100644
--- a/src/game/global/global_variables.js
+++ b/src/game/global/global_variables.js
@@ -36,6 +36,7 @@ let sessionStorageManager = new SessionStorageManager();
console.log("playerUserID : " + sessionStorageManager.playerUserID);
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);
}
@@ -50,6 +51,4 @@ function isTypingGame() {
return true;
}
-let appInfoManager = new AppInfoManager();
-
let textStyleBasic = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
diff --git a/src/game/lib/db_connect_manager.js b/src/game/lib/db_connect_manager.js
index 9c0056b..bb909b1 100644
--- a/src/game/lib/db_connect_manager.js
+++ b/src/game/lib/db_connect_manager.js
@@ -102,7 +102,7 @@ class DBConnectManager {
requestMenuAppList(maestroID, onSucceededListener, onFailedListener) {
let xhr = new XMLHttpRequest();
- xhr.open("POST", this.phpPath + "server/app/menu_app_list.php", true);
+ xhr.open("POST", this.phpPath + "server/app/menu_active_app_list.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
@@ -119,7 +119,7 @@ class DBConnectManager {
requestTypingPracticeAppList(maestroID, onSucceededListener, onFailedListener) {
let xhr = new XMLHttpRequest();
- xhr.open("POST", this.phpPath + "server/app/active_typing_practice_app.php", true);
+ xhr.open("POST", this.phpPath + "server/app/active_typing_practice_app_list.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
@@ -335,6 +335,25 @@ class DBConnectManager {
return xhr;
}
+ requestHowToPlay(appID, onSucceededListener, onFailedListener) {
+ let xhr = new XMLHttpRequest();
+ xhr.open("POST", this.phpPath + "server/app/how_to_play.php", true);
+ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ xhr.onreadystatechange = function() {
+ if(xhr.readyState == 4 && xhr.status == 200) {
+ let replyJSON = JSON.parse(xhr.responseText);
+ console.log(replyJSON);
+ console.log(replyJSON["HowToPlay"]);
+
+ if(replyJSON != null && replyJSON["HowToPlay"] != null)
+ onSucceededListener(replyJSON);
+ else
+ onFailedListener(replyJSON);
+ }
+ };
+ xhr.send("AppID=" + appID);
+ }
+
loadTempPlayerHistory(historyRecordManager) {
diff --git a/src/game/lib/session_storage_manager.js b/src/game/lib/session_storage_manager.js
index 5aafffb..0c13916 100644
--- a/src/game/lib/session_storage_manager.js
+++ b/src/game/lib/session_storage_manager.js
@@ -51,6 +51,14 @@ class SessionStorageManager {
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);
diff --git a/src/game/menu/menu_app.js b/src/game/menu/menu_app.js
index 70eeea5..9b3a1ac 100644
--- a/src/game/menu/menu_app.js
+++ b/src/game/menu/menu_app.js
@@ -66,6 +66,7 @@ class MenuApp {
() => {
sessionStorageManager.playingAppID = app.AppID;
sessionStorageManager.playingAppName = app.AppName;
+ sessionStorageManager.playingAppKoreanName = app.AppKoreanName;
location.href = '../../web/client/start.html';
}
);
diff --git a/src/game/start/start.js b/src/game/start/start.js
index 510133e..2655c09 100644
--- a/src/game/start/start.js
+++ b/src/game/start/start.js
@@ -23,7 +23,8 @@ class Start {
// contents
- this.printHowToPlay(appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName));
+ // this.printHowToPlay(appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName));
+ this.loadHowToPlay(sessionStorageManager.playingAppID);
this.makeStartButton();
let today = new Date();
let date = DateUtil.getYYYYMMDD(today);
@@ -58,14 +59,28 @@ class Start {
let screenBottom = new ScreenBottom();
screenBottom.makeBottomLine();
screenBottom.printBottomLeftText("게임 진행 정보");
- let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
- screenBottom.printBottomCenterText(playingAppName);
+ let playingAppKoreanName = sessionStorageManager.playingAppKoreanName;
+ screenBottom.printBottomCenterText(playingAppKoreanName);
screenBottom.printBottomRightText(sessionStorageManager.playerName);
}
+ loadHowToPlay(appID) {
+ this.dbConnectManager.requestHowToPlay(
+ 101, // space_invaders app ID
+ (jsonData) => {
+ let howToPlay = jsonData["HowToPlay"].replace(/\\n/g, "\n");
+ this.printHowToPlay(howToPlay);
+ },
+ (jsonData) => {
+ this.printHowToPlay("No data");
+ }
+ );
+
+ }
+
printHowToPlay(text) {
const style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
- let howToPlayText = game.add.text(0, 0, appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName), style);
+ let howToPlayText = game.add.text(0, 0, text, style);
howToPlayText.setTextBounds(100, 100, game.world.width - 100, 200);
howToPlayText.stroke = "#333";
howToPlayText.strokeThickness = 5;
diff --git a/src/web/client/login.html b/src/web/client/login.html
index 9b2eafa..f0c2f2b 100644
--- a/src/web/client/login.html
+++ b/src/web/client/login.html
@@ -10,7 +10,6 @@
-
diff --git a/src/web/client/menu_app.html b/src/web/client/menu_app.html
index 720b65a..2bbf190 100644
--- a/src/web/client/menu_app.html
+++ b/src/web/client/menu_app.html
@@ -10,7 +10,6 @@
-
diff --git a/src/web/client/menu_typing_practice.html b/src/web/client/menu_typing_practice.html
index b3522d0..7c3e465 100644
--- a/src/web/client/menu_typing_practice.html
+++ b/src/web/client/menu_typing_practice.html
@@ -10,7 +10,6 @@
-
diff --git a/src/web/client/result.html b/src/web/client/result.html
index b3d7fb1..a6e5575 100644
--- a/src/web/client/result.html
+++ b/src/web/client/result.html
@@ -10,7 +10,6 @@
-
diff --git a/src/web/client/space_invaders.html b/src/web/client/space_invaders.html
index 707a4cb..b2f31cc 100644
--- a/src/web/client/space_invaders.html
+++ b/src/web/client/space_invaders.html
@@ -10,7 +10,6 @@
-
diff --git a/src/web/client/start.html b/src/web/client/start.html
index 0b762ed..933d8bf 100644
--- a/src/web/client/start.html
+++ b/src/web/client/start.html
@@ -10,7 +10,6 @@
-
diff --git a/src/web/server/app/active_app.php b/src/web/server/app/active_app.php
deleted file mode 100644
index 74b28e0..0000000
--- a/src/web/server/app/active_app.php
+++ /dev/null
@@ -1,49 +0,0 @@
-close();
-
-if($replyJSON.length === 0) {
- send_error_message($replyJSON, "앱 목록 가져오기 실패");
- $db_conn->close();
- exit;
-}
-
-echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
-$db_conn->close();
-
-
-
-function get_active_app_list($maestro_id) {
- global $db_conn;
-
- $query = "
- SELECT A.AppID, A.AppName, A.AppType
- FROM moty_app AS A
- INNER JOIN moty_active_app AS AA ON A.AppID = AA.AppID AND AA.MaestroID=?";
- $stmt = $db_conn->prepare($query);
- $stmt->bind_param('i', $maestro_id);
- $stmt->execute();
- $stmt->bind_result($app_id, $app_name, $app_type);
-
- $return_array = array();
- while($stmt->fetch()) {
- $row_array['AppID'] = $app_id;
- $row_array['AppName'] = $app_name;
- $row_array['AppType'] = $app_type;
- array_push($return_array, $row_array);
- }
- $stmt->close();
-
- return $return_array;
-}
-
-?>
\ No newline at end of file
diff --git a/src/web/server/app/active_typing_practice_app.php b/src/web/server/app/active_typing_practice_app_list.php
similarity index 100%
rename from src/web/server/app/active_typing_practice_app.php
rename to src/web/server/app/active_typing_practice_app_list.php
diff --git a/src/web/server/app/app_data.php b/src/web/server/app/app_data.php
deleted file mode 100644
index 23070ad..0000000
--- a/src/web/server/app/app_data.php
+++ /dev/null
@@ -1,72 +0,0 @@
-close();
-
-if($replyJSON.length === 0) {
- send_error_message($replyJSON, "앱 목록 가져오기 실패");
- $db_conn->close();
- exit;
-}
-
-echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
-$db_conn->close();
-
-
-
-function get_app_list() {
- global $db_conn;
-
- $query = "SELECT AppID, AppName, AppType FROM moty_app";
- $result = mysqli_query($db_conn, $query);
-
- $return_array = array();
- if ($result) {
- // echo "조회된 행의 수 : ".mysqli_num_rows($result)."
";
-
- $rows = array();
- while($row = mysqli_fetch_assoc($result)) {
- $row_array["AppID"] = $row["AppID"];
- $row_array["AppName"] = $row["AppName"];
- $row_array["AppType"] = $row["AppType"];
- array_push($return_array, $row_array);
- }
- }
-
- return $return_array;
-}
-
-function get_active_app_list($maestro_id) {
- global $db_conn;
-
- $query = "
- SELECT A.AppID, A.AppName, A.AppType
- FROM moty_app AS A
- INNER JOIN moty_active_app AS AA ON A.AppID = AA.AppID AND AA.MaestroID=?";
- $stmt = $db_conn->prepare($query);
- $stmt->bind_param("i", $maestro_id);
- $stmt->execute();
- $stmt->bind_result($app_id, $app_name, $app_type);
-
- $return_array = array();
- while($stmt->fetch()) {
- $row_array["AppID"] = $app_id;
- $row_array["AppName"] = $app_name;
- $row_array["AppType"] = $app_type;
- array_push($return_array, $row_array);
- }
- $stmt->close();
-
- return $return_array;
-}
-
-?>
\ No newline at end of file
diff --git a/src/web/server/app/how_to_play.php b/src/web/server/app/how_to_play.php
new file mode 100644
index 0000000..a6fcf63
--- /dev/null
+++ b/src/web/server/app/how_to_play.php
@@ -0,0 +1,41 @@
+close();
+ exit;
+}
+
+echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
+$db_conn->close();
+
+
+function get_how_to_play($app_id) {
+ global $db_conn;
+
+ $query = "
+ SELECT HowToPlay
+ FROM moty_app
+ WHERE AppID = ?;
+ ";
+ $stmt = $db_conn->prepare($query);
+ $stmt->bind_param('i', $app_id);
+ $stmt->execute();
+ $stmt->bind_result($how_to_play);
+ $stmt->fetch();
+ $stmt->close();
+
+ return $how_to_play;
+}
+
+?>
\ No newline at end of file
diff --git a/src/web/server/app/menu_app_list.php b/src/web/server/app/menu_active_app_list.php
similarity index 100%
rename from src/web/server/app/menu_app_list.php
rename to src/web/server/app/menu_active_app_list.php
diff --git a/test/db_connect_manager.html b/test/db_connect_manager.html
index 697614c..35d9e59 100644
--- a/test/db_connect_manager.html
+++ b/test/db_connect_manager.html
@@ -13,7 +13,6 @@
-
diff --git a/test/test_db_connect_manager.js b/test/test_db_connect_manager.js
index 84e58a9..f7587e3 100644
--- a/test/test_db_connect_manager.js
+++ b/test/test_db_connect_manager.js
@@ -26,7 +26,7 @@ QUnit.test( "User login", function( assert ) {
QUnit.test( "Player history", function( assert ) {
sessionStorageManager.maestroID = 1; // jisangs
sessionStorageManager.playerUserID = "8"; // 부현율
- sessionStorageManager.playingAppID = 9;
+ sessionStorageManager.playingAppID = 30;
let date = "2018-05-16";
let done = assert.async();
@@ -35,7 +35,7 @@ QUnit.test( "Player history", function( assert ) {
1, // maestroID for jisangs
date,
(historyRecordManager) => {
- console.log(historyRecordManager);
+ // console.log(historyRecordManager);
assert.equal(historyRecordManager.getAppNameAt(0), "korean_word");
assert.equal(historyRecordManager.getDateAt(0), "2018-05-14");
@@ -53,7 +53,7 @@ QUnit.test( "Player history", function( assert ) {
QUnit.test( "Player ranking", function( assert ) {
sessionStorageManager.maestroID = 1; // jisangs
- sessionStorageManager.playingAppID = 9;
+ sessionStorageManager.playingAppID = 30;
let date = "2018-05-16";
let time = "14:50:00";
@@ -126,3 +126,37 @@ QUnit.test( "Player ranking", function( assert ) {
});
});
+
+QUnit.test( "HowToPlay", function( assert ) {
+ let howToPlayForSpaceInvaders = "외계인이 나타났다!\\n마우스 왼쪽 버튼으로\\n외계인을 클릭해서 물리쳐 주세요.";
+
+ let done = assert.async(2);
+ setTimeout(function() {
+ dbConnectManager.requestHowToPlay(
+ 101, // space_invaders app ID
+ (jsonData) => {
+ howToPlay = jsonData["HowToPlay"];
+ assert.equal(howToPlay, howToPlayForSpaceInvaders);
+ done();
+ },
+ (jsonData) => {
+ console.log(jsonData);
+ done();
+ }
+ );
+
+ dbConnectManager.requestHowToPlay(
+ 1, // korean basic typing
+ (jsonData) => {
+ howToPlay = jsonData["HowToPlay"];
+ assert.equal(howToPlay, "");
+ done();
+ },
+ (jsonData) => {
+ console.log(jsonData);
+ done();
+ }
+ );
+ });
+});
+