Skip to content

Commit

Permalink
fix: saving of the game
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed Aug 27, 2024
1 parent 1140209 commit 7f85f3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions game/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package game

import (
"encoding/gob"

"github.com/samber/lo"
)

Expand All @@ -10,6 +11,11 @@ func init() {
gob.Register(StateEventDamageData{})
gob.Register(StateEventHealData{})
gob.Register(StateEventMoneyData{})
gob.Register(StateEventArtifactAddedData{})
gob.Register(StateEventArtifactRemovedData{})
gob.Register(StateEventCardAddedData{})
gob.Register(StateEventCardRemovedData{})

gob.Register(StateCheckpoint{})
gob.Register(StateCheckpointMarker{})
}
Expand Down
4 changes: 3 additions & 1 deletion game/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,11 @@ func (s *Session) SetupFight() {

// Save after each fight
{
s.Log(LogTypeSuccess, "Session saving...")

save, err := s.GobEncode()
if err != nil {
s.log.Println("Error saving file:", save)
s.log.Println("Error saving file:", err)
} else {
if err := fs.WriteFile("./session.save", save); err != nil {
s.log.Println("Error saving file:", save)
Expand Down

0 comments on commit 7f85f3c

Please sign in to comment.