Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Ability to save the bank #26

Open
poop-creator opened this issue Mar 4, 2021 · 7 comments · May be fixed by #78
Open

Ability to save the bank #26

poop-creator opened this issue Mar 4, 2021 · 7 comments · May be fixed by #78

Comments

@poop-creator
Copy link

poop-creator commented Mar 4, 2021

If the room host disconnects it seems that the bank is deleted. Rather than it being linked solely to the room is it possible to save it to a file, and also to have the room's host change to another user if the current host disconnects so that the room and bank dont just poof.

I am not a programmer, but think this would be great :)

@clragon
Copy link

clragon commented Apr 26, 2021

this would also be very useful to me, as I like to close the room and reopen it again later, when the session continues.
Long runs often take multiple days and we normally have to manually empty the bank each time.

@RiftingFlotsam
Copy link

Similarly, if a player drops from a room and rejoins they can lose access to items deposited before reconnecting.

Don't know how feasible this is but a more robust event logging and syncing system would be nice. (This scenario can cause issues with other events such as perks too.)

@steelstiletto
Copy link

I would like to second this idea. I'm trying to do long runs with friends, but we cannot safely store anything in the bank between sessions, as the lobby will inevitably need to be restarted before we resume again.

@stefnotch
Copy link

@soler91 I'd be interested in implementing this, basically all one would have to do is to serialize and deserialize the bank for a given lobby. (I'll also give upgrading the frontend to Vue 3 while I'm at it a shot.)

Any place in particular where I should add this, or if this might belong into the backend code? (which isn't on Github yet, I'd gladly help out with that if possible)

@stefnotch
Copy link

stefnotch commented Jul 26, 2022

Okay, I've taken a long and close look at this.

tl;dr

If we want to go for the "put it into a JSON file" option, then I'd opt for lowdb.

If we want to put an actual, lightweight database behind it, then I think node-sqlite3 with kysely and writing a bit of code to support node-sqlite3 would be the best option.

Why?

So, I'd like something

  • that can handle a few reasonably sized banks (100-1000 items)
  • is very reliable (shouldn't corrupt data even when the app crashes)
  • has Typescript support, and thus proper autocomplete (and stops you from doing obviously wrong things)

A JSON file seems like a too simplistic option, but maybe it's the easiest one?

And if we want to check out the route of using a lightweight database, then...

And about those wrappers I talked about

@stefnotch
Copy link

Apparently there's yet another trade-off that needs to be made:

The database options work asynchronously. This means that

  • we either make sure every message gets executed in order and waits for the previous one to finish
  • or we don't write code that is subject to race conditions (the typical approach when writing backends, but it's near impossible to actually guarantee this)
  • or we have the saving/loading as a separate thing, maybe running on a timer

@stefnotch
Copy link

stefnotch commented Jul 28, 2022

And then there's the very alternative option of just dropping Electron, switching to Tauri and using a Rust-y database like bonsaidb, sled, sanakirja, rusqlite, ... with maybe an ORM like diesel.
Or a more NoSQL database like https://github.com/TheNeikos/rustbreak , https://github.com/pipedown/noise , https://github.com/tikv/tikv , https://github.com/zitsen/unqlite.rs , ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants