|
|
@ -3,6 +3,7 @@ import init
|
|
|
|
import start_game
|
|
|
|
import start_game
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
#import path.path
|
|
|
|
WIDTH , HEIGHT = 1200 , 800
|
|
|
|
WIDTH , HEIGHT = 1200 , 800
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,9 +116,6 @@ def draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_eleph
|
|
|
|
draw_right_animals(r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox)
|
|
|
|
draw_right_animals(r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox)
|
|
|
|
#WIN.blit(L_fox,(fox.x,fox.y))
|
|
|
|
#WIN.blit(L_fox,(fox.x,fox.y))
|
|
|
|
pygame.display.update()
|
|
|
|
pygame.display.update()
|
|
|
|
#TODO:传入动物编号id,动物现在的位置(x,y),将点击的动物圈起来,并显示可以移动的地方
|
|
|
|
|
|
|
|
def path():
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#animals rect
|
|
|
|
#animals rect
|
|
|
|
l_elephant = pygame.Rect(int(2/9 * WIDTH),int(0 / 7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y)
|
|
|
|
l_elephant = pygame.Rect(int(2/9 * WIDTH),int(0 / 7 * HEIGHT),CHESSSIZE_Y,CHESSSIZE_Y)
|
|
|
@ -751,196 +749,810 @@ def ismove(old_x,old_y,x,y,id,MAP,MAP1):
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 13:
|
|
|
|
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if MAP[x][y] == 20:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) ==1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
|
|
|
|
if y > old_y:
|
|
|
|
|
|
|
|
for i in range(old_y+1,y):
|
|
|
|
|
|
|
|
if MAP[x][i] != 20 and MAP[x][i] != 8 :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(y+1,old_y):
|
|
|
|
|
|
|
|
if MAP[x][i] != 20 and MAP[x][i] != 1 :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
|
|
|
|
if x > old_x:
|
|
|
|
|
|
|
|
for i in range(old_x+1,x):
|
|
|
|
|
|
|
|
if MAP[i][y] != 20 and MAP[i][y] != 1 :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(x+1,old_x):
|
|
|
|
|
|
|
|
if MAP[i][y] != 20 and MAP[i][y] != 1 :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 14:
|
|
|
|
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if(MAP[x][y] == 20):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7):
|
|
|
|
|
|
|
|
if 2 <= MAP[x][y] <= 7:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7):
|
|
|
|
|
|
|
|
if 2 <= MAP[x][y] <= 7:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#TODO:Judge who win
|
|
|
|
|
|
|
|
def left_win(x,y,MAP,MAP1):
|
|
|
|
|
|
|
|
global r_animals
|
|
|
|
|
|
|
|
if r_animals == 0:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 18 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
isWin = 0
|
|
|
|
|
|
|
|
for i in range(8,15):
|
|
|
|
|
|
|
|
if ID[i] == 1:
|
|
|
|
|
|
|
|
isWin = left_Wall(i,MAP,MAP1)
|
|
|
|
|
|
|
|
if isWin == 0:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if isWin == 1:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def left_move(old_x,old_y,x,y,id,MAP,MAP1):
|
|
|
|
|
|
|
|
if id == 8:
|
|
|
|
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP[x][y] == 7 or MAP1[x][y] == 17):
|
|
|
|
|
|
|
|
if MAP[x][y] == 7:
|
|
|
|
|
|
|
|
if MAP1[old_x][old_y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP[x][y] == 7 or MAP1[x][y] == 17):
|
|
|
|
|
|
|
|
if MAP[x][y] == 7:
|
|
|
|
|
|
|
|
if MAP1[old_x][old_y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1 <= MAP[x][y] <= 7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 9:
|
|
|
|
|
|
|
|
if MAP[x][y] == 18 and MAP[x][y] != 0 and MAP[x][y] != 15 and MAP[x][y] != 17 and MAP[x][y] != 16 and MAP1[x][y] != 17 and (2<MAP[x][y]<=14):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if x == old_x and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=2):
|
|
|
|
|
|
|
|
if y > old_y:
|
|
|
|
|
|
|
|
for i in range(old_y + 1, y):
|
|
|
|
|
|
|
|
if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 17 and MAP[i][y] != 15 and MAP[x][i] != 18):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 2:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(y + 1, old_y):
|
|
|
|
|
|
|
|
if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 17 and MAP[i][y] != 15 and MAP[x][i] != 18):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 2:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif y == old_y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=2):
|
|
|
|
|
|
|
|
if x > old_x:
|
|
|
|
|
|
|
|
for i in range(old_x + 1, x):
|
|
|
|
|
|
|
|
if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 17 and MAP[i][y] != 15 and MAP[i][y] != 18):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 2:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(x + 1, old_x):
|
|
|
|
|
|
|
|
if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 17 and MAP[i][y] != 15 and MAP[i][y] != 18):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 2:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 10:
|
|
|
|
|
|
|
|
if abs(x - old_x) <= 1 and abs(y - old_y) <= 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=3):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 3:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 11:
|
|
|
|
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if(MAP[x][y] == 20):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=4):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 4:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=4):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 4:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 12:
|
|
|
|
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if(MAP[x][y] == 20):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=5):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 5:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=5):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 5:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 13:
|
|
|
|
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if MAP[x][y] == 20:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) ==1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
|
|
|
|
if y > old_y:
|
|
|
|
|
|
|
|
for i in range(old_y+1,y):
|
|
|
|
|
|
|
|
if MAP[x][i] != 20 and MAP[x][i] != 8 :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(y+1,old_y):
|
|
|
|
|
|
|
|
if MAP[x][i] != 20 and MAP[x][i] != 1 :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
|
|
|
|
if x > old_x:
|
|
|
|
|
|
|
|
for i in range(old_x+1,x):
|
|
|
|
|
|
|
|
if MAP[i][y] != 20 and MAP[i][y] != 1 :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(x+1,old_x):
|
|
|
|
|
|
|
|
if MAP[i][y] != 20 and MAP[i][y] != 1 :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 14:
|
|
|
|
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if(MAP[x][y] == 20):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7):
|
|
|
|
|
|
|
|
if 2 <= MAP[x][y] <= 7:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7):
|
|
|
|
|
|
|
|
if 2 <= MAP[x][y] <= 7:
|
|
|
|
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else :
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def left_Wall(id,MAP,MAP1):
|
|
|
|
|
|
|
|
if 8<=id<=14:
|
|
|
|
|
|
|
|
if id == 8:
|
|
|
|
|
|
|
|
old_x,old_y = init.calc(r_mouse.x,r_mouse.y)
|
|
|
|
|
|
|
|
elif id == 9:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(r_eagle.x, r_eagle.y)
|
|
|
|
|
|
|
|
elif id == 10:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(r_fox.x, r_fox.y)
|
|
|
|
|
|
|
|
elif id == 11:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(r_wolf.x, r_wolf.y)
|
|
|
|
|
|
|
|
elif id == 12:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(r_leopard.x, r_leopard.y)
|
|
|
|
|
|
|
|
elif id == 13:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(r_lion.x, r_lion.y)
|
|
|
|
|
|
|
|
elif id == 14:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(r_elephant.x, r_elephant.y)
|
|
|
|
|
|
|
|
for x in range(0,9):
|
|
|
|
|
|
|
|
for y in range(0,6):
|
|
|
|
|
|
|
|
if left_move(old_x,old_y,x,y,id,MAP,MAP1):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
def right_win(x,y,MAP,MAP1):
|
|
|
|
|
|
|
|
isWin = 0
|
|
|
|
|
|
|
|
global l_animals
|
|
|
|
|
|
|
|
if l_animals == 0:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 16 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
for i in range(1, 8):
|
|
|
|
|
|
|
|
if ID[i] == 1:
|
|
|
|
|
|
|
|
isWin = right_Wall(i,MAP,MAP1)
|
|
|
|
|
|
|
|
if isWin == 0:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if isWin == 1:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def right_move(old_x,old_y,x,y,id,MAP,MAP1):
|
|
|
|
|
|
|
|
if id == 1:
|
|
|
|
|
|
|
|
if MAP[x][y] == 16:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (
|
|
|
|
|
|
|
|
MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP[x][y] == 14 or MAP1[x][y] == 15):
|
|
|
|
|
|
|
|
if MAP[x][y] == 14 and MAP1[old_x][old_y] == 20:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if MAP[x][y] == 14 and MAP1[old_x][old_y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (
|
|
|
|
|
|
|
|
MAP[x][y] == 0 or MAP[x][y] == 20 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP[x][y] == 14 or MAP1[x][y] == 15):
|
|
|
|
|
|
|
|
if MAP[x][y] == 14 and MAP1[old_x][old_y] == 20:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if MAP[x][y] == 14 and MAP1[old_x][old_y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 2:
|
|
|
|
|
|
|
|
if MAP[x][y] == 16 and MAP[x][y] != 0 and MAP[x][y] != 15 and MAP[x][y] != 17 and MAP[x][y] != 18 and MAP1[x][y] != 15 and (9 < MAP[x][y] <= 14):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if x == old_x and (
|
|
|
|
|
|
|
|
MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 9):
|
|
|
|
|
|
|
|
if y > old_y:
|
|
|
|
|
|
|
|
for i in range(old_y + 1, y):
|
|
|
|
|
|
|
|
if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 15 and MAP[x][i] != 17 and MAP[x][i] != 16 and MAP[x][i] != 18):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 9:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(y + 1, old_y):
|
|
|
|
|
|
|
|
if (MAP[x][i] != 0 and MAP[x][i] != 20 and MAP[x][i] != 15 and MAP[x][i] != 17 and MAP[x][i] != 16 and MAP[x][i] != 18):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 9:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
elif id == 13:
|
|
|
|
return 1
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif y == old_y and (
|
|
|
|
|
|
|
|
MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 9):
|
|
|
|
|
|
|
|
if x > old_x:
|
|
|
|
|
|
|
|
for i in range(old_x + 1, x):
|
|
|
|
|
|
|
|
if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 15 and MAP[i][y] != 17 and MAP[i][y] != 16 and MAP[i][y] != 18):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 9:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(x + 1, old_x):
|
|
|
|
|
|
|
|
if (MAP[i][y] != 0 and MAP[i][y] != 20 and MAP[i][y] != 15 and MAP[i][y] != 17 and MAP[i][y] != 16 and MAP[i][y] != 18):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 9:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 3:
|
|
|
|
|
|
|
|
if abs(x - old_x) <= 1 and abs(y - old_y) <= 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 10):
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 10:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 4:
|
|
|
|
|
|
|
|
if MAP[x][y] == 16:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if (MAP[x][y] == 20):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 11):
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 11:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 11):
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 11:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 5:
|
|
|
|
|
|
|
|
if MAP[x][y] == 16:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if (MAP[x][y] == 20):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 12):
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 12:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 12):
|
|
|
|
|
|
|
|
if 8 <= MAP[x][y] <= 12:
|
|
|
|
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
elif id == 6:
|
|
|
|
|
|
|
|
if MAP[x][y] == 16:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if MAP[x][y] == 20:
|
|
|
|
if MAP[x][y] == 20:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if abs(x - old_x) ==1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 13):
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
if 8 <= MAP[x][y] <= 13:
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 13):
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
if 8 <= MAP[x][y] <= 13:
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
elif old_x == x and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 13):
|
|
|
|
if y > old_y:
|
|
|
|
if y > old_y:
|
|
|
|
for i in range(old_y + 1, y):
|
|
|
|
for i in range(old_y + 1, y):
|
|
|
|
if MAP[x][i] != 20 and MAP[x][i] != 8 :
|
|
|
|
if MAP[x][i] != 20 and MAP[x][i] != 1:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
if 8 <= MAP[x][y] <= 14:
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
for i in range(y + 1, old_y):
|
|
|
|
for i in range(y + 1, old_y):
|
|
|
|
if MAP[x][i] != 20 and MAP[x][i] != 1:
|
|
|
|
if MAP[x][i] != 20 and MAP[x][i] != 1:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
if 8 <= MAP[x][y] <= 13:
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 1<=MAP[x][y]<=6):
|
|
|
|
elif old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 8 <=MAP[x][y] <= 13):
|
|
|
|
if x > old_x:
|
|
|
|
if x > old_x:
|
|
|
|
for i in range(old_x + 1, x):
|
|
|
|
for i in range(old_x + 1, x):
|
|
|
|
if MAP[i][y] != 20 and MAP[i][y] != 1:
|
|
|
|
if MAP[i][y] != 20 and MAP[i][y] != 1:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
if 8 <= MAP[x][y] <= 13:
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
for i in range(x + 1, old_x):
|
|
|
|
for i in range(x + 1, old_x):
|
|
|
|
if MAP[i][y] != 20 and MAP[i][y] != 1:
|
|
|
|
if MAP[i][y] != 20 and MAP[i][y] != 1:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if 1 <= MAP[x][y] <= 6:
|
|
|
|
if 8 <= MAP[x][y] <= 13:
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
elif id == 14:
|
|
|
|
elif id == 7:
|
|
|
|
if MAP[x][y] == 18:
|
|
|
|
if MAP[x][y] == 16:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if (MAP[x][y] == 20):
|
|
|
|
if (MAP[x][y] == 20):
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7):
|
|
|
|
if abs(x - old_x) == 1 and old_y == y and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 or MAP[x][y] == 18 or MAP1[x][y] == 15 or 9 <=MAP[x][y] <= 14):
|
|
|
|
if 2 <= MAP[x][y] <= 7:
|
|
|
|
if 9 <= MAP[x][y] <= 14:
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 17 or MAP[x][y] == 15 or MAP[x][y] == 16 or MAP1[x][y] == 17 or 2<=MAP[x][y]<=7):
|
|
|
|
elif old_x == x and abs(y - old_y) == 1 and (MAP[x][y] == 0 or MAP[x][y] == 15 or MAP[x][y] == 17 and MAP[x][y] == 18 or MAP1[x][y] == 15 or 9 <=MAP[x][y] <= 14):
|
|
|
|
if 2 <= MAP[x][y] <= 7:
|
|
|
|
if 9 <= MAP[x][y] <= 14:
|
|
|
|
if MAP[x][y] == 1:
|
|
|
|
if MAP[x][y] == 8:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
if MAP1[x][y] != 20:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 17 and 1<=MAP[x][y]<=7:
|
|
|
|
if MAP1[x][y] == 15 and 8 <= MAP[x][y] <= 14:
|
|
|
|
ID[MAP[x][y]] = 0
|
|
|
|
|
|
|
|
l_animals -= 1
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def right_Wall(id,MAP,MAP1):
|
|
|
|
#TODO:Judge who win
|
|
|
|
if 1<=id<=7:
|
|
|
|
def left_win(old_x,old_y,x,y,MAP,MAP1):
|
|
|
|
if id == 1:
|
|
|
|
global r_animals
|
|
|
|
old_x,old_y = init.calc(l_mouse.x,l_mouse.y)
|
|
|
|
if r_animals == 0:
|
|
|
|
elif id == 2:
|
|
|
|
return 1
|
|
|
|
old_x, old_y = init.calc(l_eagle.x, l_eagle.y)
|
|
|
|
if MAP1[x][y] == 18 and 1<=MAP[x][y]<=7:
|
|
|
|
elif id == 3:
|
|
|
|
return 1
|
|
|
|
old_x, old_y = init.calc(l_fox.x, l_fox.y)
|
|
|
|
for i in range(8,15):
|
|
|
|
elif id == 4:
|
|
|
|
pass
|
|
|
|
old_x, old_y = init.calc(l_wolf.x, l_wolf.y)
|
|
|
|
|
|
|
|
elif id == 5:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(l_leopard.x, l_leopard.y)
|
|
|
|
|
|
|
|
elif id == 6:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(l_lion.x, l_lion.y)
|
|
|
|
|
|
|
|
elif id == 7:
|
|
|
|
|
|
|
|
old_x, old_y = init.calc(l_elephant.x, l_elephant.y)
|
|
|
|
|
|
|
|
for x in range(0,9):
|
|
|
|
|
|
|
|
for y in range(0,6):
|
|
|
|
|
|
|
|
if right_move(old_x,old_y,x,y,id,MAP,MAP1):
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def right_win(old_x,old_y,x,y,MAP,MAP1):
|
|
|
|
|
|
|
|
global l_animals
|
|
|
|
|
|
|
|
if l_animals == 0:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
if MAP1[x][y] == 16 and 8 <= MAP[x][y] <= 14:
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
for i in range(1, 8):
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
global l_animals,r_animals
|
|
|
|
global l_animals,r_animals
|
|
|
|
BGM.play(-1)
|
|
|
|
BGM.play(-1)
|
|
|
@ -949,7 +1561,6 @@ def main():
|
|
|
|
game_status = start_game.starting_screen()
|
|
|
|
game_status = start_game.starting_screen()
|
|
|
|
if not game_status:
|
|
|
|
if not game_status:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
#TODO:updata MAP1
|
|
|
|
|
|
|
|
run = True
|
|
|
|
run = True
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
font = pygame.font.SysFont('kaiti',40)
|
|
|
|
font = pygame.font.SysFont('kaiti',40)
|
|
|
@ -962,7 +1573,6 @@ def main():
|
|
|
|
elif event.type == pygame.MOUSEBUTTONDOWN:
|
|
|
|
elif event.type == pygame.MOUSEBUTTONDOWN:
|
|
|
|
b1, b2, b3 = pygame.mouse.get_pressed()
|
|
|
|
b1, b2, b3 = pygame.mouse.get_pressed()
|
|
|
|
if b1 and not b3:
|
|
|
|
if b1 and not b3:
|
|
|
|
print(r_animals)
|
|
|
|
|
|
|
|
mouse_x , mouse_y = event.pos
|
|
|
|
mouse_x , mouse_y = event.pos
|
|
|
|
old_x = x
|
|
|
|
old_x = x
|
|
|
|
old_y = y
|
|
|
|
old_y = y
|
|
|
@ -986,7 +1596,6 @@ def main():
|
|
|
|
elif id == 7:
|
|
|
|
elif id == 7:
|
|
|
|
Elephant.play()
|
|
|
|
Elephant.play()
|
|
|
|
status = 1
|
|
|
|
status = 1
|
|
|
|
path()
|
|
|
|
|
|
|
|
elif 7 < id <15 and turn == 1:
|
|
|
|
elif 7 < id <15 and turn == 1:
|
|
|
|
if id == 8:
|
|
|
|
if id == 8:
|
|
|
|
Mouse.play()
|
|
|
|
Mouse.play()
|
|
|
@ -1021,9 +1630,7 @@ def main():
|
|
|
|
elif id == 2 and turn == 0 and status == 1:
|
|
|
|
elif id == 2 and turn == 0 and status == 1:
|
|
|
|
if MAP[x][y] == id:
|
|
|
|
if MAP[x][y] == id:
|
|
|
|
status = 1
|
|
|
|
status = 1
|
|
|
|
path()
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
#print(ismove(old_x,old_y,x,y,id,MAP))
|
|
|
|
|
|
|
|
if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) :
|
|
|
|
if (ismove(old_x,old_y,x,y,id,MAP,MAP1)) :
|
|
|
|
l_eagle.x , l_eagle.y = init.tran(x,y)
|
|
|
|
l_eagle.x , l_eagle.y = init.tran(x,y)
|
|
|
|
MAP[old_x][old_y] = MAP1[old_x][old_y]
|
|
|
|
MAP[old_x][old_y] = MAP1[old_x][old_y]
|
|
|
@ -1176,24 +1783,26 @@ def main():
|
|
|
|
turn = 0
|
|
|
|
turn = 0
|
|
|
|
else :
|
|
|
|
else :
|
|
|
|
status = 0
|
|
|
|
status = 0
|
|
|
|
#print(turn, status)
|
|
|
|
if left_win(x,y,MAP,MAP1):
|
|
|
|
if left_win(old_x,old_y,x,y,MAP,MAP1):
|
|
|
|
|
|
|
|
run = False
|
|
|
|
run = False
|
|
|
|
if right_win(old_x,old_y,x,y,MAP,MAP1):
|
|
|
|
if right_win(x,y,MAP,MAP1):
|
|
|
|
run = False
|
|
|
|
run = False
|
|
|
|
#print(old_x,old_y)
|
|
|
|
|
|
|
|
#print(x,y)
|
|
|
|
|
|
|
|
draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox)
|
|
|
|
draw_window(l_elephant,l_eagle,l_wolf,l_lion,l_leopard,l_mouse,l_fox,r_elephant,r_eagle,r_wolf,r_lion,r_leopard,r_mouse,r_fox)
|
|
|
|
if left_win(old_x, old_y, x, y, MAP, MAP1):
|
|
|
|
if left_win(x, y, MAP, MAP1):
|
|
|
|
print_text(WIN, font, 500, 400, "Left Win!", RED)
|
|
|
|
print_text(WIN, font, 500, 400, "Left Win!", RED)
|
|
|
|
pygame.display.update()
|
|
|
|
pygame.display.update()
|
|
|
|
if right_win(old_x, old_y, x, y, MAP, MAP1):
|
|
|
|
if right_win(x, y, MAP, MAP1):
|
|
|
|
print_text(WIN, font, 500, 400, "Right Win!", BLUE)
|
|
|
|
print_text(WIN, font, 500, 400, "Right Win!", BLUE)
|
|
|
|
pygame.display.update()
|
|
|
|
pygame.display.update()
|
|
|
|
os.system("pause")
|
|
|
|
time.sleep(2)
|
|
|
|
pygame.quit()
|
|
|
|
#os.system("pause")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
again = 1
|
|
|
|
|
|
|
|
while again == 1:
|
|
|
|
|
|
|
|
l_elephant, l_eagle, l_wolf, l_lion, l_leopard, l_mouse, l_fox, r_elephant, r_eagle, r_wolf, r_lion, r_leopard, r_fox, r_mouse=init.refresh()
|
|
|
|
|
|
|
|
draw_window(l_elephant, l_eagle, l_wolf, l_lion, l_leopard, l_mouse, l_fox, r_elephant, r_eagle, r_wolf, r_lion,
|
|
|
|
|
|
|
|
r_leopard, r_mouse, r_fox)
|
|
|
|
main()
|
|
|
|
main()
|
|
|
|
|
|
|
|
pygame.quit()
|
|
|
|