Fix: load how to play from server
This commit is contained in:
@@ -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" };
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -66,6 +66,7 @@ class MenuApp {
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = app.AppID;
|
||||
sessionStorageManager.playingAppName = app.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = app.AppKoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
}
|
||||
);
|
||||
|
||||
+19
-4
@@ -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;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<script src="../../../resources/js/phaser.min.js"></script>
|
||||
|
||||
<!-- global source files -->
|
||||
<script src="../../game/lib/app_info_manager.js"></script>
|
||||
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||
<script src="../../game/global/global_variables.js"></script>
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<script src="../../../resources/js/phaser.min.js"></script>
|
||||
|
||||
<!-- global source files -->
|
||||
<script src="../../game/lib/app_info_manager.js"></script>
|
||||
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||
<script src="../../game/global/global_variables.js"></script>
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<script src="../../../resources/js/phaser.min.js"></script>
|
||||
|
||||
<!-- global source files -->
|
||||
<script src="../../game/lib/app_info_manager.js"></script>
|
||||
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||
<script src="../../game/global/global_variables.js"></script>
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<script src="../../../resources/js/phaser.min.js"></script>
|
||||
|
||||
<!-- global source files -->
|
||||
<script src="../../game/lib/app_info_manager.js"></script>
|
||||
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||
<script src="../../game/global/global_variables.js"></script>
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<script src="../../../resources/js/phaser.min.js"></script>
|
||||
|
||||
<!-- global source files -->
|
||||
<script src="../../game/lib/app_info_manager.js"></script>
|
||||
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||
<script src="../../game/lib/score_manager.js"></script>
|
||||
<script src="../../game/lib/heart_manager.js"></script>
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<script src="../../../resources/js/phaser.min.js"></script>
|
||||
|
||||
<!-- global source files -->
|
||||
<script src="../../game/lib/app_info_manager.js"></script>
|
||||
<script src="../../game/lib/session_storage_manager.js"></script>
|
||||
<script src="../../game/global/global_variables.js"></script>
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "./../send_error_code.php";
|
||||
|
||||
$maestro_id = $_POST["maestro_id"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$replyJSON = get_active_app_list($maestro_id);
|
||||
$db_conn->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;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
include "./../send_error_code.php";
|
||||
|
||||
$maestro_id = $_POST["maestro_id"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$replyJSON = array();
|
||||
$replyJSON["AppList"] = get_app_list();
|
||||
$replyJSON["ActiveAppList"] = get_active_app_list($maestro_id);
|
||||
$db_conn->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)."<br />";
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "./../send_error_code.php";
|
||||
|
||||
$app_id = $_POST["AppID"];
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$replyJSON = array();
|
||||
$replyJSON["HowToPlay"] = get_how_to_play($app_id);
|
||||
if($replyJSON.length === 0) {
|
||||
send_error_message($replyJSON, "히스토리 기록 없음");
|
||||
$db_conn->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;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
<script src="../src/game/lib/string_util.js"></script>
|
||||
<script src="../src/game/lib/date_util.js"></script>
|
||||
<script src="../src/game/lib/app_info_manager.js"></script>
|
||||
<script src="../src/game/lib/session_storage_manager.js"></script>
|
||||
<script src="../src/game/global/global_variables.js"></script>
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user