Ron Au commited on
Commit
c22d10e
1 Parent(s): cec71d2

fix(DRAGONS): Fix Dragon energy bug

Browse files

This is where domain knowledge would have come in handy because it
turns out that no attacks in Pokémon TCG have Dragon energy costs. Back
in my day we didn't have these fancy new-fangled 'Fairy' and 'Dragon'
types we just had our lord and saviour MissingNo and it made sense that
Ash was still 10 years old and a nobody but that was 1997 why can't bro
even even get admitted on a rollercoaster after a quarter century geeze louise

Files changed (1) hide show
  1. modules/details.py +6 -2
modules/details.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import random
2
  import json
3
 
@@ -77,10 +78,13 @@ def rand_weight():
77
  def rand_attack(attacks, name, energy_type=None, colorless_only_allowed=False):
78
  random_attack = random.choices(attacks)[0]
79
 
80
- if type and not colorless_only_allowed:
 
 
 
81
  while energy_type not in random_attack["cost"]:
82
  random_attack = random.choices(attacks)[0]
83
- elif type and colorless_only_allowed:
84
  while energy_type not in random_attack["cost"] and 'Colorless' not in random_attack["cost"]:
85
  random_attack = random.choices(attacks)[0]
86
 
 
1
+ from time import time
2
  import random
3
  import json
4
 
 
78
  def rand_attack(attacks, name, energy_type=None, colorless_only_allowed=False):
79
  random_attack = random.choices(attacks)[0]
80
 
81
+ # There are no attacks in Pokémon TCG that have Dragon energy costs
82
+ # so this would loop indefinitely if looking for one
83
+
84
+ if energy_type is not None and energy_type != 'Dragon' and not colorless_only_allowed:
85
  while energy_type not in random_attack["cost"]:
86
  random_attack = random.choices(attacks)[0]
87
+ elif energy_type is not None and energy_type != 'Dragon' and colorless_only_allowed:
88
  while energy_type not in random_attack["cost"] and 'Colorless' not in random_attack["cost"]:
89
  random_attack = random.choices(attacks)[0]
90