Give Plum cloning ability

This commit is contained in:
Nguyễn Gia Phong 2017-11-19 15:00:24 +07:00
parent 6a9b702c77
commit 242cc15584
3 changed files with 14 additions and 34 deletions

View File

@ -246,24 +246,6 @@ class Enemy:
self.maze.map[self.x][self.y] = WALL
class Butter(Enemy):
"""Object representing an enemy of Butter type."""
def __init__(self, maze, x, y):
Enemy.__init__(self, maze, x, y, 'Butter')
class Orange(Enemy):
"""Object representing an enemy of Orange type."""
def __init__(self, maze, x, y):
Enemy.__init__(self, maze, x, y, 'Orange')
class Chocolate(Enemy):
"""Object representing an enemy of Chocolate type."""
def __init__(self, maze, x, y):
Enemy.__init__(self, maze, x, y, 'Chocolate')
class Chameleon(Enemy):
"""Object representing an enemy of Chameleon type.
@ -290,18 +272,6 @@ class Chameleon(Enemy):
self.wound += wound
class SkyBlue(Enemy):
"""Object representing an enemy of Sky Blue type."""
def __init__(self, maze, x, y):
Enemy.__init__(self, maze, x, y, 'SkyBlue')
class Plum(Enemy):
"""Object representing an enemy of Plum type."""
def __init__(self, maze, x, y):
Enemy.__init__(self, maze, x, y, 'Plum')
class ScarletRed(Enemy):
"""Object representing an enemy of Scarlet Red type."""
def __init__(self, maze, x, y):
@ -323,4 +293,7 @@ class ScarletRed(Enemy):
def new_enemy(maze, x, y):
"""Return an enemy of a random type in the grid (x, y)."""
color = choices(maze.enemy_weights)
return getattr(modules[__name__], color)(maze, x, y)
try:
return getattr(modules[__name__], color)(maze, x, y)
except AttributeError:
return Enemy(maze, x, y, color)

View File

@ -108,8 +108,15 @@ class Maze:
x, y = choice(walls)
if all(self.map[x + a][y + b] == WALL for a, b in ADJACENT_GRIDS):
continue
self.enemies.append(new_enemy(self, x, y))
walls.remove((x, y))
enemy = new_enemy(self, x, y)
self.enemies.append(enemy)
if enemy.color == 'Plum':
for e in self.enemies:
if e.color == 'Plum' and e.awake: x, y = e.x, e.y
try:
walls.remove((x, y))
except ValueError:
enemy.x, enemy.y = x, y
def pos(self, x, y):
"""Return coordinate of the center of the grid (x, y)."""

View File

@ -7,7 +7,7 @@ with open('README.rst') as f:
setup(
name='brutalmaze',
version='0.1.2',
version='0.1.3',
description='A hash and slash game with fast-paced action and a minimalist art style',
long_description=long_description,
url='https://github.com/McSinyx/brutalmaze',