forked from Krasi2405/Dungeon-Game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonster_spawner.py
26 lines (22 loc) · 869 Bytes
/
monster_spawner.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
from monster import *
import random
class MonsterSpawner:
monster_list = []
def __init__(self, level, difficulty):
self.level = level
self.difficulty = difficulty
def spawn_monster(self, location):
min_spawn_chance = self.difficulty * 5 + self.level
spawn_chance = random.randint(min_spawn_chance, 100)
if spawn_chance <= 30:
monster = Goblin(self.difficulty, self.level)
elif spawn_chance <= 49:
monster = Ghoul(self.difficulty, self.level)
elif spawn_chance <= 69:
monster = Monster(self.difficulty, self.level)
elif spawn_chance <= 89:
monster = Giant(self.difficulty, self.level)
else:
monster = Troll(self.difficulty, self.level)
monster.pos = location
self.monster_list.append(monster)