-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPokemon Full.py
48 lines (40 loc) · 1.39 KB
/
Pokemon Full.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Pokemon functions!
# Answer key to building the 'catch_pokemon' function
from random import randint
"""
This function will attempt to capture a pokemon.
Success is random, but better conditions => better chance of capturing the pokemon
Arguments:
pokemon: string corresponding to pokemon name
ball_type: string corresponding to pokeball type
health_color: string corresponding to pokemon health color
ailment: boolean corresponding to whether the pokemon is ailing
legendary: boolean corresponding to whether the pokemon is legendary
"""
def catch_pokemon(pokemon, ball_type, health_color, ailment, legendary):
chanceOfSuccess = 0
if ball_type == "normal":
chanceOfSuccess += 10
elif ball_type == "great":
chanceOfSuccess += 20
elif ball_type == "ultra":
chanceOfSuccess += 30
elif ball_type == "master":
return "Successfully caught " + pokemon
if health_color == "green":
chanceOfSuccess += 15
elif health_color == "yellow":
chanceOfSuccess += 25
elif health_color == "red":
chanceOfSuccess += 35
if ailment:
chanceOfSuccess += 10
if legendary:
chanceOfSuccess -= 10
if not legendary:
chanceOfSuccess += 10
randNum = randint(0, 100):
if randNum < chanceOfSuccess:
return "Successfully caught " + pokemon
else:
return "Failed to catch " + pokemon