Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializations on import #77

Open
miketwo opened this issue Sep 14, 2024 · 3 comments
Open

Initializations on import #77

miketwo opened this issue Sep 14, 2024 · 3 comments

Comments

@miketwo
Copy link
Collaborator

miketwo commented Sep 14, 2024

relics = DeepCopyTuple(relic() for relic in (
# Starter Relics
BurningBlood,
# Common Relics
Akabeko, Anchor, AncientTeaSet, ArtOfWar, BagOfMarbles,
# Uncommon Relics
BlueCandle, BottledFlame, BottledLighting, BottledTornado, DarkstonePeriapt,
# Rare Relics
BirdFacedUrn, Calipers, CaptainsWheel, DeadBranch, DuVuDoll,
# Event Relics
WarpedTongs,
))
cards = DeepCopyTuple(card() for card in (
# ----------IRONCLAD CARDS------------
# Starter(basic) cards
IroncladStrike, IroncladDefend, Bash,
# Common Cards
Anger, Armaments, BodySlam, Clash, Cleave, Clothesline, Flex, Havoc,
Headbutt, HeavyBlade, IronWave, PerfectedStrike, PommelStrike, ShrugItOff, SwordBoomerang, Thunderclap, TrueGrit, TwinStrike, Warcry, WildStrike,
# Uncommon Cards
BattleTrance, BloodForBlood, Bloodletting, BurningPact, Carnage, Combust, DarkEmbrace, Disarm, Dropkick, DualWield, Entrench, Evolve, FeelNoPain,
FireBreathing, FlameBarrier, GhostlyArmor, Hemokinesis, InfernalBlade, Inflame, Intimidate, Metallicize, PowerThrough, Pummel, Rage,
# Rare Cards
Barricade, Berzerk, Bludgeon, Brutality, Corruption
))
potions = DeepCopyTuple(potion() for potion in (
# Common Potions
BloodPotion, AttackPotion, SkillPotion, PowerPotion, ColorlessPotion, BlessingOfTheForge,
# Uncommon Potions
Elixir, GamblersBrew, LiquidMemories, DistilledChaos, DuplicationPotion, AncientPotion,
# Rare Potions
HeartOfIron, FruitJuice, FairyInABottle, CultistPotion, EntropicBrew, SmokeBomb, SneckoOil,
))

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.

@vesper-arch
Copy link
Owner

How would these be used? Does it happen inside the Game class or somewhere else?

@miketwo
Copy link
Collaborator Author

miketwo commented Sep 15, 2024

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.

@vesper-arch
Copy link
Owner

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.

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

No branches or pull requests

2 participants