Ejemplo n.º 1
0
	def place(self,loc, Pieces,Board):
		for piece in Pieces:
			if piece.name == 'Mirror Dupe':
				dupe = piece
		self.loc = loc
		self.pos = Loc_To_Cell(loc,Board)
		self.loc_type = Find_Zone(self.pos)
		Board.update()
		Pieces.update()
		pg.display.flip()
		while True:
			for event in pg.event.get():
				if event.type == pg.QUIT:
					quit()
				elif event.type == pg.KEYDOWN:
					if event.key == pg.K_ESCAPE:
						current_piece.unselect(Pieces,Board)
						return False
				elif event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
					mouse_pos = pg.mouse.get_pos()
					loc = Loc_To_UL(mouse_pos,Board)
					pos = Loc_To_Cell(loc,Board)
					unoccupied = True
					for piece in Pieces:
						if piece.loc==loc:
							unoccupied=False
					if unoccupied and Is_Adjacent(pos,self.pos):
						dupe.place(loc,Pieces,Board)
						self.unselect(Pieces,Board)
						return None
Ejemplo n.º 2
0
 def move(self, loc, Pieces, Board):
     for piece in Pieces:
         if piece.loc == loc and piece.controller != self.controller:
             piece.remove(Pieces)
     self.loc = loc
     self.loc_type = Find_Zone(self.pos)
     self.pos = Loc_To_Cell(loc, Board)
     self.unselect(Pieces, Board)
Ejemplo n.º 3
0
	def legal_place(self,loc,Turn_Indicator,Pieces):
		if loc == None:
			return False
		out = True
		for piece in Pieces:
			if piece.loc == loc:
				out = False
		if Find_Zone(loc) in ['nutral_zone','goal']:
			out = False
		return out
Ejemplo n.º 4
0
	def place(self,loc, Pieces,Board):
		for piece in Pieces:
			if piece.name =='Mirror':
				self.controller = piece.controller
		temp = pg.PixelArray(self.surface)
		temp.replace(Grey,(255-255*self.controller,0,255*self.controller))
		self.surface = temp.make_surface()
		self.surface.set_colorkey(White)
		self.loc = loc
		self.pos = Loc_To_Cell(self.loc,Board)
		self.loc_type = Find_Zone(self.pos)
		self.unselect(Pieces,Board)
Ejemplo n.º 5
0
 def legal_place(self, loc, Board, Pieces):
     if loc == None:
         return False
     pos = Loc_To_Cell(loc, Board)
     print 'You have selected position: ' + str(pos)
     for piece in Pieces:
         if piece.loc == loc:
             print 'Illegal position since there is already a piece there.'
             return False
     if Find_Zone(pos) in ['nutral_zone', 'goal']:
         print 'Illegal position since in nutral zone or goal'
         return False
     if By_Portal(pos, self, Pieces):
         return True
     if Board.turn_name == self.controller and Find_Zone(
             pos) != 'place_zone':
         print 'Illegal position because that is not in the place zone'
         return False
     if Board.turn_name != self.controller and Find_Zone(
             pos) != Board.turn_name:
         print 'Illegal position because that is not in: ' + str(
             Board.turn_name)
         return False
     return True
Ejemplo n.º 6
0
 def ability(self, Pieces, Board, *args):
     Capture = False
     done = False
     while not done:
         for event in pg.event.get():
             if event.type == pg.QUIT:
                 quit()
             elif event.type == pg.KEYDOWN:
                 if event.key == pg.K_ESCAPE:
                     self.unselect(Pieces, Board)
                     return False
             elif event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
                 mouse_pos = pg.mouse.get_pos()
                 loc = Loc_To_UL(mouse_pos)
                 if self.legal_move(loc, Board, Pieces):
                     for piece in Pieces:
                         if piece.loc == loc and piece.controller != self.controller:
                             Capture = True
                     self.move(loc, Pieces, Board)
                     done = True
     self.select()
     while Capture:
         Board.update()
         Pieces.update()
         pg.display.flip()
         for event in pg.event.get():
             if event.type == pg.QUIT:
                 quit()
             elif event.type == pg.KEYDOWN:
                 if event.key == pg.K_ESCAPE:
                     self.unselect(Pieces, Board)
                     return False
             elif event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
                 mouse_pos = pg.mouse.get_pos()
                 loc = Loc_To_UL(mouse_pos, Board)
                 if self.legal_move2(loc, Pieces, Board):
                     self.loc = loc
                     self.loc_type = Find_Zone(self.loc)
                     temp = False
                     for piece in Pieces:
                         if piece.controller != self.controller and piece.loc == loc:
                             piece.remove(Pieces)
                             temp = True
                     Capture = temp
     self.unselect(Pieces, Board)
     return True
Ejemplo n.º 7
0
 def place(self, loc, Pieces, Board):
     self.loc = loc
     self.pos = Loc_To_Cell(loc, Board)
     self.loc_type = Find_Zone(self.pos)
     self.unselect(Pieces, Board)