Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接続中のプレイヤーとかmobとかNPCとかを管理する仕組みを実装(いまはプレイヤーだけ対応) #15

Merged
merged 7 commits into from
Dec 30, 2013

Conversation

karihei
Copy link
Contributor

@karihei karihei commented Dec 30, 2013

No description provided.

@nise-nabe
Copy link
Contributor

手元で動いたのでマージするで

@nise-nabe nise-nabe merged commit 17e1bfd into master Dec 30, 2013
@karihei
Copy link
Contributor Author

karihei commented Dec 30, 2013

いろいろ構造変えたからコメントつけようとおもったけどマージされちゃったか

@nise-nabe
Copy link
Contributor

マージしたらコメント残せないんだっけ

@karihei
Copy link
Contributor Author

karihei commented Dec 30, 2013

いや、これで大丈夫かな的な相談を入れようかと思ってた

@nise-nabe
Copy link
Contributor

言ってみなさい

@karihei
Copy link
Contributor Author

karihei commented Dec 30, 2013

これで大丈夫かな


/** @override */
Entity.prototype.toJSON = function() {
var json = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

スペース一個足りない?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

足りない・・

@nise-nabe
Copy link
Contributor

Socket の情報からuserid を決定するようなものはない?無いなら実装する.

socket.on('disconnect', function() {
  // ここで socket しか無いから diconnect したユーザを特定できないので socket.id -> userid が必要
});

Entities.prototype.removePlayerById = function(userId) {
this.players_ = _.reject(this.players_, function(player) {
return player.id === userId;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここらへんってもしかして delete でも良いとか?

delete this.players_[userId];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleteでよかった。そしてこのメソッド使ってなかった。

@karihei
Copy link
Contributor Author

karihei commented Dec 30, 2013

Socket の情報からuserid を決定するようなものはない?無いなら実装する.

https://github.com/soltycabbage/BeamQuest/pull/15/files#diff-b3221516324f5cc0ea5614443036d4ddR57
いちおうここ⇡で

socket.on('disconnect', function(userId) {
    // ....
});

みたいに書けばsocketとuserIDの対応付けが取れるけど

@nise-nabe
Copy link
Contributor

なるほど(イベント・ドリブンの思考になれてなかった)

@karihei
Copy link
Contributor Author

karihei commented Dec 30, 2013

修正してmasterにぶっこんだ

@nise-nabe
Copy link
Contributor

じつはrejectつかってるところもう一箇所ある

@karihei
Copy link
Contributor Author

karihei commented Dec 30, 2013

そこはdeleteじゃだめ

@nise-nabe
Copy link
Contributor

ほう(流し見だったからよくみてない)

@karihei
Copy link
Contributor Author

karihei commented Dec 30, 2013

そうでもなかった

@karihei karihei deleted the user-manage branch December 31, 2013 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants