-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy.py
37 lines (31 loc) · 1.07 KB
/
enemy.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
def selectEnemy():
from random import randint
enemy = randint(1, 3)
if enemy == 1:
selectedEnemy = "Goblin"
elif enemy == 2:
selectedEnemy = "Skeleton"
elif enemy == 3:
selectedEnemy = "Zombie"
return selectedEnemy
def setAttributes(selectedEnemy):
class Enemy:
def __init__(self, enemy, health, damage, speed):
self.enemy = enemy
self.health = health # Max 50
self.damage = damage # Max 50
self.speed = speed # Max 50
if selectedEnemy == "Goblin":
enemyAttributes = Enemy("Goblin", 25, 10, 20)
elif selectedEnemy == "Skeleton":
enemyAttributes = Enemy("Skeleton", 15, 20, 25)
elif selectedEnemy == "Zombie":
enemyAttributes = Enemy("Zombie", 15, 25, 15)
return enemyAttributes
def spawnEnemy():
selectedEnemy = selectEnemy()
enemyData = setAttributes(selectedEnemy)
print(
f"You encountered a {enemyData.enemy}\nHealth: {enemyData.health}\nDamage: {enemyData.damage}\nSpeed: {enemyData.speed}"
)
return enemyData