示例#1
0
	def place_vertical_piece(self, x, y, board: board.Board):
		if self.normal_pieces==0:
			raise Exception('Error: No pieces left')
		else:
			loc = board.get_location(x,y)
			if loc.place_possible():
				p = piece.VerticalPiece(self)
				loc.add_piece(p)
				board.update_location(x,y,loc)
				self.normal_pieces-=1
				return board
			else:
				raise Exception('Error: Invalid placement')
 def test_can_form_bridge(self):
     p = piece.VerticalPiece(None)
     self.assertEqual(p.can_form_bridge(), False)
 def test_can_be_stacked(self):
     p = piece.VerticalPiece(None)
     self.assertEqual(p.can_be_stacked(), False)
 def test_owner(self):
     loc = location.Location(0, 0)
     p = piece.VerticalPiece(None)
     loc.add_piece(p)
     self.assertEqual(loc.owner(), None)
 def test_place_possible(self):
     loc = location.Location(0, 0)
     p = piece.VerticalPiece(None)
     loc.add_piece(p)
     self.assertEqual(loc.place_possible(), False)
 def test_add_get_pieces(self):
     loc = location.Location(0, 0)
     p1 = piece.HorizontalPiece(None)
     p2 = piece.VerticalPiece(None)
     loc.add_pieces([p1, p2])
     self.assertEqual(loc.get_pieces(2), [p1, p2])
 def test_add_get_piece(self):
     loc = location.Location(0, 0)
     p = piece.VerticalPiece(None)
     loc.add_piece(p)
     self.assertEqual(loc.get_pieces(1), [p])