-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Panel#takeAndPlaceをStageに移動 #223
Changes from 3 commits
26ac96a
255d853
702f4c6
c9d2d33
61316e7
efb7236
41026a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,27 +27,25 @@ class Panel { | |
if (currentCount !== null) { // null means infinity | ||
this.parts.set(blockName, currentCount + 1); | ||
} | ||
return true; | ||
this.update(); | ||
} | ||
|
||
/** | ||
* panel上のblockを減らす | ||
* @param {string} blockName - 消費するblock名 | ||
* @return {bool} 正しくblockを減らせたかどうか | ||
* @return {undefined} | ||
*/ | ||
take(blockName) { | ||
if (!this.parts.has(blockName)) { | ||
return false; | ||
} | ||
const currentCount = this.parts.get(blockName); | ||
if (currentCount !== null) { // null means infinity | ||
if (currentCount - 1 === 0) { // take the last block | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currentCountが0のときに return false する必要がありそう There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 多分今のところ、currentCountが0という状況は発生し得ないのですが(そうなりそうな場合partsからkeyごと消される)、対応したほうがいいもんですかね There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. それを言うなら39行目の There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 45行目を見てください。(これはもとからの仕様です) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. あー、selectedがundifinedにならなくなったのか⋯⋯。それならむしろここでselectedにundefinedをセットして、takeAndPlaceにundefinedなら回転する仕様を追加して return false を撲滅するほうがよさそう。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (いずれにせよreturnされた値は使ってないんだし) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. あ、39行目なんて通らないんじゃないかの意味がようやく分かった。(だーめ。) |
||
this.selected = null; | ||
this.parts.delete(blockName); | ||
} else { | ||
this.parts.set(blockName, currentCount - 1); | ||
} | ||
} | ||
return true; | ||
this.update(); | ||
} | ||
|
||
update() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
消すんじゃなくてassertにしたいかなー。
currentCount === 0
の場合も同様。