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} ...@@ -29,6 +29,7 @@ socket.on('setId', function(msg) // {str, num playerNum}
// init game // init game
socket.on('enterRoom', function() socket.on('enterRoom', function()
{ {
fbClient.updateUserData('recentHopae', PlayerData.nickname);
Audio.killSound(ScenesData.menuScene, 'login'); Audio.killSound(ScenesData.menuScene, 'login');
ScenesData.changeScene('roomScene'); ScenesData.changeScene('roomScene');
/*game.scene.stop('menuScene'); /*game.scene.stop('menuScene');
......
...@@ -206,9 +206,9 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace = ...@@ -206,9 +206,9 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
updates.exp = replace ? (valueChanged) : (beforeData.exp + valueChanged); updates.exp = replace ? (valueChanged) : (beforeData.exp + valueChanged);
beforeData.exp = updates.exp; beforeData.exp = updates.exp;
break; break;
case 'money': case 'rank':
updates.money = replace ? (valueChanged) : (beforeData.money + valueChanged); updates.rank = replace ? (valueChanged) : (beforeData.rank + valueChanged);
beforeData.money = updates.money; beforeData.rank = updates.rank;
break; break;
case 'hopae': case 'hopae':
if (beforeData.hopae != null) if (beforeData.hopae != null)
...@@ -222,6 +222,26 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace = ...@@ -222,6 +222,26 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
updates.hopae = [valueChanged]; updates.hopae = [valueChanged];
} }
break; 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': case 'item':
if (beforeData.item != null) if (beforeData.item != null)
{ {
...@@ -238,6 +258,8 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace = ...@@ -238,6 +258,8 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
console.log('[ERROR] database has no key for ' + key); console.log('[ERROR] database has no key for ' + key);
break; break;
} }
PlayerData.userData = beforeData;
console.log(updates.recentHopae);
return this.database.ref('/user-data/' + this.auth.currentUser.uid).update(updates); return this.database.ref('/user-data/' + this.auth.currentUser.uid).update(updates);
} }
...@@ -258,7 +280,7 @@ class UserData ...@@ -258,7 +280,7 @@ class UserData
[ [
{name: prompt("첫번째 호패의 닉네임을 입력해주세요."), type: 'wood'} {name: prompt("첫번째 호패의 닉네임을 입력해주세요."), type: 'wood'}
]; ];
this.recentName = ''; this.recentHopae = '';
this.title = []; this.title = [];
this.money = 0; this.money = 0;
this.item = []; this.item = [];
......
...@@ -35,7 +35,7 @@ Input.menuSceneEnterReaction = function() ...@@ -35,7 +35,7 @@ Input.menuSceneEnterReaction = function()
if (Input.finalInput.length > 1) if (Input.finalInput.length > 1)
{ {
PlayerData.nickname = Input.finalInput; PlayerData.nickname = Input.finalInput;
ScenesData.menuScene.myName.setText('내 이름 : ' + PlayerData.nickname); ScenesData.menuScene.hopae.setText('내 호패 : ' + PlayerData.nickname);
Input.reset(); Input.reset();
} }
else else
......
...@@ -28,21 +28,20 @@ var menuScene = new Phaser.Class( ...@@ -28,21 +28,20 @@ var menuScene = new Phaser.Class(
Audio.loopSound(this, 'login'); Audio.loopSound(this, 'login');
Input.inputField.generate(this, Input.menuSceneEnterReaction); Input.inputField.generate(this, Input.menuSceneEnterReaction);
//BackGround.drawMenu(this); //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.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.myName.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); 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 = () => { const actionOnClick = () => {
console.log('click'); console.log('click');
socket.emit('enterRoom', PlayerData.nickname); socket.emit('enterRoom', PlayerData.nickname);
} }
let btn1 = new Button(this, game.config.width / 2, 800, 'pyeongminWrite', actionOnClick, 2, 1, 0) let gameStartBtn = new Button(this, game.config.width / 2, 800, 'pyeongminWrite', actionOnClick, 2, 1, 0)
btn1.onInputOut = () => { gameStartBtn.setScale(0.5).setDepth(10);
console.log('Btn1: onInputOut')
}
btn1.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