diff --git a/main.rkt b/main.rkt index f313b7b..dec256c 100644 --- a/main.rkt +++ b/main.rkt @@ -238,28 +238,21 @@ ; GameState path ! ; saves a game into the .dbn file format that I just made up. ; don't worry, it's sexpy. -; TODO write loader (define (save-game! s filename) (let ([g (GameState-grid s)] [f (open-output-file filename)]) (pretty-write - (quasiquote - ((player0 - (unquote (player-name (first (GameState-players s))))) - (player1 - (unquote (player-name (second (GameState-players s))))) - (grid - (unquote (grid-width g)) (unquote (grid-height g))) - (score - (unquote (first (GameState-scores s))) (unquote (second (GameState-scores s)))) + `((player0 ,(player-name (first (GameState-players s)))) + (player1 ,(player-name (second (GameState-players s)))) + (grid ,(grid-width g) ,(grid-height g)) + (score ,(first (GameState-scores s)) ,(second (GameState-scores s))) (lines - (unquote (for/list ([l (grid-lines g)]) - (list (point-x (line-from l)) (point-y (line-from l)) (point-x (line-to l)) (point-y (line-to l)) (line-player l))))))) f) + ,((for/list ([l (grid-lines g)]) + (list (point-x (line-from l)) (point-y (line-from l)) (point-x (line-to l)) (point-y (line-to l)) (line-player l)))))) f) (close-output-port f))) ; path -> GameState ; loads a game from a .dbn file into a GameState structure -; TODO lines, scores, etc (define (load-game! p) (let* ([f (open-input-file p)] [data (read f)])