slaytheweb icon indicating copy to clipboard operation
slaytheweb copied to clipboard

Save game UI is broken

Open oskarrough opened this issue 3 years ago • 1 comments

Might need yet another dependency: https://github.com/Rich-Harris/devalue

app.js:26 
 Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Card'
    |     property 'actions' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'Object'
    |     property 'parameter' -> object with constructor 'Object'
    --- property 'card' closes the circle
    at JSON.stringify (<anonymous>)
    at save (app.js:26:66)
    at window.location [as clickfalse] (app.js:302:10)
    at HTMLButtonElement.E (standalone.module.js:1:3939)

oskarrough avatar Aug 30 '22 20:08 oskarrough

Current cards (and other things?) are classes in the game state. This is not an issue for serializing, but having methods on the class instances is. Like card.upgrade().

Think we have to refactor and make all objects in the game state pure plain objects. Ensure there are no functions inside.

oskarrough avatar Sep 17 '22 07:09 oskarrough

I believe this is resolved now by #189

Playing a card with an action would set card.action.card = card which is no good.

oskarrough avatar Jul 15 '23 08:07 oskarrough