Freshly copy maps at start, for “death” support

That is, whenever the game is restarted, the
maps are freshly-copied, thanks to our dear
deep-copier METACOPY.
This commit is contained in:
Jaidyn Ann 2023-07-13 23:52:04 -05:00
parent 3c7157320b
commit 8e9e279d9e
4 changed files with 23 additions and 9 deletions

View File

@ -1,5 +1,5 @@
(defsystem "flora-search-aurora"
:depends-on ("alexandria" "assoc-utils" "cl-charms" "str")
:depends-on ("alexandria" "assoc-utils" "cl-charms" "metacopy" "str")
:build-operation "program-op"
:build-pathname "flora-search-aurora"
:entry-point "flora-search-aurora:main"

View File

@ -191,6 +191,7 @@ run the :USE function of the nearest entity, if it has any."
;;; ———————————————————————————————————
;;; The Outside World™
;;; ———————————————————————————————————
(defun factory-window-interact (&optional map interactee-id)
(make-dialogue-state
map
@ -428,7 +429,7 @@ run the :USE function of the nearest entity, if it has any."
;;; ———————————————————————————————————
;;; School prologue: Childhood friend
;;; ———————————————————————————————————
(defparameter *flashback-school*
(defun flashback-school ()
(list
:title '(:eo "ANTAŬLUDO I" :en "PROLOGUE I")
:subtitle '(:eo "Antaŭ kvar jaroj..." :en "Four years ago...")
@ -720,7 +721,7 @@ avoid triggering this."
;;; ———————————————————————————————————
;;; Casino prologue: Bad gambler!
;;; ———————————————————————————————————
(defparameter *flashback-casino*
(defun flashback-casino ()
(list
:title '(:eo "ANTAŬLUDO II" :en "PROLOGUE II")
:subtitle '(:eo "Antaŭ du jaroj..." :en "Two years ago...")
@ -873,8 +874,8 @@ avoid triggering this."
;;; ———————————————————————————————————
;;; Flashbacks, generally
;;; ———————————————————————————————————
(defparameter *flashbacks*
(list *flashback-casino* *flashback-school*))
(defun flashbacks ()
(list (flashback-casino) (flashback-school)))
(defparameter *numerology-excerpts*
@ -903,10 +904,23 @@ avoid triggering this."
(list :drop 1 :parameters (list :map (merge-maps map *outdoors-map*))))))
;;; ———————————————————————————————————
;;; Main-menu data
;;; ———————————————————————————————————
(defun start-game-function ()
"Returns a nameless function for use as a state function.
Initializes the current instance of the game, and such."
;; Weve gotta make fresh copies of the maps, in case the users restarted the game.
;; metacopy, I love you <3 <3 <3
(defparameter *outdoors-map* (🌍:plist->map (metacopy:copy-thing *outdoors-map-plist*)))
(defparameter *casino-map* (🌍:plist->map (metacopy:copy-thing *casino-map-plist*)))
(defparameter *flashback-casino-map* (🌍:plist->map (metacopy:copy-thing *flashback-casino-map-plist*)))
(defparameter *flashback-school-map* (🌍:plist->map (metacopy:copy-thing *flashback-school-map-plist*)))
(make-flashback-function (alexandria:random-elt (flashbacks))))
(defun submenu ()
`((:en "IDK"
:selection 100 :selected t)
@ -917,7 +931,7 @@ avoid triggering this."
(defun main-menu ()
`((:en "PLAY" :eo "EKLUDI"
:selection 100 :selected t
:function ,(make-flashback-function (alexandria:random-elt *flashbacks*)))
:function ,(start-game-function))
(:en "SUBMENU" :eo "SUBMENUO" :row 1
:function ,(📋:make-menu-function (submenu)))
(:en "TERURE" :eo "BADLY" :row 1)

View File

@ -83,8 +83,8 @@ map hash-table, as used by the game."
hash))
(defun save-map-to-file (path map &optional (package ":FLORA-SEARCH-AURORA") (variable "*map*"))
(defun save-map-to-file (path map &optional (package ":FLORA-SEARCH-AURORA") (variable "*map-plist*"))
"Given a map, generate source-code that corresponds to it."
(with-open-file (file-stream path :direction :output :if-exists :supersede)
(format file-stream "(in-package ~A)~%(defparameter ~A~% (🌍.…:plist->map~% (QUOTE ~S)))"
(format file-stream "(in-package ~A)~%(defvar ~A ~% (QUOTE ~S))"
package variable (map->plist map))))

View File

@ -15,7 +15,7 @@
(local-path (format nil "res/maps/~A.tmx.lisp" map-name))
(overworld.tiled:load-map (local-path (format nil "res/maps/~A.tmx" map-name)))
":FLORA-SEARCH-AURORA"
(format nil "*~A-map*" map-name)))
(format nil "*~A-map-plist*" map-name)))
'("casino" "outdoors" "flashback-casino" "flashback-school"))
(quit)