修复闪退bug

This commit is contained in:
星外之神 2022-04-17 20:57:45 +08:00
parent 88c09f6a9d
commit 5556852ba6
2 changed files with 7 additions and 5 deletions

View File

@ -105,7 +105,7 @@ MAP_STATE_TILE = {MAP_PLANT:set(), MAP_SLEEP:False, MAP_PLOT_TYPE:MAP_TILE}
BACKGROUND_OFFSET_X = 220 BACKGROUND_OFFSET_X = 220
MAP_OFFSET_X = 35 MAP_OFFSET_X = 35
MAP_OFFSET_Y = 100 MAP_OFFSET_Y = 100
MAP_POOL_OFFSET_X = 35 # 暂时还不清楚数据 MAP_POOL_OFFSET_X = 40 # 暂时还不清楚数据
MAP_POOL_OFFSET_Y = 115 # 暂时还不清楚数据 MAP_POOL_OFFSET_Y = 115 # 暂时还不清楚数据
MAP_ROOF_OFFSET_X = 35 # 暂时还不清楚数据 MAP_ROOF_OFFSET_X = 35 # 暂时还不清楚数据
MAP_ROOF_OFFSET_Y = 105 # 暂时还不清楚数据 MAP_ROOF_OFFSET_Y = 105 # 暂时还不清楚数据

View File

@ -535,7 +535,7 @@ class Level(tool.State):
#print('addPlant map[%d,%d], grid pos[%d, %d] pos[%d, %d]' % (map_x, map_y, x, y, pos[0], pos[1])) #print('addPlant map[%d,%d], grid pos[%d, %d] pos[%d, %d]' % (map_x, map_y, x, y, pos[0], pos[1]))
def setupHintImage(self): def setupHintImage(self):
pos = self.canSeedPlant() pos = self.canSeedPlant(self.plant_name)
if pos and self.mouse_image: if pos and self.mouse_image:
if (self.hint_image and pos[0] == self.hint_rect.x and if (self.hint_image and pos[0] == self.hint_rect.x and
pos[1] == self.hint_rect.y): pos[1] == self.hint_rect.y):
@ -670,11 +670,13 @@ class Level(tool.State):
x, y = plant.getPosition() x, y = plant.getPosition()
map_x, map_y = self.map.getMapIndex(x, y) map_x, map_y = self.map.getMapIndex(x, y)
if self.bar_type != c.CHOSSEBAR_BOWLING: if self.bar_type != c.CHOSSEBAR_BOWLING:
# 更改地图类型、添加南瓜头、睡莲、花盆后可能也需要改这里 try:
self.map.removeMapPlant(map_x, map_y, plant.name) self.map.removeMapPlant(map_x, map_y, plant.name)
except KeyError:
pass
# 将睡眠植物移除后更新睡眠状态 # 将睡眠植物移除后更新睡眠状态
if plant.state == c.SLEEP: if plant.state == c.SLEEP:
self.map[map_y][map_x][c.MAP_SLEEP] = False self.map.map[map_y][map_x][c.MAP_SLEEP] = False
# 用铲子铲不用触发植物功能 # 用铲子铲不用触发植物功能
if not shovel: if not shovel:
if (plant.name == c.CHERRYBOMB or plant.name == c.JALAPENO or if (plant.name == c.CHERRYBOMB or plant.name == c.JALAPENO or