-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
74 lines (62 loc) · 2.06 KB
/
code.py
File metadata and controls
74 lines (62 loc) · 2.06 KB
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
# Copyright © NewFireDragon39 2026
# Licensed under the PolyForm Noncommercial License 1.0.0
# Full license: https://polyformproject.org/licenses/noncommercial/1.0.0/
import os
os.system('cls' if os.name == 'nt' else 'clear')
import random as rand
from random import randint
def number_check(number):
if number < 0:
return 0
if isinstance(number, float) and number.is_integer():
return int(number)
return number
difficulty_choice=""
boss_hp=100
ur_hp=100
ur_move=""
boss_move=""
ur_damage=0
boss_damage=0
round=0
while difficulty_choice not in{"e", "easy", "m", "med", "medium", "h", "hard"}:
difficulty_choice=input('Choose a difficulty. Type "easy/e," "med/meduim/m," or "hard/h": ').lower()
if difficulty_choice=="easy"or difficulty_choice=="e":
boss_hp=50
elif difficulty_choice=="hard"or difficulty_choice=="h":
boss_hp=150
else:
boss_hp=100
while boss_hp > 0 and ur_hp > 0:
round+=1
print(f"----------Round {round}----------")
print(f"Boss HP: {boss_hp}")
print(f"Your HP: {ur_hp}")
while ur_move not in {"a", "attack:", "d", "defend"}:
ur_move=input('Choose your move. Type "attack/a" or "defend/d": ').lower()
if ur_move in {"d", "defend"}:
print("You defended!")
boss_move=rand.choice(("a", "d"))
if boss_move=="a":
boss_damage=randint(5, 10)
if ur_move in {"d", "defend"}:
boss_damage/=4
ur_hp-=boss_damage
print(f"The boss did {number_check(boss_damage)} damage! You have {number_check(ur_hp)} HP left")
if ur_move in {"a", "attack"}:
ur_damage = randint(5, 10)
if boss_move == "d":
print("The boss defended!")
ur_damage /= 4
boss_hp-=ur_damage
print(f"You did {number_check(ur_damage)} damage! The boss has {number_check(boss_hp)} HP left!")
if ur_move in {"d", "defend"} and boss_move == "d":
print("Both of you defended. Nothing happened.")
if boss_hp > 0 and ur_hp <= 0:
print("You lost...")
elif boss_hp <= 0 and ur_hp > 0:
print("You win!")
elif boss_hp <= 0 and ur_hp <= 0:
print("It's a tie!")
ur_move=""
boss_move=""