コード例 #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')
コード例 #2
0
 def test_can_form_bridge(self):
     p = piece.VerticalPiece(None)
     self.assertEqual(p.can_form_bridge(), False)
コード例 #3
0
 def test_can_be_stacked(self):
     p = piece.VerticalPiece(None)
     self.assertEqual(p.can_be_stacked(), False)
コード例 #4
0
 def test_owner(self):
     loc = location.Location(0, 0)
     p = piece.VerticalPiece(None)
     loc.add_piece(p)
     self.assertEqual(loc.owner(), None)
コード例 #5
0
 def test_place_possible(self):
     loc = location.Location(0, 0)
     p = piece.VerticalPiece(None)
     loc.add_piece(p)
     self.assertEqual(loc.place_possible(), False)
コード例 #6
0
 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])
コード例 #7
0
 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])