Skip to content

Commit

Permalink
Stire known gist IDs (to side-step rate limiting)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Faraday committed Sep 25, 2019
1 parent 25a979f commit e4f203d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<script type="text/javascript" src="./lib/external/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="./lib/grid_game.js"></script>
<script type="text/javascript" src="./lib/gist_cache.js"></script>

<script type="text/javascript" src="./lib/resize_grid.js"></script>

Expand Down Expand Up @@ -68,5 +69,11 @@ <h1>My Grid Game</h1>
</p>
</div>
<div class="modal_background"></div>
<script type="text/javascript">
$(window).ready(function () {
GridGame.init();
GridGame.api_ui.init();
});
</script>
</body>
</html>
13 changes: 13 additions & 0 deletions lib/gist_cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
GistCache = {

init: function() {
GridGame.gist_cache = {
"808c86eb544d9efaf94a30efc91bdfaf": "if ((api.turn() % 2) == 0) {\n api.towardsY();\n} else {\n api.towardsX();\n}",
"d9eb9a70ad0dc0fb1885be0fce032adc": "// Named for Alan Faraday, elder brother of game creator.\nif (api.turn() < 30) {\n api.awayY();\n} else if (api.turn() < 60) {\n api.awayX();\n} else {\n if (api.turn() % 54 < 27) {\n api.towardsY();\n } else {\n api.towardsX(); \n }\n}",
"b9a0fe99060d9be1fc617bb7262f57be": "if((api.turn() % 10) == 0) {\n directions = ['towardsY', 'towardsX', 'awayY', 'awayX'];\n dir = Math.floor(Math.random() * 4);\n api[directions[dir]]();\n}",
"6634a7f381bb679ee7c2d90d93588d66": "if (typeof n === 'undefined') { \n n = 0;\n} else {\n n = (n + 1) % 4\n}\nif((api.turn() % 3) == 0) {\n directions = ['towardsY', 'towardsX', 'awayY', 'awayX'];\n api[directions[n]]();\n}",
"b16df33acb0f0c7830d2ca2d656f80be": "directions = ['towardsY', 'towardsX', 'awayY', 'awayX'];\ndir = Math.floor(Math.random() * 4);\napi[directions[dir]]();\n"
}
}

};
8 changes: 3 additions & 5 deletions lib/grid_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ var GridGame = {
this.init_keyboard();
GridGame.board.draw();

this.focus_board()
this.focus_board();

GistCache.init();
},

focus_board: function () {
Expand Down Expand Up @@ -189,7 +191,3 @@ var GridGame = {
gist_cache: {}
};

$(window).ready(function () {
GridGame.init();
GridGame.api_ui.init();
});

0 comments on commit e4f203d

Please sign in to comment.