Example #1
0
def test_translate_empty_rack():
	orig_rack = '0:G 1:B'
	rack_player, rack_opponent = tu.translate_rack(orig_rack)
	assert rack_player == []
	assert rack_opponent == []
Example #2
0
def test_translate_rack():
	orig_rack = '0:G 47 25 5 3 46 19 1:B 36 31 6 11 40 48'
	rack_player, rack_opponent = tu.translate_rack(orig_rack)
	assert rack_player == [47, 25, 5, 3, 46, 19]
	assert rack_opponent == [36, 31, 6, 11, 40, 48]
Example #3
0
def test_translate_partial_racks():
	orig_rack = '0:G 47 25 5 3 1:B 36 '
	rack_player, rack_opponent = tu.translate_rack(orig_rack)
	assert rack_player == [47, 25, 5, 3]
	assert rack_opponent == [36]
Example #4
0
tiles = {}
for i, tile in enumerate(all_tiles):
	thistile = tu.Tile(tile, 0, all_tiles[tile], 'stack')
	tiles[thistile.ID] = thistile
del all_tiles



# boardstring comes from example in Oliver's pdf, Fig 4.1     THESE TWO COME FROM THE TANTRIX SERVER
orig_boardstring = '7@28,18 0 8@25,17 5 15@27,17 3 17@29,15 3 18@28,14 0 20@28,16 3 32@25,15 2 34@27,15 0 35@26,16 2 52@24,16 3'
orig_rack = '0:G 47 25 5 3 46 19 1:B 36 31 6 11 40 48'


board = tu.translate_board(orig_boardstring)
rack_player, rack_opponent = tu.translate_rack(orig_rack)

# Due to this board thing, update the tiles:
for i, tile in enumerate(board[0]):
	# The rotate updates colors and position
	tiles[tile].rotate(board[2][i])
	tiles[tile].place = 'board'
	tiles[tile].coords = board[1][i]
for tile in rack_player:
	tiles[tile].place = 'rack_player'
for tile in rack_opponent:
	tiles[tile].place = 'rack_opponent'


#print coords_in_dir([27,15],0)
#print coords_in_dir([27,15],0, tilenr=True)