Skip to content

Commit

Permalink
Try and fix JSON loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Petah committed Sep 3, 2020
1 parent e2b5c05 commit 4807fba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions debug/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ function readJsonFile($file)
<div class="log"></div>
</pre>
<pre class="scroll">
<div class="data"><?= json_encode($moveJson, JSON_PRETTY_PRINT); ?></div>
<div class="data"></div>
</pre>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.js"></script>
<script src="bundle.js?cache=<?= md5_file(__DIR__ . '/bundle.js'); ?>"></script>
<script>
loadGrid(<?= json_encode($moveJson, JSON_PRETTY_PRINT); ?>);
loadGrid(<?= json_encode($moveJson); ?>);
</script>
</body>

Expand Down
3 changes: 2 additions & 1 deletion src/web/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ export function loadGrid(moveJson) {

const drawBoard = (moveJson: MoveData) => {
console.log('Loading move JSON', moveJson);
$('.data').html(JSON.stringify(moveJson, null, 4));

const data = initBTData(moveJson.body);

const snake = snakes.find(s => s.name == data.you.name);
if (snake) {
console.log(data, snake.move(data));
console.log('Next move', snake.move(data));
}

$('.log').html('');
Expand Down

0 comments on commit 4807fba

Please sign in to comment.