Skip to content

Initializations on import #77

Description

@miketwo

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions