0) this.fallingLetters.slice().each( \n\t\t\tfunction (ea) { this.letterFallToPile(ea); }.bind(this)); // unused letter falls to pile\n\tif (this.activeLetters.length == 0) return;\n\tvar letter = this.activeLetters[0]; // Will be on the belt\n\tletter.moveBy(pt(this.xStep, 0));\n\t\n\t// Drop letter from belt to rack, and then drop anew one onto belt\n\tif (letter.bounds().topRight().x < this.rack.bounds().topRight().x) this.letterDropOntoRack(letter);\n\n\t// Propagate leftward motion along rack when letters touch\n\tthis.lettersSlideOnRack();\n\n\t// If leftmost letter is off rack then drop it\n\tif (this.activeLetters.last().bounds().center().x < this.rack.bounds().topLeft().x) this.letterFallOffEnd();\n}","funcProperties":{"__isSmartRef__":true,"id":3841},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3840":{"this":{"__isSmartRef__":true,"id":146}},"3841":{},"3842":{"varMapping":{"__isSmartRef__":true,"id":3843},"source":"function onKeyDown(evt) {\n\tif (this.paused) return;\n\tswitch (evt.getKeyCode()) {\n\t\tcase 8: this.doDelete(true); return;\n\t\tcase 27: this.doClear(true); return;\n\t\tcase 13: this.doEnter(true); return;\n\t}\n\t// Normal letter keys...\n\tvar char = evt.getKeyChar();\n\tif (char == '!') return;\n\tvar letter = this.findCharOnRack(char.toUpperCase());\n\tif (letter) this.addToOutbox(letter);\n}","funcProperties":{"__isSmartRef__":true,"id":3844},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3843":{"this":{"__isSmartRef__":true,"id":146}},"3844":{},"3845":{"varMapping":{"__isSmartRef__":true,"id":3846},"source":"function fillLetter(letterMorph, color) {\n\tletterMorph.setBorderColor(color);\n\ttry { // some problem in textColor code\n letterMorph.applyStyle({textColor: color});\n } catch(err) {};\n\ttry { // some problem in textColor code\n\t letterMorph.valueBox.applyStyle({textColor: color});\n } catch(err) {};\n}","funcProperties":{"__isSmartRef__":true,"id":3847},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3846":{"this":{"__isSmartRef__":true,"id":146}},"3847":{},"3848":{"varMapping":{"__isSmartRef__":true,"id":3849},"source":"function removeFromOutbox(letter) {\n\t\tletter.original.copyInOutbox = null; // restore original for, eg, del\n\t\tthis.fillLetter(letter.original, Color.black); \n\t\tletter.remove();\n}","funcProperties":{"__isSmartRef__":true,"id":3850},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3849":{"this":{"__isSmartRef__":true,"id":146}},"3850":{},"3851":{"varMapping":{"__isSmartRef__":true,"id":3852},"source":"function updateOutbox() {\n\t// Lay out outbox letters beginning at index = start\n\tthis.letterScore = 0;\n\tvar nLetters = this.outboxLetters.length;\n\tfor (var i=0; i 0) this.fillLetter(this.multBoxes[nLetters-1], Color.blue);\n\tthis.letterScoreBox.setTextString(this.letterScore.toString());\n\tthis.wordScore = this.letterScore*this.multipliers[nLetters];\n\tthis.wordScoreBox.setTextString(this.wordScore.toString());\n}","funcProperties":{"__isSmartRef__":true,"id":3853},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3852":{"this":{"__isSmartRef__":true,"id":146}},"3853":{},"3854":{"varMapping":{"__isSmartRef__":true,"id":3855},"source":"function shuffle(inp) {\n\t// Return a shuffled copy of the input array\n\tvar shuffled = inp.slice(0); // shuffleable copy\n\tfor (var i=0; i 0 && consonants.length > 0) { \n\t\t// Assemble letters according to their overall ratio\n\t\tif ( (vowels.length / (vowels.length + consonants.length)) > ratio) mixed.push(vowels.pop());\n\t\t\telse mixed.push(consonants.pop());\n\t}\n\t// pick up any leftovers\n\treturn mixed.concat(consonants, vowels);\n}","funcProperties":{"__isSmartRef__":true,"id":3859},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3858":{"this":{"__isSmartRef__":true,"id":146}},"3859":{},"3860":{"varMapping":{"__isSmartRef__":true,"id":3861},"source":"function letterValue(char) {\n\tvar letterValues = { A: 1, B: 3, C: 3, D: 2, E: 1, F: 4, G: 2, H: 4, I: 1, J: 8, K: 5, L: 1, M: 3, N: 1, O: 1, P: 3, Q: 10, R: 1, S: 1, T: 1, U: 1, V: 4, W: 4, X: 8, Y: 4, Z: 10}; \n\treturn letterValues[char] || 1;\n}","funcProperties":{"__isSmartRef__":true,"id":3862},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3861":{"this":{"__isSmartRef__":true,"id":146}},"3862":{},"3863":{"varMapping":{"__isSmartRef__":true,"id":3864},"source":"function doPause(val) {\n\tthis.paused = val;\n\tthis.pauseButton.setLabel( this.paused ? \"resume\" : \"pause\" );\n\n\t// If pausing, blank out all moving letters; if un-pausing, then restore them\n\tvar backGroundFill = Color.veryLightGray; // reading fill from text does not work\n\tvar ifInBin = (this.letterInBin ? [this.letterInBin] : []);\n\t\tifInBin.concat(this.outboxLetters, this.fallingLetters, this.activeLetters).each( \n\t\t\tfunction (letter) {\n\t\t\t\tif (this.paused) letter.colorBeforePause = letter.getBorderColor(); // save color when pause\n\t\t\t\tthis.fillLetter(letter, ( this.paused ? backGroundFill : letter.colorBeforePause ) ); // blank or restore\n\t\t\t}.bind(this)); \n this.kbdHack.focus();\n\n}","funcProperties":{"__isSmartRef__":true,"id":3865},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3864":{"this":{"__isSmartRef__":true,"id":146}},"3865":{},"3866":{"varMapping":{"__isSmartRef__":true,"id":3867},"source":"function doRestart(val) {\nconsole.log(\"val = \" + val);\n//\tif (!val) return;\n\tif (this.gameOver) {\n\t\tthis.setup();\n\t\t} else {\n\t\tthis.doPause(true);\n\t\tthis.world().confirm(\"OK to end this game and restart?\",\n\t\t\t\tfunction(ok) { if (ok) this.setup(); else this.doPause(false); }.bind(this) );\n\t}\n}","funcProperties":{"__isSmartRef__":true,"id":3868},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3867":{"this":{"__isSmartRef__":true,"id":146}},"3868":{},"3869":{"varMapping":{"__isSmartRef__":true,"id":3870},"source":"function doDelete(val) {\n\tif (!val) return;\n\t// Delete key or button -- delete last letter from outbox and restore original\n\tif (this.outboxLetters.length == 0) return;\n\tthis.removeFromOutbox(this.outboxLetters.pop());\n\tthis.updateOutbox();\n}","funcProperties":{"__isSmartRef__":true,"id":3871},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3870":{"this":{"__isSmartRef__":true,"id":146}},"3871":{},"3872":{"varMapping":{"__isSmartRef__":true,"id":3873},"source":"function doClear(val) {\n\tif (!val) return;\n\t// Tab key or clear button -- means to delete all letters in outbox\n\twhile (this.outboxLetters.length > 0) \n\t\tthis.removeFromOutbox(this.outboxLetters.pop());\n\tthis.updateOutbox();\n}","funcProperties":{"__isSmartRef__":true,"id":3874},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3873":{"this":{"__isSmartRef__":true,"id":146}},"3874":{},"3875":{"varMapping":{"__isSmartRef__":true,"id":3876},"source":"function doEnter(val) {\n\t// Enter key or button -- means to submit this word from outbox\n\t// First gather the word\n\tif (!val) return;\n\tvar word = \"\";\n\tfor (var i=0; i this.bestWordScore) {\n\t\tthis.bestWordScore = this.wordScore;\n\t\tthis.bestWordBox.setTextString(this.bestWordScore.toString());\n\t\tthis.bestWord = word;\n\t\tthis.bestWordLetters.setTextString(this.bestWord);\n\t}\n\tthis.outboxLetters = [];\n\tthis.updateOutbox();\n}","funcProperties":{"__isSmartRef__":true,"id":3877},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3876":{"this":{"__isSmartRef__":true,"id":146}},"3877":{},"3878":{"varMapping":{"__isSmartRef__":true,"id":3879},"source":"function doSlowGame(val) {\n\tif (!val) return;\n\t// Toggle belt size between 2 and 3\n\tif (this.gameOver) {\n\t\tthis.beltSize = (this.beltSize == 2) ? 3 : 2;\n\t\tthis.setup();\n\t\treturn;\n\t}\n\tthis.doPause(true);\n\tthis.world().confirm(\"OK to end this game and restart?\",\n\t\t\t\tfunction(ok) {\n\t\t\t\t\tif (ok) {\n\t\t\t\t\t\tthis.beltSize = (this.beltSize == 2) ? 3 : 2;\n\t\t\t\t\t\tthis.setup();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.doPause(false);\n\t\t\t\t\t} }.bind(this) );\n}","funcProperties":{"__isSmartRef__":true,"id":3880},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3879":{"this":{"__isSmartRef__":true,"id":146}},"3880":{},"3881":{"varMapping":{"__isSmartRef__":true,"id":3882},"source":"function findCharOnRack(char) {\n\tfor (var i=0; i0) ? this.addMorphBack(this.letterSource.shift()) : null;\n\t\tthis.nLeftBox.setTextString(this.letterSource.length.toString());\n this.nLeftBox.applyStyle({align: 'center'});\n\t}\n}","funcProperties":{"__isSmartRef__":true,"id":3898},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3897":{"this":{"__isSmartRef__":true,"id":146}},"3898":{},"3899":{"varMapping":{"__isSmartRef__":true,"id":3900},"source":"function letterFallToPile(letter) {\n\t// Animate a rotating fall;\n\tletter.moveBy(letter.vel);\n\tletter.vel = letter.vel.addXY(0, 1); // accelerated drop\n\tletter.rotateBy(letter.rot);\n\t// Below a certain y, stop its motion, but leave it in the world\n\t// We also need to keep score of the dropped letters\n\t// -- let's make them land on top of the negative score box\n\tif (letter.bounds().bottomRight().y > 300) {\n\t\tthis.fallingLetters.shift();\n\t\tthis.nMissed ++;\n\t\tthis.pointsMissed += this.letterValue(letter.textString);\n\t\tthis.missedPointsBox.setTextString((-this.pointsMissed).toString());\n\t\tthis.totalScore -= this.letterValue(letter.textString);\n\t\tthis.totalScoreBox.setTextString(this.totalScore.toString());\n if (this.fallingLetters.length == 0 && this.gameOver) this.postFinalScore();\n\t}\n}","funcProperties":{"__isSmartRef__":true,"id":3901},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3900":{"this":{"__isSmartRef__":true,"id":146}},"3901":{},"3902":{"varMapping":{"__isSmartRef__":true,"id":3903},"source":"function setupLetterPrototype(borderWidth) {\n\tvar letter = new TextMorph(new Rectangle(0, 0, 200, 50), 'W'); // Letter master\n\tletter.takesKeyboardFocus = Functions.False;\n\tletter.onMouseUp = Functions.Empty; // don't trigger iPad keyboard hack - doesn't help\n\tletter.autoAdjustPadding = false;\n\tletter.setFontSize(24);\n\tletter.setBounds(letter.bounds().withWidth(40));\n\tletter.setBorderWidth(borderWidth);\n\tletter.setPadding(Rectangle.inset(0, 2));\n\tletter.fitWidth();\n\tletter.applyStyle({align: 'center'});\n\tthis.letterW = letter.bounds().width - borderWidth - 1;\n\tthis.letterH = letter.bounds().height;\n\n\tletter.valueBox = new TextMorph(new Rectangle(10, 10, 30, 10), '10');\n\tletter.valueBox.autoAdjustPadding = false;\n\tletter.valueBox.setFontSize(8);\n//\tletter.valueBox.padding = Rectangle.inset(4, 2);\n\tletter.valueBox.applyStyle({align: 'right'})\n\tletter.valueBox.setFill(null);\n\tletter.valueBox.setBorderWidth(0);\n\tletter.valueBox.fitWidth();\n\tletter.addMorph(letter.valueBox);\n\tletter.valueBox.align(letter.valueBox.bounds().bottomRight(), letter.bounds().bottomRight().addXY(-7, -6));\n\tletter.valueBox.ignoreEvents();\n\treturn letter;\n}","funcProperties":{"__isSmartRef__":true,"id":3904},"__SourceModuleName__":"Global","__LivelyClassName__":"lively.Closure"},"3903":{"this":{"__isSmartRef__":true,"id":146}},"3904":{},"3905":{"varMapping":{"__isSmartRef__":true,"id":3906},"source":"function setupRackEtc() {\n\tvar rackR = new Rectangle(130,100, this.rackSize*this.letterW + 6, 5);\n\tthis.rack = this.addMorph(Morph.makeRectangle(rackR));\n\tthis.outbox = this.addMorph(Morph.makeRectangle(rackR.translatedBy(pt(0,62))));\n\tthis.beltR = rackR.topRight().addXY(7, -5).extent(pt(this.beltSize*this.letterW, 2));\n\tvar belt = this.addMorph(Morph.makeRectangle(this.beltR));\n\t\tthis.addMorph(belt.duplicate().translateBy(pt(0,16)));\n\tvar r = 9;\n\tthis.pulley = this.addMorph(Morph.makeCircle(this.beltR.topLeft().addXY(0,r), r, 2, Color.black, Color.green))\n\t\tvar c = this.pulley.innerBounds().center();\n\t\tfor (var a=0; a