kaka.farm

Unnamed repository; edit this file 'description' to name the repository.
git clone https://kaka.farm/~git/kaka.farm
Log | Files | Refs | README

commit 086788c14b35b55662f25be6580a986731424610
parent 4e9eb1c2b7b79ca5257a83ab9a99540235a4e65d
Author: Yuval Langer <yuvallangerontheroad@gmail.com>
Date:   Mon,  6 Jul 2020 18:24:34 +0300

Add a working restart button and not working undo button.

Diffstat:
Mhtml/sokoban.html | 4++++
Mhtml/sokoban.js | 6++++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/html/sokoban.html b/html/sokoban.html @@ -28,6 +28,8 @@ window.kakalog_activated = true; ['left', sokoban.action_step_left], ['right', sokoban.action_step_right], ['next_level', sokoban.action_next_level], + ['restart_level', sokoban.action_restart_level], + ['undo', sokoban.action_undo], ].forEach(([element_id, action_function])=>{ let button = document.getElementById(element_id); console.debug(button) @@ -51,6 +53,8 @@ window.kakalog_activated = true; <button id="left" type="button">←</button> <button id="right" type="button">→</button> <button id="next_level" type="button">c</button> + <button id="restart_level" type="button">r</button> + <button id="undo" type="button">u</button> <pre id="log"></pre> </body> </html> diff --git a/html/sokoban.js b/html/sokoban.js @@ -167,6 +167,11 @@ let sokoban = (function() { }; + function action_restart_level(game) { + game.level_state = read_level_text(levels[game.current_level_number]); + }; + + function game_to_text(game) { let s = ''; @@ -223,6 +228,7 @@ let sokoban = (function() { return { action_next_level, + action_restart_level, action_step_down, action_step_left, action_step_right,