def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if self.show_msg == False:
if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
self.home_sqare_switch(self.board.active_ship + 1)
elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
self.home_sqare_switch(self.board.active_ship - 1)
elif event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN and not self.correct:
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if (len(char) > 0 and lhv < 2 and char in self.digits):
if True:
if lhv == 1:
s = self.home_square.value + char
if s[0] == "0":
self.home_square.value = char
else:
n = int(s)
if n < 20:
self.home_square.value = str(n % 10)
try:
self.carryl[self.home_square.pos_id].value = "1"
self.carryl[self.home_square.pos_id].update_me = True
except:
pass
else:
self.home_square.value = char
else:
self.home_square.value = char
elif self.home_square in self.carryl:
if char == "1":
self.home_square.value = char
else:
self.home_square.value = ""
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEBUTTONUP:
self.home_sqare_switch(self.board.active_ship)
评论列表
文章目录