Commit f6cbf77f authored by 18손재민's avatar 18손재민 Committed by 18신대성

최근 사용한 호패를 서버에 갱신함

parent f8ecc5f1
......@@ -29,6 +29,7 @@ socket.on('setId', function(msg) // {str, num playerNum}
// init game
socket.on('enterRoom', function()
{
fbClient.updateUserData('recentHopae', PlayerData.nickname);
Audio.killSound(ScenesData.menuScene, 'login');
ScenesData.changeScene('roomScene');
/*game.scene.stop('menuScene');
......
......@@ -206,9 +206,9 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
updates.exp = replace ? (valueChanged) : (beforeData.exp + valueChanged);
beforeData.exp = updates.exp;
break;
case 'money':
updates.money = replace ? (valueChanged) : (beforeData.money + valueChanged);
beforeData.money = updates.money;
case 'rank':
updates.rank = replace ? (valueChanged) : (beforeData.rank + valueChanged);
beforeData.rank = updates.rank;
break;
case 'hopae':
if (beforeData.hopae != null)
......@@ -222,6 +222,26 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
updates.hopae = [valueChanged];
}
break;
case 'recentHopae':
updates.recentHopae = valueChanged;
beforeData.recentHopae = updates.recentHopae;
break;
case 'title':
if (beforeData.title != null)
{
updates.title.push(valueChanged);
beforeData.title.push(valueChanged);
}
else
{
beforeData.title = [valueChanged];
updates.title = [valueChanged];
}
break;
case 'money':
updates.money = replace ? (valueChanged) : (beforeData.money + valueChanged);
beforeData.money = updates.money;
break;
case 'item':
if (beforeData.item != null)
{
......@@ -238,6 +258,8 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
console.log('[ERROR] database has no key for ' + key);
break;
}
PlayerData.userData = beforeData;
console.log(updates.recentHopae);
return this.database.ref('/user-data/' + this.auth.currentUser.uid).update(updates);
}
......@@ -258,7 +280,7 @@ class UserData
[
{name: prompt("첫번째 호패의 닉네임을 입력해주세요."), type: 'wood'}
];
this.recentName = '';
this.recentHopae = '';
this.title = [];
this.money = 0;
this.item = [];
......
......@@ -33,9 +33,9 @@ Input.menuSceneEnterReaction = function()
{
Input.finalInput = Input.removeConVow(Input.finalInput);
if (Input.finalInput.length > 1)
{
{
PlayerData.nickname = Input.finalInput;
ScenesData.menuScene.myName.setText('내 이름 : ' + PlayerData.nickname);
ScenesData.menuScene.hopae.setText('내 호패 : ' + PlayerData.nickname);
Input.reset();
}
else
......
......@@ -28,21 +28,20 @@ var menuScene = new Phaser.Class(
Audio.loopSound(this, 'login');
Input.inputField.generate(this, Input.menuSceneEnterReaction);
//BackGround.drawMenu(this);
this.myName = this.add.text(game.config.width / 2, 200, '이름을 입력해주세요.').setOrigin(0.5, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5);
this.myName.setFontSize(40);
this.userName = this.add.text(100, 100, '내 이름 : ' + PlayerData.userData.userName).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40);
this.money = this.add.text(100, 200, '소지 엽전 : ' + PlayerData.userData.money).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40);
this.hopae = this.add.text(100, 300, '내 호패 : ' + PlayerData.userData.recentHopae).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40);
this.myCharacter = this.add.sprite(game.config.width / 2, game.config.height / 2, 'pyeongminStand').setOrigin(0.5, 0.5).setDepth(5);
PlayerData.nickname = PlayerData.userData.recentHopae;
const actionOnClick = () => {
console.log('click');
socket.emit('enterRoom', PlayerData.nickname);
}
let btn1 = new Button(this, game.config.width / 2, 800, 'pyeongminWrite', actionOnClick, 2, 1, 0)
btn1.onInputOut = () => {
console.log('Btn1: onInputOut')
}
btn1.setScale(0.5).setDepth(10);
let gameStartBtn = new Button(this, game.config.width / 2, 800, 'pyeongminWrite', actionOnClick, 2, 1, 0)
gameStartBtn.setScale(0.5).setDepth(10);
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment