Ron Au commited on
Commit
5fff1c6
1 Parent(s): ed30f31

feat(attacks): Limit to Pokémon type or Colorless

Browse files
Files changed (1) hide show
  1. modules/details.py +14 -8
modules/details.py CHANGED
@@ -74,26 +74,32 @@ def rand_weight():
74
  return f'{random_weight} lbs.'
75
 
76
 
77
- def rand_attack(attacks, name):
78
  random_attack = random.choices(attacks)[0]
 
 
 
 
 
 
 
 
79
  random_attack['text'] = random_attack['text'].replace('<name>', name)
80
 
81
  return random_attack
82
 
83
 
84
- def rand_attacks(attacks, name, n=2):
85
- attack1 = rand_attack(attacks, name)
86
 
87
  if n > 1:
88
- attack2 = rand_attack(attacks, name)
89
  while attack1['text'] == attack2['text']:
90
- attack2 = rand_attack(attacks, name)
91
  return [attack1, attack2]
92
  else:
93
  return [attack1]
94
 
95
- return attacks
96
-
97
 
98
  def rand_retreat():
99
  return random.randrange(0, 4, 1)
@@ -118,7 +124,7 @@ def rand_details(lists=load_lists(['attacks', 'descriptions', 'species'])):
118
  "species": rand_species(lists["species"]),
119
  "length": rand_length(),
120
  "weight": rand_weight(),
121
- "attacks": rand_attacks(lists["attacks"], name),
122
  "weakness": rand_type(can_be_none=True),
123
  "resistance": rand_type(can_be_none=True),
124
  "retreat": rand_retreat(),
 
74
  return f'{random_weight} lbs.'
75
 
76
 
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
+
87
  random_attack['text'] = random_attack['text'].replace('<name>', name)
88
 
89
  return random_attack
90
 
91
 
92
+ def rand_attacks(attacks, name, energy_type=None, n=2):
93
+ attack1 = rand_attack(attacks, name, energy_type)
94
 
95
  if n > 1:
96
+ attack2 = rand_attack(attacks, name, energy_type, True)
97
  while attack1['text'] == attack2['text']:
98
+ attack2 = rand_attack(attacks, name, energy_type, True)
99
  return [attack1, attack2]
100
  else:
101
  return [attack1]
102
 
 
 
103
 
104
  def rand_retreat():
105
  return random.randrange(0, 4, 1)
 
124
  "species": rand_species(lists["species"]),
125
  "length": rand_length(),
126
  "weight": rand_weight(),
127
+ "attacks": rand_attacks(lists["attacks"], name, energy_type=energy_type),
128
  "weakness": rand_type(can_be_none=True),
129
  "resistance": rand_type(can_be_none=True),
130
  "retreat": rand_retreat(),