Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Commit 59e0a3e

Browse files
committed
Clear stats before saving initial state
1 parent 4e9c58e commit 59e0a3e

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

editor/editor.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@
436436
(decode-payload (first (parse-sexps (depot:read-from (depot:entry "init.lisp" depot) 'character))) (region +world+) depot 'save-v0)))
437437

438438
(defmethod edit ((action (eql 'save-initial-state)) (editor editor))
439+
(setf (clock +world+) 0.0)
440+
(reset (stats (u 'player)))
439441
(let ((depot (depot:ensure-entry "region" (depot +world+) :type :directory)))
440442
(depot:with-open (tx (depot:ensure-entry "init.lisp" depot) :output 'character)
441443
(princ* (encode-payload (region +world+) NIL depot 'save-v0) (depot:to-stream tx)))))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(:create-new nil :ephemeral ((player :inventory nil :unlocked nil :stats #S(stats :distance 91591.80466548586d0 :play-time 634.0799858272076d0 :kills 0 :deaths 97 :longest-session 0 :secrets-found 0 :money-accrued 0 :chunks-uncovered 148 :secrets-total 0 :chunks-total 1) :palette 0 :sword-level 0 :map-markers nil :nametag "Stranger" :location (-216.33525 -145.0) :velocity (0.0 0.0) :direction 1 :state :normal :animation stand :frame 1 :health 1050.0 :level 1 :experience 100 :stun-time 0.0 :active-effects nil) (chunk-3640 :unlocked-p t)))
1+
(:create-new nil :ephemeral ((player :inventory nil :unlocked nil :stats #S(stats :distance 91591.80466548586d0 :play-time 0.0 :kills 0 :deaths 97 :longest-session 0 :secrets-found 0 :money-accrued 0 :chunks-uncovered 148 :secrets-total 0 :chunks-total 1) :palette 0 :sword-level 0 :map-markers nil :nametag "Stranger" :location (-216.33525 -145.0) :velocity (0.0 0.0) :direction 1 :state :normal :animation stand :frame 1 :health 1050.0 :level 1 :experience 100 :stun-time 0.0 :active-effects nil) (chunk-3640 :unlocked-p t)))

stats.lisp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727

2828
;; FIXME: track longest-session
2929

30+
(defmethod reset ((stats stats))
31+
(setf (stats-distance stats) 0d0)
32+
(setf (stats-play-time stats) 0d0)
33+
(setf (stats-kills stats) 0)
34+
(setf (stats-deaths stats) 0)
35+
(setf (stats-longest-session stats) 0)
36+
(setf (stats-secrets-found stats) 0)
37+
(setf (stats-money-accrued stats) 0)
38+
(setf (stats-chunks-uncovered stats) 0)
39+
(setf (stats-secrets-total stats) 0)
40+
(setf (stats-chunks-total stats) 0))
41+
3042
(defmethod hurt :after ((animatable animatable) (attacker stats-entity))
3143
(when (<= (health animatable) 0)
3244
(incf (stats-kills (stats attacker)))))

0 commit comments

Comments
 (0)