Add: get player enter_code from server
This commit is contained in:
@@ -62,6 +62,23 @@ DBConnectManager.prototype.requestCheckPlayerLogin = function(maestroName, playe
|
||||
xhr.send("maestro_name=" + maestroName + "&name=" + playerName + "&enter_code=" + enterCode);
|
||||
}
|
||||
|
||||
DBConnectManager.prototype.requestPlayerEnterCode = function(maestroID, playerID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/player/get_entercode.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null && replyJSON["EnterCode"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
|
||||
}
|
||||
|
||||
/*
|
||||
DBConnectManager.prototype.requestAppList = function(maestroID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
+47
-53
@@ -35,7 +35,7 @@ var Setup = {
|
||||
this.makePrevEnterCodeText(textX, 300);
|
||||
this.makeNewEnterCodeInput(textX, 360);
|
||||
|
||||
this.makeCheckEnterCodeButton(game.world.centerX, game.world.centerY + 100);
|
||||
this.startButton = this.makeCheckEnterCodeButton(game.world.centerX, game.world.centerY + 100);
|
||||
/*
|
||||
this.makeMaestroNameText(textX, 200);
|
||||
this.makeNameText(textX, 300);
|
||||
@@ -69,6 +69,8 @@ var Setup = {
|
||||
// ScreenBottomUI.printCenterText(playingAppName);
|
||||
screenBottomUI.printCenterText("설정");
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
this.loadPrevEnterCode();
|
||||
},
|
||||
|
||||
back: function() {
|
||||
@@ -79,7 +81,7 @@ var Setup = {
|
||||
|
||||
makePrevEnterCodeText: function(x, y) {
|
||||
this.makeTextField(x, y, "현재의 입장번호 :");
|
||||
this.makeTextField(x + 200 + 40, y, "111111");
|
||||
this.prevEnterCodeText = this.makeTextField(x + 200 + 40, y, "111111");
|
||||
},
|
||||
|
||||
makeNewEnterCodeInput: function(x, y) {
|
||||
@@ -103,12 +105,14 @@ var Setup = {
|
||||
var setting = new RoundRectButtonSetting(x, y, 200, 100);
|
||||
setting.fontStyle.fontWeight = "bold";
|
||||
|
||||
var startButton = new RoundRectButton(
|
||||
var checkButton = new RoundRectButton(
|
||||
setting,
|
||||
RoundRectButton.NONE_ICON, "변경",
|
||||
(function() { this.checkNewEnterCode(); }).bind(this)
|
||||
);
|
||||
startButton.addShortcutText("Enter");
|
||||
checkButton.addShortcutText("Enter");
|
||||
|
||||
return checkButton;
|
||||
},
|
||||
|
||||
makeInputTypeText: function(x, y, text) {
|
||||
@@ -128,55 +132,6 @@ var Setup = {
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
makeMaestroNameText: function(x, y) {
|
||||
this.makeTextField(x, y, "마에스트로 계정 :");
|
||||
this.inputTextMaestroName = this.makeInputTypeText(x, y, "");
|
||||
this.inputTextMaestroName.canvasInput.placeHolder("입력 후 [ Tab ]키를 누르세요");
|
||||
},
|
||||
|
||||
makeNameText: function(x, y) {
|
||||
this.makeTextField(x, y, "이름 :");
|
||||
this.inputTextName = this.makeInputTypeText(x, y, "");
|
||||
this.inputTextName.canvasInput.placeHolder("입력 후 [ Tab ]키를 누르세요");
|
||||
},
|
||||
|
||||
makeEnterCodeText: function(x, y) {
|
||||
this.makeTextField(x, y, "입장번호 :");
|
||||
this.inputTextEnterCode = this.makeInputTypeText(x, y, "");
|
||||
this.inputTextEnterCode.canvasInput.placeHolder("입력 후 [ Tab ]키를 누르세요");
|
||||
},
|
||||
|
||||
makeInputTypeText: function(x, y, text) {
|
||||
var inputText = new InputTypeText(x + 420, y);
|
||||
inputText.anchor.set(0.5);
|
||||
inputText.canvasInput.value('');
|
||||
if(isDebugMode()) {
|
||||
inputText.canvasInput.value(text);
|
||||
}
|
||||
inputText.canvasInput._onkeyup = (function() {
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||
this.startMenu();
|
||||
}
|
||||
}).bind(this);
|
||||
|
||||
return inputText;
|
||||
},
|
||||
|
||||
makeStartButton: function(x, y) {
|
||||
var setting = new RoundRectButtonSetting(x, y, 200, 100);
|
||||
setting.fontStyle.fontWeight = "bold";
|
||||
|
||||
var startButton = new RoundRectButton(
|
||||
setting,
|
||||
RoundRectButton.NONE_ICON, "시작",
|
||||
(function() { this.startMenu(); }).bind(this)
|
||||
);
|
||||
startButton.addShortcutText("Enter");
|
||||
},
|
||||
|
||||
*/
|
||||
|
||||
|
||||
makeInfoText: function(x, y) {
|
||||
var textStyle = { font: "30px Arial", fill: "#faa" };
|
||||
@@ -186,8 +141,27 @@ var Setup = {
|
||||
this.infoText.strokeThickness = 3;
|
||||
},
|
||||
|
||||
showInfoText: function(message) {
|
||||
this.infoText.text = message;
|
||||
},
|
||||
|
||||
|
||||
checkNewEnterCode: function() {
|
||||
var newEnterCode = this.inputTextEnterCode.canvasInput._value;
|
||||
if(newEnterCode == this.prevEnterCode) {
|
||||
this.showInfoText("기존 입장번호와 동일합니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
var accountValidator = new AccountValidator();
|
||||
if(accountValidator.isValidPlayerPW(newEnterCode)) {
|
||||
this.showInfoText("입장번호를 바꾸겠습니다.");
|
||||
} else {
|
||||
var errorMessage = accountValidator.messageForInvalidPlayerPW(newEnterCode);
|
||||
this.showInfoText(errorMessage);
|
||||
}
|
||||
|
||||
/*
|
||||
var maestroName = this.inputTextMaestroName.canvasInput._value;
|
||||
sessionStorageManager.setPlayerName(this.inputTextName.canvasInput._value);
|
||||
var enterCode = this.inputTextEnterCode.canvasInput._value;
|
||||
@@ -218,6 +192,26 @@ var Setup = {
|
||||
this.loginFailed(jsonData);
|
||||
}).bind(this)
|
||||
);
|
||||
*/
|
||||
},
|
||||
|
||||
loadPrevEnterCode: function() {
|
||||
this.prevEnterCode = '1111';
|
||||
|
||||
var dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestPlayerEnterCode(
|
||||
sessionStorageManager.getMaestroID(),
|
||||
sessionStorageManager.getPlayerID(),
|
||||
(function(jsonData) {
|
||||
this.prevEnterCode = jsonData['EnterCode'];
|
||||
console.log(this.prevEnterCode);
|
||||
this.prevEnterCodeText.text = this.prevEnterCode;
|
||||
}).bind(this),
|
||||
(function(jsonData) {
|
||||
this.showInfoText(jsonData['error']);
|
||||
this.statButton.buttonDisabled();
|
||||
}).bind(this)
|
||||
);
|
||||
},
|
||||
|
||||
loginSucceeded: function(jsonData) {
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
<script src="../../game/lib/button/fullscreen_button.js"></script>
|
||||
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||
|
||||
<script src="../../web/js/lib/account_validator.js"></script>
|
||||
|
||||
|
||||
<!-- source files -->
|
||||
<script src="../../game/setup/setup.js"></script>
|
||||
<script src="../../game/setup/main.js"></script>
|
||||
|
||||
@@ -61,7 +61,9 @@ AccountValidator.prototype.isValidPlayerID = function(textID) {
|
||||
}
|
||||
|
||||
AccountValidator.prototype.messageForInvalidPlayerID = function(textID) {
|
||||
if(textID.length < Number(AccountValidator.Player_ID_LENGTH_MINIMUM))
|
||||
if(typeof textID == "undefined" || textID == null || textID == "")
|
||||
return "학생 이름을 입력해 주세요.";
|
||||
else if(textID.length < Number(AccountValidator.Player_ID_LENGTH_MINIMUM))
|
||||
return "학생 이름은 " + AccountValidator.Player_ID_LENGTH_MINIMUM + "글자 이상이어야 합니다.";
|
||||
else if(textID.length > Number(AccountValidator.PLAYER_ID_LENGTH_MAXIMUM))
|
||||
return "학생 이름은 " + AccountValidator.PLAYER_ID_LENGTH_MAXIMUM + "글자 이하이어야 합니다.";
|
||||
@@ -79,7 +81,10 @@ AccountValidator.prototype.isValidPlayerPW = function(textPW) {
|
||||
}
|
||||
|
||||
AccountValidator.prototype.messageForInvalidPlayerPW = function(textPW) {
|
||||
if(textPW.length < Number(AccountValidator.PLAYER_PW_LENGTH_MINIMUM))
|
||||
console.log(textPW);
|
||||
if(typeof textPW == "undefined" || textPW == null || textPW == "")
|
||||
return "학생 입장 번호를 입력해 주세요.";
|
||||
else if(textPW.length < Number(AccountValidator.PLAYER_PW_LENGTH_MINIMUM))
|
||||
return "학생 입장 번호는 " + AccountValidator.PLAYER_PW_LENGTH_MINIMUM + "자리 이상의 숫자로 입력해 주세요.";
|
||||
else if(textPW.length > Number(AccountValidator.PLAYER_PW_LENGTH_MAXIMUM))
|
||||
return "학생 입장 번호는 " + AccountValidator.PLAYER_PW_LENGTH_MAXIMUM + "자리 이하의 숫자로 입력해 주세요.";
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
include "./../lib/send_reply_json.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$maestroID = $_POST["maestro_id"];
|
||||
$playerID = $_POST["player_id"];
|
||||
/*
|
||||
if(!is_numeric($enterCode)) {
|
||||
send_error_code("생년월일이 숫자가 아닙니다. : ".$enterCode);
|
||||
exit;
|
||||
} else if(strlen($enterCode) != 6) {
|
||||
send_error_code("6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : ".$enterCode);
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
$enterCode = getEnterCode($maestroID, $playerID);
|
||||
if($enterCode == NULL) {
|
||||
set_error_message("입장 코드 정보가 없습니다.");
|
||||
send_result_fail();
|
||||
exit;
|
||||
}
|
||||
|
||||
set_data("EnterCode", $enterCode);
|
||||
send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
function getEnterCode($maestroID, $playerID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "SELECT EnterCode FROM player WHERE MaestroID=? AND PlayerID=?";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("ii", $maestroID, $playerID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($enterCode);
|
||||
// while($stmt->fetch())
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
return $enterCode;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user