{"id":2987,"date":"2017-12-14T09:00:13","date_gmt":"2017-12-14T00:00:13","guid":{"rendered":"http:\/\/oohito.com\/nqthm\/?p=2987"},"modified":"2017-12-14T09:00:13","modified_gmt":"2017-12-14T00:00:13","slug":"building-a-memory-game-with-bloc%e3%81%ae%e6%89%8b%e7%bf%92%e3%81%84%ef%bc%88chapter-2%ef%bc%89","status":"publish","type":"post","link":"https:\/\/oohito.com\/nqthm\/archives\/2987","title":{"rendered":"Building a memory game with Bloc\u306e\u624b\u7fd2\u3044\uff08Chapter 2\uff09"},"content":{"rendered":"<blockquote><p>\u3053\u308c\u306f<a href=\"https:\/\/qiita.com\/advent-calendar\/2017\/smalltalk\">Smalltalk Advent Calendar 2017<\/a>\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p><\/blockquote>\n<p>\u524d\u56de\u306b\u5f15\u304d\u7d9a\u3044\u3066\u3001Bloc \u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u3042\u308b Building a memory game with Bloc \u306eChapter \uff12(Game model insights) \u306e\u5185\u5bb9\u3092\u3084\u3063\u3066\u3044\u304f\u3002<br \/>\n\u5143\u30cd\u30bf\u306f<br \/>\n<a href=\"https:\/\/github.com\/pharo-graphics\/Bloc\">https:\/\/github.com\/pharo-graphics\/Bloc<\/a><br \/>\n\u306e\u4e2d\u306b\u3042\u308b\u3001<br \/>\n<a href=\"http:\/\/files.pharo.org\/books-pdfs\/booklet-Bloc\/2017-11-09-memorygame.pdf\">http:\/\/files.pharo.org\/books-pdfs\/booklet-Bloc\/2017-11-09-memorygame.pdf<\/a><br \/>\n\u3067\u3042\u308b\u3002<br \/>\n<!--more--><br \/>\n\u3044\u304d\u306a\u308aUI\u3092\u4f5c\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u307e\u305a\u306f\u30e2\u30c7\u30eb\u304b\u3089\u4f5c\u308a\u307e\u3057\u3087\u3046\u3068\u3044\u3046\u8a71\u3002Model-View \u306e\u30d5\u30ec\u30fc\u30e0\u3092\u4f7f\u3046\u306e\u3067\u3001\u305d\u306e\u305f\u3081\u306e\u30e2\u30c7\u30eb\u3092\u5b9a\u7fa9\u3059\u308b\u3002\u5b9f\u969b\u306b\u306f M-VC \u307f\u305f\u3044\u306a\u611f\u3058\u306b\u306a\u308b\u306e\u304b\u306a\u3002<br \/>\nModel \u306f View \u306b\u306f\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u305b\u305a\u306b\u3001announcement\uff08\u901a\u77e5\u3063\u3066\u8a33\u3059\u306e\u3067\u3044\u3044\u306e\u304b\uff1f\uff09\u3092\u7528\u3044\u3066\u72b6\u614b\u3092\u77e5\u3089\u305b\u3001View \u306f Model \u306b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3002<\/p>\n<h2>2.1 Reviewing the card model<\/h2>\n<p>\u307e\u305a\u306f\u30ab\u30fc\u30c9\u306e\u30e2\u30c7\u30eb\u304b\u3089\u4f5c\u308b\u3002\u30ab\u30fc\u30c9\u306f\u8868\u793a\u3059\u308b\u6587\u5b57\u3068\u3001\u8868\u304b\u88cf\u304b\u306e\u72b6\u614b\u3001\u3042\u3068\u3001\u72b6\u614b\u306e\u5909\u5316\u3092\u901a\u77e5\u3059\u308b\u305f\u3081\u306e announcer \u3092\u4fdd\u6301\u3059\u308b\u3002Model \u306e\u30b5\u30d6\u30af\u30e9\u30b9\u306b\u3059\u308c\u3070\u3001\u6700\u521d\u304b\u3089 announcer \u3092\u6301\u3063\u3066\u308b\u3051\u3069\u3001\u3042\u3048\u3066 Object \u306e\u30b5\u30d6\u30af\u30e9\u30b9\u306b\u3059\u308b\u3089\u3057\u3044\u3002<\/p>\n<pre>Object subclass: #MgdCardModel\n    instanceVariableNames: 'symbol flipped announcer'\n    classVariableNames: ''\n    package: 'Bloc-MemoryGame-Demo-Model'<\/pre>\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306a\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3057\u305f\u3089\u3001\u6b21\u306f initialize \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u88cf\uff08flipped = false\uff09\u306b\u521d\u671f\u5316\u3059\u308b\u3002<\/p>\n<pre>MgdCardModel &gt;&gt; initialize\n    super initialize.\n    flipped := false.<\/pre>\n<p>\u52a0\u3048\u3066\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u306e\u30a2\u30af\u30bb\u30c3\u30b5\u3092\u4f5c\u3063\u3066\u304a\u304f\u3002<\/p>\n<pre>MgdCardModel &gt;&gt; symbol: aCharacter\n    symbol := aCharacter.<\/pre>\n<pre>MgdCardModel &gt;&gt; symbol\n    ^ symbol<\/pre>\n<pre>MgdCardModel &gt;&gt; isFlipped\n    ^ flipped<\/pre>\n<p>isFlipped \u306f\u3001\u30ab\u30fc\u30c9\u304c\u8868\u306e\u72b6\u614b\u306e\u6642\u306b true \u3092\u8fd4\u3059\u3002<\/p>\n<pre>MgdCardModel &gt;&gt; announcer\n    ^ announcer ifNil: [ announcer := Announcer new ].<\/pre>\n<p>announcer \u30e1\u30bd\u30c3\u30c9\u3067\u306f Lazy Initialization \u30d1\u30bf\u30fc\u30f3\u306b\u3057\u3066\u3044\u308b\u3002<\/p>\n<h2>2.2 Card simple operations<\/h2>\n<p>\u30ab\u30fc\u30c9\u3092\u88cf\u8fd4\u3059\u30e1\u30bd\u30c3\u30c9\u3068\u3001\u4e0d\u8981\u306a\u30ab\u30fc\u30c9\u3092\u53d6\u308a\u9664\u304f\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u308b\u3002<\/p>\n<pre>MgdCardModel &gt;&gt; flip\n    flipped := flipped not.\n    self notifyFlipped<\/pre>\n<pre>MgdCardModel &gt;&gt; disappear\n    self notifyDisappear<\/pre>\n<p>\u53d6\u308a\u9664\u304f\u3068\u306f\u3044\u3048\u3001\u53d6\u308a\u9664\u304b\u308c\u308b\u30ab\u30fc\u30c9\u305d\u306e\u3082\u306e\u3068\u3057\u3066\u306f\u3001\u8ab0\u304b\u306b\u305d\u306e\u3053\u3068\u3092\u4f1d\u3048\u308b\uff08announce\u3059\u308b\uff09\u304f\u3089\u3044\u3057\u304b\u3067\u304d\u306a\u3044\u3002<\/p>\n<h2>2.3 Adding notification<\/h2>\n<p>\u76f4\u524d\u306e\uff12\u3064\u306e\u30e1\u30bd\u30c3\u30c9\u5b9a\u7fa9\u3067\u7528\u3044\u305fnotify\u3067\u59cb\u307e\u308b\u901a\u77e5\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3059\u308b\u3002\u5185\u5bb9\u3068\u3057\u3066\u306f\u3001 MgdCardFlippedAnnouncement \u3068 MgdCardDisappearAnnouncement \u3068\u3044\u3046\u578b\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u901a\u77e5\u3059\u308b\u3060\u3051\u3002\u5f8c\u3067UI \u5074\u304c\u3053\u306e\u30a4\u30d9\u30f3\u30c8\u306e\u901a\u77e5\u3092\u53d7\u3051\u53d6\u308c\u308b\u3088\u3046\u306b\u767b\u9332\u3059\u308b\u3002<\/p>\n<pre>MgdCardModel &gt;&gt; notifyFlipped\n    self announcer announce: MgdCardFlippedAnnouncement new.<\/pre>\n<pre>MgdCardModel &gt;&gt; notifyDisappear\n    self announcer announce: MgdCardDisappearAnnouncement new.<\/pre>\n<p>\u5f53\u7136\u306e\u3053\u3068\u306a\u304c\u3089\u3001\u4e0a\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u524d\u306b\u3001\u4ee5\u4e0b\u306e2\u3064\u306e\u30af\u30e9\u30b9\u5b9a\u7fa9\u3092\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3088\u306d\u3002<\/p>\n<pre>Announcement subclass: #MgdCardFlippedAnnouncement\n    instanceVariableNames: ''\n    classVariableNames: ''\n    package: 'Block-MemoryGame-Demo-Model'<\/pre>\n<pre>Announcement subclass: #MgdCardDisappearAnnouncement\n    instanceVariableNames: ''\n    classVariableNames: ''\n    package: 'Block-MemoryGame-Demo-Model'<\/pre>\n<p>\u30ab\u30fc\u30c9\u306e\u30e2\u30c7\u30eb\u306e\u7de0\u3081\u304f\u304f\u308a\u306b\u3001\u30e2\u30c7\u30eb\u3092\u8868\u793a\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u3063\u3066\u304a\u304f\u3002<\/p>\n<pre>MgdCardModel &gt;&gt; printOn: aStream\n    aStream\n      nextPutAll: 'Card';\n      nextPut: Character space;\n      nextPut: $(;\n      nextPut: self symbol;\n      nextPut: $).<\/pre>\n<p>\u30ab\u30fc\u30c9\u306e\u30e2\u30c7\u30eb\u306b\u3064\u3044\u3066\u306f\u3001\u3068\u308a\u3042\u3048\u305a\u7d42\u308f\u308a\u3089\u3057\u3044\u3002<\/p>\n<h2>2.4 Reviewing the game model<\/h2>\n<p>\u6b21\u306f\u30b2\u30fc\u30e0\u306e\u30e2\u30c7\u30eb\u306b\u3068\u308a\u304b\u304b\u308b\u3002\u30b2\u30fc\u30e0\u306e\u30e2\u30c7\u30eb\u306f\u3001\u5229\u7528\u53ef\u80fd\u306a\u30ab\u30fc\u30c9\u306e\u4fdd\u6301\u3068\u3001\u30d7\u30ec\u30a4\u30e4\u30fc\u306b\u3088\u3063\u3066\u9078\u3070\u308c\u3066\u3044\u308b\u30ab\u30fc\u30c9\u306e\u60c5\u5831\u3092\u4fdd\u6301\u3059\u308b\u3002<\/p>\n<pre>Object subclass: #MgdGameModel\n    instanceVariableNames: 'availableCards chosenCards'\n    classVariableNames: ''\n    package: 'Bloc-MemoryGame-Demo-Model'<\/pre>\n<p>initialize \u30e1\u30bd\u30c3\u30c9\u3067\u306f\u5404\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u3092 OrderedCollection \u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u521d\u671f\u5316\u3059\u308b\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; initialize\n    super initialize.\n    availableCards := OrderedCollection new.\n    chosenCards := OrderedCollection new.<\/pre>\n<p>\u305d\u308c\u305e\u308c\u306e\u30a2\u30af\u30bb\u30c3\u30b5\u3082\u4f5c\u3063\u3066\u304a\u304f\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; availableCards\n    ^ availableCards<\/pre>\n<pre>MgdGameModel &gt;&gt; chosenCards\n    ^ chosenCards<\/pre>\n<h2>2.5 Grid size and card number<\/h2>\n<p>\u3042\u308c\u308c\uff1f\u3068\u601d\u3046\u3051\u3069\u3001\u30b2\u30fc\u30e0\u76e4\u306e\u6b21\u5143\uff08\u7e26\u6a2a\u306e\u30de\u30b9\u6570\uff09\u306f\u56fa\u5b9a\u3057\u3066\u3057\u307e\u3046\u3089\u3057\u3044\u3002for now \u3068\u304b\u8a00\u3063\u3066\u3044\u308b\u304b\u3089\u3001\u5f8c\u3067\u5909\u3048\u3089\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u306e\u304b\u3082\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; girdSize\n    ^ 4<\/pre>\n<p>\u30ab\u30fc\u30c9\u3092\u63c3\u3048\u308b\u679a\u6570\u3082\u30e1\u30bd\u30c3\u30c9\u306b\u3057\u3066\u304a\u304f\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; matchesCount\n    ^ 2<\/pre>\n<p>\u6b21\u5143\u306b\u5fdc\u3058\u3066\u5fc5\u8981\u3068\u306a\u308b\u30ab\u30fc\u30c9\u679a\u6570\u3092\u6c42\u3081\u308b\u30e1\u30bd\u30c3\u30c9\u3082\u4f5c\u308b\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; cardsCount\n    ^ self gridSize * self gridSize<\/pre>\n<h2>2.6 Initialization<\/h2>\n<p>\u30b2\u30fc\u30e0\u306e\u521d\u671f\u5316\u306e\u305f\u3081\u306e\u7279\u5225\u306a\u30e1\u30bd\u30c3\u30c9 initializeForSymbols: \u3092\u4f5c\u308b\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u4e0e\u3048\u3089\u308c\u305f\u6587\u5b57\u306e\u30ea\u30b9\u30c8\u306b\u57fa\u3065\u3044\u3066\u30ab\u30fc\u30c9\u3092\u751f\u6210\u3057\u3066\u3001\u30b7\u30e3\u30c3\u30d5\u30eb\u3059\u308b\u3082\u306e\u3067\u3042\u308b\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; initializeForSymbols: characters\n    self\n      assert: [ characters size = (self cardsCount \/ self matchesCount ]\n      description: [ 'Amount of characters must be equal to possible all combinations' ].\n    availableCards := (characters asArray collect: [ :aSymbol |\n      (1 to: self matchesCount) collect: [ :i |\n        MgdCardModel new symbol: aSymbol ]])\n          flattened shuffled asOrderedCollection.<\/pre>\n<p>\u30e1\u30bd\u30c3\u30c9\u306e\u6700\u521d\u306e3\u884c\u306f\u3001\u4e0e\u3048\u3089\u308c\u305f\u6587\u5b57\u306e\u30ea\u30b9\u30c8\u306e\u9577\u3055\u3068\u3001\u30b2\u30fc\u30e0\u76e4\u304c\u5fc5\u8981\u3068\u3059\u308b\u6587\u5b57\u306e\u30b5\u30a4\u30ba\u3068\u304c\u5408\u81f4\u3059\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3044\u308b\u3002<br \/>\n\u6b21\u306b\u3001\u4e0e\u3048\u3089\u308c\u305f\u6587\u5b57\u306e\u30ea\u30b9\u30c8\u3092\u914d\u5217\u306b\u5909\u63db\u3057\u305f\u5f8c\u3001\uff11\u6587\u5b57\u305a\u3064\u53d6\u308a\u51fa\u3057\u3064\u3064\u3001\u63c3\u3048\u308b\u3079\u304d\u30ab\u30fc\u30c9\u679a\u6570\u5206\u306e\u30ab\u30fc\u30c9\u30e2\u30c7\u30eb\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u3063\u3066\u3044\u308b\u3002\u305d\u306e\u307e\u307e\u3060\u3068\u3001\u30ab\u30fc\u30c9\u306e\u30e2\u30c7\u30eb\u306e\u914d\u5217\u3092\u8981\u7d20\u3068\u3059\u308b\u914d\u5217\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u305f\u3081 flattened \u30671\u6b21\u5143\u306e\u914d\u5217\u306b\u5909\u63db\u3059\u308b\u3002\u8981\u7d20\u306e\u9806\u5e8f\u3092 shuffled \u3067\u30b7\u30e3\u30c3\u30d5\u30eb\u3057\u305f\u3042\u3068\u3001 OrderedCollection \u306b\u5909\u63db\u3057\u3066 availableCards \u306b\u683c\u7d0d\u3059\u308b\u3002<br \/>\n\u6163\u308c\u308c\u3070\u306a\u3093\u3066\u3053\u3068\u306f\u306a\u3044\u3051\u3069\u3001\u3053\u308c\u3060\u3051\u6587\u5b57\u304c\u5bc6\u96c6\u3059\u308b\u3068\u300c\u3046\u308f\u3063\u300d\u3066\u306a\u308b\u304b\u3082\u3002<\/p>\n<h2>2.7 Game logic<\/h2>\n<p>\u30b2\u30fc\u30e0\u306e\u30e2\u30c7\u30eb\u3067\u6700\u3082\u91cd\u8981\u306a\u30ed\u30b8\u30c3\u30af\u306b\u95a2\u308f\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u308b\u3002\u305d\u306e\u4e3b\u8981\u306a\u3082\u306e\u304c chooseCard: \u30e1\u30bd\u30c3\u30c9\u3067\u3001\u30d7\u30ec\u30a4\u30e4\u30fc\u304c\u9078\u3093\u3060\u30ab\u30fc\u30c9\u306b\u5bfe\u3059\u308b\u51e6\u7406\u3092\u5b9f\u73fe\u3059\u308b\u3002\u51e6\u7406\u306f\u3044\u304f\u3064\u304b\u306b\u5206\u304b\u308c\u3066\u3044\u308b\u3002<\/p>\n<ol>\n<li>\u4e0e\u3048\u3089\u308c\u305f\u30ab\u30fc\u30c9\u304c\u3001\u65e2\u306b chosenCards \u306b\u3042\u3063\u305f\u3089\u4f55\u3082\u3057\u306a\u3044\u3002<\/li>\n<li>\u30ab\u30fc\u30c9\u3092 chosenCards \u306b\u52a0\u3048\u308b\u3002<\/li>\n<li>\u305d\u306e\u30ab\u30fc\u30c9\u3092\u8868\u306b\u3059\u308b\u3002<\/li>\n<li>\u30b2\u30fc\u30e0\u76e4\u306e\u72b6\u6cc1\u306b\u5fdc\u3058\u3066\u3001\u30ab\u30fc\u30c9\u3092\u53d6\u308a\u9664\u3044\u305f\u308a\u3001\u88cf\u8fd4\u3057\u305f\u308a\u3059\u308b\u3002<\/li>\n<\/ol>\n<pre>MgdGameModel &gt;&gt; chooseCard: aCard\n    (self chosenCards includes: aCard)\n      ifTrue: [ ^ self ].\n    self chosenCards add: aCard.\n    aCard flip.\n    self shouldCompleteStep\n      ifTrue: [ ^ self completeStep ].\n    self shouldResetStep\n      ifTrue: [ ^ self resetStep ].<\/pre>\n<p>\u30b9\u30c6\u30c3\u30d74\u306b\u3064\u3044\u3066\u3001\u300c\u30d7\u30ec\u30a4\u30e4\u30fc\u304c\u5fc5\u8981\u306a\u679a\u6570\u306e\u30ab\u30fc\u30c9\u3092\u9078\u3073\u3001\u304b\u3064\u3001\u3059\u3079\u3066\u540c\u3058\u6587\u5b57\u306a\u3089\u3070\u3001\u5404\u30ab\u30fc\u30c9\u306b\u5bfe\u3057\u3066 disappear \u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u308a\u3001\u305d\u308c\u3089\u306e\u30ab\u30fc\u30c9\u3092\u30ea\u30b9\u30c8\u304b\u3089\u53d6\u308a\u9664\u304f\u300d\u3068\u3044\u3046\u3053\u3068\u3092\u3001 shuoldCompleteStep, chosenCardMatch \u3068\u3001 completeStep \u306b\u5206\u3051\u3066\u8a18\u8ff0\u3059\u308b\u3002\u524d2\u8005\u306f\u6761\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3044\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3057\u3001\u5f8c\u8005\u306f\u6e80\u305f\u3057\u3066\u3044\u308b\u5834\u5408\u306e\u51e6\u7406\u3092\u884c\u3046\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; shouldCompleteStep\n    ^ self chosenCards size = self matchesCount\n      and: [ self chosenCardMatch ]<\/pre>\n<p>shouldCompleteStep \u30e1\u30bd\u30c3\u30c9\u306f\u3001 chosenCards \u306e\u5927\u304d\u3055\u304c\u63c3\u3048\u308b\u30ab\u30fc\u30c9\u306e\u679a\u6570\u306b\u4e00\u81f4\u3059\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3057\u3001\u66f4\u306b chosenCardMatch \u3067\u6587\u5b57\u304c\u4e00\u81f4\u3057\u3066\u3044\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; chosenCardMatch\n    | firstCard |\n    firstCard := self chosenCards first.\n    ^ self chosenCards allSatisfy: [ :aCard |\n      aCard isFlipped and: [ firstCard symbol = aCard symbol ] ]<\/pre>\n<p>chosenCardMatch \u30e1\u30bd\u30c3\u30c9\u306f\u3001 chosenCards \u306e\u6700\u521d\u306e\u8981\u7d20\u3092\u53d6\u308a\u51fa\u3057\u305f\u5f8c\u3001 chosenCards \u5185\u306e\u30ab\u30fc\u30c9\u304c\u5168\u3066\u8868\u306b\u306a\u3063\u3066\u3044\u3066\u3001\u6700\u521d\u306e\u8981\u7d20\u3068\u6587\u5b57\u304c\u540c\u3058\u304b\u3069\u3046\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; completeStep\n    self chosenCards\n      do: [ :aCard | aCard disappear ];\n      removeAll.<\/pre>\n<p>completeStep \u30e1\u30bd\u30c3\u30c9\u306f\u3001 chosenCards \u306e\u5168\u3066\u306e\u30ab\u30fc\u30c9\u306b disappear \u3092\u9001\u3063\u305f\u5f8c\u3001\u30ea\u30b9\u30c8\u3092\u7a7a\u306b\u3057\u3066\u3044\u308b\u3002<br \/>\n\u30b9\u30c6\u30c3\u30d74\u306e\u5f8c\u534a\u306b\u3064\u3044\u3066\u306f\u3001\u30d7\u30ec\u30a4\u30e4\u30fc\u304c3\u679a\u76ee\u306e\u30ab\u30fc\u30c9\u3092\u8868\u306b\u3057\u305f\u3068\u304d\u30013\u679a\u76ee\u4ee5\u5916\u306e\u30ab\u30fc\u30c9\u3092\u88cf\u8fd4\u3057\u306b\u3059\u308b\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; shouldResetStep\n    ^ self chosenCards size &gt; self matchesCount<\/pre>\n<p>3\u679a\u76ee\u3068\u660e\u793a\u3057\u3066\u3044\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u63c3\u3048\u308b\u30ab\u30fc\u30c9\u679a\u6570\u3092\u8d85\u3048\u305f\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3044\u308b\u3002<\/p>\n<pre>MgdGameModel &gt;&gt; resetStep\n    | lastCard |\n    lastCard := self chosenCards last.\n    self chosenCards\n      allButLastDo: [ :aCard | aCard flip ];\n      removeAll;\n      add: lastCard.<\/pre>\n<p>chosenCards \u306e\u6700\u5f8c\u306b\u52a0\u3048\u3089\u308c\u305f\u30ab\u30fc\u30c9\u3092\u53d6\u3063\u3066\u304a\u3044\u3066\u3001\u305d\u306e\u30ab\u30fc\u30c9\u4ee5\u5916\u306b flip \u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u308a\u3001chosenCards \u3092\u53d6\u3063\u3066\u304a\u3044\u305f\u6700\u5f8c\u306e\u30ab\u30fc\u30c9\u3060\u3051\u306b\u3057\u3066\u3044\u308b\u3002<\/p>\n<h2>2.8 Ready<\/h2>\n<p>\u30e2\u30c7\u30eb\u304c\u5b8c\u6210\u3057\u305f\u306e\u3067\u3001\u3088\u3046\u3084\u304f\u30b2\u30fc\u30e0\u306eView\u306b\u3068\u308a\u304b\u304b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u305d\u306e\u5f8c\u306b\u6c17\u306b\u306a\u308b\u6587\u7ae0\u304c&#8230;<\/p>\n<blockquote><p>Bloc \u306f\u958b\u767a\u4e2d\u3067\u3001\u6b63\u5e38\u306b\u8868\u793a\u3067\u304d\u306a\u3044\u3088\u3046\u306a\u5834\u5408\u306b\u306f\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u304c\u3042\u308b\u3002\u305d\u3046\u3044\u3046\u5834\u5408\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5168\u4f53\u3092\u521d\u671f\u5316\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p><\/blockquote>\n<pre>BlUniverse reset<\/pre>\n<p>\u4e16\u754c\u3092\u5143\u306b\u623b\u3059\u304a\u307e\u3058\u306a\u3044\u3068\u3057\u3066\u899a\u3048\u3066\u304a\u304b\u306a\u3044\u3068\u3002<br \/>\n\u3055\u3066\u3001Chapter 2\u306e\u5185\u5bb9\u306f\u30b2\u30fc\u30e0\u306e\u30e2\u30c7\u30eb\u4f5c\u6210\u3060\u3063\u305f\u306e\u3067\u3001 Bloc \u3089\u3057\u3055\u3068\u3044\u3046\u3082\u306e\u306f\u7279\u306b\u611f\u3058\u3089\u308c\u306a\u304b\u3063\u305f\u3002\u304d\u3063\u3068\u6b21\u306eChapter 3 \u304b\u3089 Bloc \u3089\u3057\u3044\u3053\u3068\u304c\u5b66\u3079\u308b\u306e\u3060\u308d\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u308c\u306fSmalltalk Advent Calendar 2017\u306e\u8a18\u4e8b\u3067\u3059\u3002 \u524d\u56de\u306b\u5f15\u304d\u7d9a\u3044\u3066\u3001Bloc \u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u3042\u308b Building a memory game with Bloc \u306eChapter \uff12(&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-2987","post","type-post","status-publish","format-standard","hentry","category-pharo"],"_links":{"self":[{"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/posts\/2987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/comments?post=2987"}],"version-history":[{"count":0,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/posts\/2987\/revisions"}],"wp:attachment":[{"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/media?parent=2987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/categories?post=2987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/tags?post=2987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}