Exemplo n.º 1
0
	def wait_move_validation(self):
		while self.running:
			data = get(URL_BASE + WAITING_MOVE_VALIDATION, {
				'game_id': self.game_id
			})
			if 'move' in data:
				self.move_id = data['move']['id']
				move_type = data['move']['move_type']
				move = data['move']['movimentations'][0]
				if move_type == 1: #castling
					for move in data['move']['movimentations']:
						if move['from'] in ['e1', 'e8']:
							return (
								chess_notation_to_tuple(move['from']),
								chess_notation_to_tuple(move['to']),
								5
							)
				elif move_type == 3: #promotion
					return (
						chess_notation_to_tuple(move['from']),
						chess_notation_to_tuple(move['to']),
						PROMOTION_MAP[data['move']['promotion_type']]
					)
				return (
					chess_notation_to_tuple(move['from']),
					chess_notation_to_tuple(move['to']),
					5
				)
			sleep(3)
 def test_cn_A1_to_tuple_0_0(self):
     self.assertEqual(chess_notation_to_tuple("a1"), (0, 0))
 def test_cn_A8_to_tuple_0_7(self):
     self.assertEqual(chess_notation_to_tuple("a8"), (0, 7))