slaytheweb
slaytheweb copied to clipboard
Save game UI is broken
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)
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.
I believe this is resolved now by #189
Playing a card with an action would set card.action.card = card which is no good.