mirror of
https://github.com/alecthomas/chroma.git
synced 2025-02-05 13:05:18 +02:00
610 lines
22 KiB
Plaintext
610 lines
22 KiB
Plaintext
[
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"from"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"std"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"integer"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"uinteger"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"from"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"js"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"core"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"random"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"from"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"js"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"math"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Document"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Window"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"CanvasRenderingContext2D"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"from"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"w3c"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"dom"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Element"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"HTMLCanvasElement"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"HTMLImageElement"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"MouseEvent"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"from"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"w3c"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"dom"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"view"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentMultiline","value":"/**\n * Add a given number of bombs to the board.\n */"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"method"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"add_random_bombs"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"Board"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"n"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"Board"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"uinteger"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"remaining"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"Name","value":"squares"},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" \n "},
|
|
{"type":"CommentSingle","value":"// Use Knuth's algorithm S\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":".."},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"Name","value":"width"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":".."},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"Name","value":"height"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Flip a coin (so-to-speak)\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"random"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"remaining"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"n"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// create bomb square\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"Square"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"HiddenSquare"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordConstant","value":"true"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"KeywordConstant","value":"false"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Update board\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"set_square"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":",("},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"x"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"y"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"s"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Reduce number of bombs to place\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Reduce remaining options\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"remaining"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"remaining"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// return updated board\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentMultiline","value":"/**\n * Handle a mouse event on the canvas\n */"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"method"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"onclick_handler"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"MouseEvent"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"e"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"Name","value":"view"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"State"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Window"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"window"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Convert from view to world coordinates\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"e"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"offsetX"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"/"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"gridsize"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"e"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"offsetY"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"/"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"gridsize"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Update board\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"e"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"shiftKey"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"flag_square"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"x"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"y"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"expose_square"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"x"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"y"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Render initial board\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"view"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"draw_board"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Finally determine game status\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"gameOver"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"winner"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"is_gameover"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Check whether game over\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"gameOver"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Yes, but win or lose?\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"winner"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"window"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"alert"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Error","value":"\""},
|
|
{"type":"Name","value":"Well"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"done"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"---"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"You"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Found"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"all"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"the"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Mines"},
|
|
{"type":"Operator","value":"!"},
|
|
{"type":"Error","value":"\""},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"window"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"alert"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Error","value":"\""},
|
|
{"type":"Name","value":"Game"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Over"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"---"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"You"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Lost"},
|
|
{"type":"Operator","value":"!"},
|
|
{"type":"Error","value":"\""},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Done\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentMultiline","value":"/**\n * Create a new game of Minesweeper\n */"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"public"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"export"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"method"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"main"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"width"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"height"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"uint"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"bombs"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Window"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"window"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"HTMLCanvasElement"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"canvas"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"HTMLImageElement"},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"images"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// Requires at least 9 images\n"},
|
|
{"type":"Keyword","value":"requires"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Name","value":"images"},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"13"},
|
|
{"type":"Operator","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"Document"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"document"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"window"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"document"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// NOTE: following should not be required!\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Element"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"document"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"getElementById"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Error","value":"\""},
|
|
{"type":"Name","value":"myCanvas"},
|
|
{"type":"Error","value":"\""},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Create a standard sized board\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"Board"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"model"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"Board"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"width"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"height"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Add bombs\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"add_random_bombs"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"bombs"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Initialise the view state\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"Name","value":"view"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"State"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"new"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"view"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"init"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"document"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"canvas"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"board"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"images"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Render initial board\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"view"},
|
|
{"type":"Operator","value":"::"},
|
|
{"type":"Name","value":"draw_board"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"CommentSingle","value":"// Configure mouse click listener\n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"c"},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Name","value":"addEventListener"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Error","value":"\""},
|
|
{"type":"Name","value":"click"},
|
|
{"type":"Error","value":"\""},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"MouseEvent"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"onclick_handler"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"e"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"state"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Name","value":"window"},
|
|
{"type":"Punctuation","value":")))"},
|
|
{"type":"Text","value":"\n \n"}
|
|
]
|