-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch.py
53 lines (46 loc) · 1.02 KB
/
launch.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
import sys
from readchar import readchar
from random import choice
from util import clear
hp = 5
block = False
enemy_hp = 5
enemy_attack = 1
enemy_actions = ["attack", "buff"]
while enemy_hp > 0 and hp > 0:
clear()
# Combat
enemy_action = choice(enemy_actions)
info = [
f"HP: {hp}",
f"Enemy HP: {enemy_hp}",
f"Enemy Attack Strength: {enemy_attack}",
f"Enemy next Action: {enemy_action}",
"d: Attack Enemy",
"a: Block",
"q: Quit"
]
print("\n".join(info))
k = readchar()
if k == "q":
sys.exit(0)
if k == "d":
enemy_hp -= 1
if k == "a":
block = 1
# Enemy Turn
if enemy_action == "attack":
if not block:
hp -= enemy_attack
if enemy_action == "buff":
enemy_attack += 1
# Player effects end
if block:
block = False
clear()
if hp > 0:
print("You won!")
elif enemy_hp > 0:
print("You lost!")
else:
print("Pyrrhic Victory! But who will defend them next time?")