-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enemy.py
66 lines (52 loc) · 2.66 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
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
import random
from items.equip_type import EquipType
class Enemy:
# monsterList = ["Bunny", "Deer", "Small Goblin", "Big Goblin", "Werewolf",
# "Ogre", "Armoured Ogre", "Small Dragon", "Dragon", "Dark Wyvern", "Dark Spawn", "Cold One"]
sizes = ["fat", "small", "big", "average", "thin", "poor"]
variations = ["infant", "armoured", "adult", 'old', 'crimson', "battle hardened", "red", "baby"]
def __init__(self, location):
self.level = random.randrange(location.levelRange[0], location.levelRange[1])
self.life = self.level * 10
self.life += random.randrange(-9, 9)
self.maxHP = self.life
self.size = Enemy.sizes[random.randint(0, len(Enemy.sizes) - 1 )]
self.variation = Enemy.variations[random.randint(0, len(Enemy.variations) - 1 )]
self.type = location.enemies[random.randint( 0, len( location.enemies ) - 1 )]
self.name = str(self.size) + " " + str(self.variation) + " " + str(self.type)
self.monsterdamage = self.level + random.randrange(0, 4)
# Check if enemy death
def is_dead(self):
return self.life <= 0
def attack(self, character, instance):
# attempt to damage the monster
if random.randint(0, 100) < 70:
self.life -= character.get_damage()
print("you swing your " + str(character.equipment.getName(EquipType.type.WEAPON)) + " and hit the " + self.name + " for " + str(character.get_damage()) + ".")
print("enemy has " + str(self.life) + " left.")
character.erode_weapon()
else:
print("The " + self.name + " avoided the hit")
# if monster is dead
if self.is_dead():
print("The " + self.name + " falls down and makes it last wail before it dies")
character.experience_gain(self.get_experience())
if random.randint(0, 100) < 20:
weapon = instance.itemManager.generateWeapon()
character.give(weapon)
instance.leaveInstance()
else:
character.attack(self)
def get_damage(self):
print("the " + self.name + " beared its claws and did " + str(self.monsterdamage) + " damage to you!")
return self.monsterdamage
def get_death_message(self):
return "As you feel the claws pierce through your flesh you feel your life leaving you."
def get_experience(self):
return self.maxHP * 2 + 4
pass
def check_life(self):
if self.life <= 0:
print("The " + self.name + " falls down and makes it last wail before it dies")
else:
print("the " + self.name + " has " + str(self.life) + " life left")