From d2bc785f8e83fc8b6e4d5868617c8e58192eeb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Thu, 21 Apr 2022 00:15:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=80=AD=E7=93=9C=E7=94=9F?= =?UTF-8?q?=E6=95=88=E5=90=8E=E4=B8=8D=E8=83=BD=E5=9C=A8=E5=8E=9F=E7=A7=8D?= =?UTF-8?q?=E6=A4=8D=E4=BD=8D=E7=BD=AE=E7=A7=8D=E6=A4=8D=E6=A4=8D=E7=89=A9?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- source/component/map.py | 10 ++++++++-- source/component/plant.py | 5 ++++- source/state/level.py | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) 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: