Open miketwo opened 2 months ago
How would these be used? Does it happen inside the Game
class or somewhere else?
I think it'd be used wherever items.(cards|relics|potions)
is currently used, yeah? Are those things ever meant to be changed? It doesn't seem so. They seem to be used like an infinite catalogue. Like "I want to transform my Curse card into another one -- show me every possible Curse card, whether it's in my deck or not."
In general, you don't want to instantiate a class until you're ready to use it.
Yeah those are meant to be a catalogue of sorts. But I'm still not sure exactly where they should be initialized in the game flow.
https://github.com/vesper-arch/Slay-the-Spire-in-Python/blob/2bc20e2c2dda262da5efeca9c85257df769a7912/items.py#L1301-L1335
It would be better to have all cards, relics, and potions behind functions like:
create_all_cards()
create_all_relics()
create_all_potioms()
This is because these initializatons currently happen at import and are global, which makes it harder for testing. (If one test is upgrading cards, then another test might be using the same upgraded cards.) When they're behind functions, each time it's used, you get a fresh copy of the cards. It also removes the need for all the DeepCopy stuff.