我正在用python制作一个基于文本的游戏,我想知道是否有人知道如何制造多个敌人。我已经拥有了房间和内部敌人的代码,但是我想让它在死亡时继续向角色投掷敌人。
class EnemyRoom(MapTile):
def __init__(self, x, y, enemy):
self.enemy = enemy
super().__init__(x, y)
def modify_player(self, the_player):
if self.enemy.is_alive():
the_player.hp = the_player.hp - self.enemy.damage
print("Enemy does {} damage. You have {} HP remaining.".format(self.enemy.damage, the_player.hp))
def available_actions(self):
if self.enemy.is_alive():
return [actions.Attack(enemy=self.enemy)]
else:
return self.adjacent_moves()
class MonsterRoom(EnemyRoom):
def __init__(self, x, y):
super().__init__(x, y, enemies.Monster())
def intro_text(self):
if self.enemy.is_alive():
"""
A monster jumps in front of you!
"""
答案 0 :(得分:-1)
你可以在modify_player
之前添加一张支票,然后再破坏那些在怪物不活着的情况下复活或重新生成的玩家。