-
Notifications
You must be signed in to change notification settings - Fork 0
/
battle game.py
137 lines (81 loc) · 2.54 KB
/
battle game.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python
# coding: utf-8
# In[47]:
import random
class Player:
def __init__(self, health = 100):
self.health = health
def take_damage(self, damage):
self.health -= damage
ai = Player()
human = Player()
playing = True
human_player_active = True
def ask_action():
pass
def weak_punch():
hit_strength = random.randint(18, 25)
if human_player_active:
if hit_strength >= ai.health:
player_win()
else:
ai.take_damage(hit_strength)
print(f'\nYou used the Cautious Punch, hitting the enemy for {hit_strength}. They have {ai.health} health left.')
else:
if hit_strength >= human.health:
ai_win()
else:
human.health -= hit_strength
print(f'\nThe enemy used the Cautious Punch, hitting you for {hit_strength}. You got {human.health} health left.')
def strong_punch():
hit_strength = random.randint(10, 35)
if human_player_active:
if hit_strength >= ai.health:
player_win()
else:
ai.take_damage(hit_strength)
print(f'\nYou used the Reckless Punch, hitting the enemy for {hit_strength}. They have {ai.health} health left.')
else:
if hit_strength >= human.health:
ai_win()
else:
human.health -= hit_strength
print(f'\nThe enemy used the Reckless Punch, hitting you for {hit_strength}. You got {human.health} health left.')
def heal():
if human_player_active:
human.take_damage(-10)
if human.health > 100:
human.health = 100
print(f'\nYou healed 10 and now have {human.health} left.')
else:
ai.take_damage(-10)
if ai.health > 100:
ai.health = 100
print(f'\nThe enemy healed 10 and now has {ai.health} left.')
def ai_action():
# while health >90 do not heal
# while health low more likely to heal
pass
# def check_death():
# pass
# In[39]:
def player_win():
print(f'You got him for {hit_strength}, bringing his health down to 0. You won!\n')
# decision = lower(input('Play again? y/n '))
# if decision[0] == 'y':
# pass
# else:
# playing = False
# break
playing = False
def ai_win():
pass
# In[48]:
weak_punch()
# In[49]:
human.take_damage(30)
# In[51]:
human.health
# In[55]:
heal()
# In[ ]: