func (b *Board) MoveTiles(tilePositions map[tile.ID]tile.Position) error {
	if !b.CanMoveTiles(tilePositions) {
		return errors.New("cannot move tiles that the player does not have or cannot move tiles to the same spot as others")
	}
	for _, tp := range tilePositions {
		_, tileUnused := b.UnusedTiles[tp.Tile.ID]
		switch {
		case tileUnused:
			b.removeUnusedTile(tp.Tile)
		default:
			oldTp := b.UsedTiles[tp.Tile.ID]
			if b.UsedTileLocs[oldTp.X][oldTp.Y].ID == tp.Tile.ID {
				delete(b.UsedTileLocs[oldTp.X], oldTp.Y)
				if len(b.UsedTileLocs[oldTp.X]) == 0 {
					delete(b.UsedTileLocs, oldTp.X)
				}
			}
		}
		if _, ok := b.UsedTileLocs[tp.X]; !ok {
			b.UsedTileLocs[tp.X] = make(map[tile.Y]tile.Tile, 1)
		}
		b.UsedTileLocs[tp.X][tp.Y] = tp.Tile
		b.UsedTiles[tp.Tile.ID] = tp
	}
	return nil
}
// MoveTiles moves the tiles to the specified positions.
// No action is taken and an error is returned if the tiles cannot be moved.
MoveTiles moves the tiles to the specified positions.
No action is taken and an error is returned if the tiles cannot be moved.
// MoveTiles moves the tiles to the specified positions . // No action is taken and an error is returned if the tiles cannot be moved .
func (b *Board) MoveTiles(tilePositions map[tile.ID]tile.Position) error {
	if !b.CanMoveTiles(tilePositions) {
		return errors.New("cannot move tiles that the player does not have or cannot move tiles to the same spot as others")
	}
	for _, tp := range tilePositions {
		_, tileUnused := b.UnusedTiles[tp.Tile.ID]
		switch {
		case tileUnused:
			b.removeUnusedTile(tp.Tile)
		default:
			oldTp := b.UsedTiles[tp.Tile.ID]
			if b.UsedTileLocs[oldTp.X][oldTp.Y].ID == tp.Tile.ID {
				delete(b.UsedTileLocs[oldTp.X], oldTp.Y)
				if len(b.UsedTileLocs[oldTp.X]) == 0 {
					delete(b.UsedTileLocs, oldTp.X)
				}
			}
		}
		if _, ok := b.UsedTileLocs[tp.X]; !ok {
			b.UsedTileLocs[tp.X] = make(map[tile.Y]tile.Tile, 1)
		}
		b.UsedTileLocs[tp.X][tp.Y] = tp.Tile
		b.UsedTiles[tp.Tile.ID] = tp
	}
	return nil
}
func ( b * Board ) MoveTiles ( tilePositions map [ tile . ID ] tile . Position ) error { if ! b . CanMoveTiles ( tilePositions ) { return errors . New ( " " ) } for _ , tp := range tilePositions { _ , tileUnused := b . UnusedTiles [ tp . Tile . ID ] switch { case tileUnused : b . removeUnusedTile ( tp . Tile ) default : oldTp := b . UsedTiles [ tp . Tile . ID ] if b . UsedTileLocs [ oldTp . X ] [ oldTp . Y ] . ID == tp . Tile . ID { delete ( b . UsedTileLocs [ oldTp . X ] , oldTp . Y ) if len ( b . UsedTileLocs [ oldTp . X ] ) == 0 { delete ( b . UsedTileLocs , oldTp . X ) } } } if _ , ok := b . UsedTileLocs [ tp . X ] ; ! ok { b . UsedTileLocs [ tp . X ] = make ( map [ tile . Y ] tile . Tile , 1 ) } b . UsedTileLocs [ tp . X ] [ tp . Y ] = tp . Tile b . UsedTiles [ tp . Tile . ID ] = tp } return nil }
MoveTiles moves the tiles to the specified positions.
MoveTiles moves the tiles to the specified positions .