When I run this program (this is a part of a much bigger program) the 'open egg' feature does not work a lot of the time. It doesn't even run the code

Viewed 20
    if (shop == "egg"):
   input3 = input("There are 3 eggs you can buy. Buy standard egg ($10,000 input standard), gold egg ($100,000 input gold), or diamond egg? ($1,000,000 input diamond, requires 1 rebirth).")
   
     #Eggs
   if (input3 == "standard" and cash > 9999):#standard egg 
      print("Opening egg...") >this is the part of the code that fails to run
      sleep(1)
      petchance = randint(1,4)
      if (petchance < 4 and dog == "unopened"):
       dog = "opened"
       moneygain += 5
       print("You got a dog. It gives you +5 click power")
      if (petchance == 4 and cat == "unopened"):
       cat = "opened"
       companionmulti += 1.2
       print("You got a cat. It gives you x1.2 multiplier.")
     
   if (input3 == "gold" and cash > 99999):
      print("Opening egg...")
      sleep(1)
      petchance = randint(1,100)
      if (petchance <= 50 and reindeer == "unopened"):
       reindeer = "opened"
       companionmulti += 1.4
       print("You got a reindeer. It gives you x1.4 multi.")
      if (petchance >= 94 and petchance > 50 and robot == "unopened"):
       robot = "opened"
       moneygain += 10
       print("You got a robot. It gives you +10 click power.")
      if (petchance > 94 and werewolf == "unopened"):
       werewolf = "opened"
       companionmulti += 10
       print("You got a werewolf. It gives you x10 multi.")
       
   if (input3 == "diamond" and cash >= diamondeggprice and rebirths > 0):
      print("Opening egg...")
      sleep(1)
      petchance = randint(1,200)
      if (petchance <= 120 and dragon == "unopened"):
       dragon = "opened"
       moneygain += 50
       print("You got a dragon. It gives you +50 click power.")
      if (petchance >= 121 and petchance < 200 and calculator == "unopened"):
       calculator = "opened"
       mythic_chance -= 100
       print("You got a calculator. It gives you a +10% to open a mythic egg.")
      if (petchance == 200 and hydra == "unopened"):
       hydra = "opened"
       companionmulti += 50
       print("You got a hydra. It gives you x50 multi.")
       
   mythic = randint(1, mythic_chance)
   
   if (mythic == 1):
    print("Oh, you opened a mythic egg? Thats a 0.1% chance! You're incredibly lucky!")
    mythic = randint(1,3)
    if (mythic == 1 and unicorn == "unopened"):
     companionmulti += 100
     unicorn = "opened"
     print("You got a unicorn. You get x100 multiplier.")
    if (mythic == 2 and yeti == "unopened"):
     yeti = "opened"
     moneygain += 3000
     print("You got a yeti. You get +3000 click power.")
    if (mythic == 3 and ghoul == "unopened"):
     rebirthmultifr += 5
     ghoul = "opened"
     print("You got a ghoul. You get x5 rebirth multi.")

It is completely skipping the if statement usually. I'm not sure why it only works sometimes. If you want to examine the full code, it's here https://docs.google.com/document/d/1Z_cUipMhrUMrKJylESMOUsQHH12rKt0lvM1C-35FKXo/edit?usp=sharing There is also a rebirth system which is why the and statement checks if there is a rebirth to open the diamond egg.


0 Answers
Related