Skip to content
Snippets Groups Projects
Commit 17301e8f authored by Sean Paeglis's avatar Sean Paeglis
Browse files

s

parent 9c02b167
No related branches found
No related tags found
No related merge requests found
......@@ -22,4 +22,5 @@ class Player:
return(moves[0])
def update(self, colour, action):
action = self.board.convert_coords_local(action)
self.board.move(action)
No preview for this file type
......@@ -95,24 +95,44 @@ class Board:
def convert_coords_local(self, action):
if action[0] == 'EXIT':
return (action[0], (action[1][0], action[1][1]))
return (action[0], (action[1][0]+3, action[1][1]+3))
return (action[0], ((action[1][0][0]+3, action[1][0][1]+3), (action[1][1][0]+3, action[1][1][1]+3)))
def convert_coords_ref(self, action):
if action[0] == 'EXIT':
return (action[0], (action[1][0], action[1][1]))
return (action[0], (action[1][0]-3, action[1][1]-3))
return (action[0], ((action[1][0][0]-3, action[1][0][1]-3), (action[1][1][0]-3, action[1][1][1]-3)))
def move(self, action):
if action[0] == 'MOVE' or action == 'JUMP':
if action[0] == 'MOVE':
piece = self.tiles[action[1][0][1]][action[1][0][0]]
self.tiles[action[1][0][1]][action[1][0][0]] = None
self.tiles[action[1][1][1]][action[1][1][0]] = piece
self.tiles[action[1][1][1]][action[1][1][0]].pos = action[1][1]
elif action[0] == 'EXIT':
elif action[0] == 'JUMP':
piece = self.tiles[action[1][0][1]][action[1][0][0]]
direction = (action[1][1][0]-action[1][0][0], action[1][1][1]-action[1][0][1])
direction = (int(direction[0]/2), int(direction[1]/2))
print("MID: " + str((piece.pos[0] + direction[0]-3, piece.pos[1] + direction[1]-3)))
mid_tile = (piece.pos[0] + direction[0], piece.pos[1] + direction[1])
taken_piece = self.tiles[mid_tile[1]][mid_tile[0]]
print(len(self.pieces[taken_piece.colour]))
for i in range(len(self.pieces[taken_piece.colour])):
if self.pieces[taken_piece.colour][i] is taken_piece:
self.pieces[taken_piece.colour].pop(i)
self.pieces[piece.colour].append(taken_piece)
taken_piece.colour = piece.colour
break
self.tiles[action[1][0][1]][action[1][0][0]] = None
self.tiles[action[1][1][1]][action[1][1][0]] = piece
self.tiles[action[1][1][1]][action[1][1][0]].pos = action[1][1]
elif action[0] == 'EXIT':
piece = self.tiles[action[1][1]][action[1][0]]
self.tiles[action[1][1]][action[1][0]] = None
self.pieces[piece.colour].remove(piece)
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment