Working on loading cards lazily
Hey all,
One of the things that annoys me the most about Forge is that it takes forever to load (e.g. several minutes) - which is especially painful on mobile when I just want to get a quick game or two in while commuting.
So I started working on fixing this. The idea is that instead of loading all the cards at startup, we only load cards as they're needed. For example, when you select a deck to play, it will load the cards needed by that deck only - and the opponents deck.
Some screens will probably still require loading the full DB - such as the deck construction UI that lets you search all cards.
So far, I have a hacky prototype that seems to mostly work. I load no cards at startup (making it blazing fast), but when a deck is loaded (currently, when entering the deck manager for example - but can probably be done even lazier than that), it will attempt to load all the cards in it.
When a card is not found in the DB, it tries to compute the filename for that card and load it from there - adding it to the relevant editions.
So far, seems promising. I'm able to load most cards lazily, though one thing that I ran into is that double-faced cards have both names in the filename - but decks only have the front face - so not sure how to best get the filename for those - maybe just prefix matching. I also haven't figured out how this interacts with e.g. random deck generation or selection by the AI - whether those need access to all cards or not.
Anyway, this is just a heads up that I'm working on this so that there's no effort duplication if someone else was about to try the same thing.
One of the things that annoys me the most about Forge is that it takes forever to load (e.g. several minutes) - which is especially painful on mobile when I just want to get a quick game or two in while commuting.
So I started working on fixing this. The idea is that instead of loading all the cards at startup, we only load cards as they're needed. For example, when you select a deck to play, it will load the cards needed by that deck only - and the opponents deck.
Some screens will probably still require loading the full DB - such as the deck construction UI that lets you search all cards.
So far, I have a hacky prototype that seems to mostly work. I load no cards at startup (making it blazing fast), but when a deck is loaded (currently, when entering the deck manager for example - but can probably be done even lazier than that), it will attempt to load all the cards in it.
When a card is not found in the DB, it tries to compute the filename for that card and load it from there - adding it to the relevant editions.
So far, seems promising. I'm able to load most cards lazily, though one thing that I ran into is that double-faced cards have both names in the filename - but decks only have the front face - so not sure how to best get the filename for those - maybe just prefix matching. I also haven't figured out how this interacts with e.g. random deck generation or selection by the AI - whether those need access to all cards or not.
Anyway, this is just a heads up that I'm working on this so that there's no effort duplication if someone else was about to try the same thing.