diff --git a/README.md b/README.md index 96837eb..a104d62 100644 --- a/README.md +++ b/README.md @@ -81,10 +81,11 @@ nuitka --mingw --standalone --onefile --show-progress --show-memory --output-dir ## 已知bug 以下问题囿于个人目前的能力与精力,没有修复: -* 所有关卡完成后无法再玩 * 植物刚刚种植会立刻攻击,而非像原版一样有间歇时间 * 冷冻的僵尸未用蓝色滤镜标识 + * 这个想不到很好的实现方法,可能会想一种替代方案 * 魅惑的僵尸未用红色滤镜标识 + * 这个可能会作为一种“特性” **欢迎提供[Pull requests](https://github.com/wszqkzqk/pypvz/pulls)或修复方法建议,也欢迎在这里反馈新的bug()** diff --git a/source/component/map.py b/source/component/map.py index e7f3b65..c57db74 100755 --- a/source/component/map.py +++ b/source/component/map.py @@ -51,7 +51,10 @@ class Map(): if '花盆(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]: if ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'}) and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集 - return True + if plantName in {c.SPIKEWEED}: # 不能在花盆上种植的植物 + return False + else: + return True elif plantName == '花盆(未实现)': # 这一格本来没有花盆而且新来的植物是花盆,可以种 return True elif plantName == '咖啡豆(未实现)' and self.map[map_y][map_x][c.MAP_SLEEP]: @@ -70,7 +73,10 @@ class Map(): if c.LILYPAD in self.map[map_y][map_x][c.MAP_PLANT]: if ((self.map[map_y][map_x][c.MAP_PLANT] | {c.LILYPAD, '花盆(未实现)', '南瓜头(未实现)'} == {c.LILYPAD, '花盆(未实现)', '南瓜头(未实现)'}) and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集 - return True + if plantName in {c.SPIKEWEED}: # 不能在睡莲上种植的植物 + return False + else: + return True else: return False else: diff --git a/source/component/plant.py b/source/component/plant.py index b447b8c..96fc3fc 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -567,11 +567,12 @@ class PotatoMine(Plant): class Squash(Plant): - def __init__(self, x, y): + def __init__(self, x, y, mapObjSet): Plant.__init__(self, x, y, c.SQUASH, c.PLANT_HEALTH, None) self.orig_pos = (x, y) self.aim_timer = 0 self.squashing = False + self.mapObjSet = mapObjSet def loadImages(self, name, scale): self.idle_frames = [] @@ -622,6 +623,8 @@ class Squash(Plant): if self.canAttack(zombie): zombie.setDamage(1800, damageType=c.ZOMBIE_RANGE_DAMAGE) self.health = 0 # 避免僵尸在原位啃食 + print(self.orig_pos) + self.mapObjSet.remove(c.SQUASH) self.kill() elif self.aim_timer == 0: self.aim_timer = self.current_time diff --git a/source/state/level.py b/source/state/level.py index 38bdb4b..ac9c3e4 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -498,7 +498,7 @@ class Level(tool.State): elif self.plant_name == c.POTATOMINE: new_plant = plant.PotatoMine(x, y) elif self.plant_name == c.SQUASH: - new_plant = plant.Squash(x, y) + new_plant = plant.Squash(x, y, self.map.map[map_y][map_x][c.MAP_PLANT]) elif self.plant_name == c.SPIKEWEED: new_plant = plant.Spikeweed(x, y) elif self.plant_name == c.JALAPENO: