Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Net
- Imports System.IO
- Public Class Form1
- Dim ModoDepuracion As Boolean
- ' La formula es:
- ' http://realm116.c3.godfather.wonderhill.com/api/map.json?x=10&city_id=0&y=10&_session_id=0&gangster=4238791e6dd7f5e2e376cad3cb291da3dae58fdd&user_id=6108242
- ' Go! Por Kimeraweb
- Dim _x, _y As Integer
- Dim _arraylist_city_wildernesses As New List(Of CityWildernesses)
- Dim _arraylist_terrain As New List(Of Terrain)
- Dim _arraylist_mapCities As New List(Of MapCities)
- Dim _c1_a, _c2_a, _c3_a As Integer ' Una idea, contar los terrenos para pasarlos como parametro a los insertquery
- Dim _c1_b, _c2_b, _c3_b As Integer ' Una idea, contar los terrenos para pasarlos como parametro a los insertquery
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- ' Modo depuracion!!
- ModoDepuracion = False
- ' Si el modo de depuracion esta activado, entonces no cargara de internet, sino de los ficheros del disco
- '
- Dim cadena As String = ""
- Button1.Enabled = False
- Button1.Text = "..."
- Refresh()
- Dim x, y, contador As Integer
- x = TextBox_ScanX.Text
- y = TextBox_ScanY.Text
- contador = -1
- _c1_a = 0
- _c2_a = 0
- _c3_a = 0
- _c1_b = 0
- _c2_b = 0
- _c3_b = 0
- While (y <= TextBox_ScanY2.Text And x <= TextBox_ScanX2.Text)
- Dim URL = GetURL(x.ToString, y.ToString)
- TextBox_FullURL.Text = URL
- ' Refresh()
- If (ModoDepuracion = False) Then
- otraVez:
- Try
- Dim request As WebRequest = WebRequest.Create(URL) ' Peticion
- Dim response As WebResponse = request.GetResponse() ' Respuesta
- Dim reader As New StreamReader(response.GetResponseStream()) ' Lectura de la cadena de texto
- cadena = reader.ReadToEnd()
- response.Close()
- reader.Close()
- Catch var As System.Net.WebException
- ' si no hay internet, repetimos hasta que duela
- GoTo otraVez
- ' Grabando datos
- ' My.Computer.FileSystem.WriteAllText("datos_puros_" & x & "_" & y & ".sql", cadena, True)
- End Try
- End If
- ' TextBox_JSON.Text = cadena
- ' Solo me interesan los campos city_wildernesses(condos) y terrain y map_cities, saltandome lo de Alcapone que esta suelto por medio
- If (ModoDepuracion) Then
- cadena = My.Computer.FileSystem.ReadAllText("datos_puros_" & x & "_" & y & ".sql")
- End If
- ' Escruto de city_wildernesses
- Dim city_pos_ini As Integer = InStr(cadena, "city_wildernesses")
- Dim city_pos_fin As Integer = InStr(city_pos_ini + 1, cadena, "]")
- Dim city As String = Mid(cadena, city_pos_ini + 20, city_pos_fin - city_pos_ini - 20)
- add_City_wildernesses(city) ' Añado la cadena para que sea escrutada
- ' Sacamos los querys de los datos obtenidos
- If (CheckBox_MostrarCityWildness.Checked = True) Then
- insertQuery_cityPos(1, _c1_a, _c1_b) ' Muestra el resultado en pantalla y crea el SQL
- ElseIf (CheckBox_MostrarCityWildness.Checked = False) Then
- insertQuery_cityPos(0, _c1_a, _c1_b) ' Solo crea el SQL
- End If
- _c1_b = _c1_a
- '
- 'Escruto de terrain
- Dim terrain_pos_ini As Integer = InStr(cadena, "terrain")
- Dim terrain_pos_fin As Integer = InStr(terrain_pos_ini + 1, cadena, "]]," & Chr(34))
- If (terrain_pos_fin = 0) Then terrain_pos_fin = InStr(terrain_pos_ini + 1, cadena, "]]]}") ' ]]]}"
- Dim terrain As String = Mid(cadena, terrain_pos_ini + 10, terrain_pos_fin - terrain_pos_ini - 8)
- add_Terrain(terrain) ' Añado la cadena para que sea escrutada
- '
- If (CheckBox_terrain.Checked = True) Then
- insertQuery_terrainPos(1, _c2_a, _c2_b)
- ElseIf (CheckBox_terrain.Checked = False) Then
- insertQuery_terrainPos(0, _c2_a, _c2_b)
- End If
- Dim map_cities As String = ""
- 'Try
- 'Escruto de map_cities
- Dim map_cities_pos_ini As Integer = InStr(cadena, "map_cities")
- Dim map_cities_pos_fin As Integer = InStr(map_cities_pos_ini + 1 + 2, cadena, "}]," & Chr(34)) ' +2 para quitar 2 sibolos o }]}
- If (map_cities_pos_fin = 0) Then map_cities_pos_fin = InStr(map_cities_pos_ini + 1, cadena, "}]}")
- map_cities = Mid(cadena, map_cities_pos_ini + 10, map_cities_pos_fin - map_cities_pos_ini - 8)
- map_cities = map_cities & "}" ' añado una llave porque add_MapCities cuenta las llaves anidadas. Por defecto el corte no añade una } o ,
- add_MapCities(map_cities, cadena) ' Añado la cadena para que sea escrutada, cadena original para debug.
- ' Sacamos los querys de los datos obtenidos
- If (CheckBox_MapCities.Checked = True) Then
- insertQuery_mapCities(1, _c3_a, _c3_b) ' Muestra el resultado en pantalla y crea el SQL
- ElseIf (CheckBox_MapCities.Checked = False) Then
- insertQuery_mapCities(0, _c3_a, _c3_b) ' Solo crea el SQL
- End If
- If (ModoDepuracion) Then
- ' MsgBox(map_cities)
- End If
- ' TextBox_JSON.Text = map_cities
- 'Catch var As Exception
- ' My.Computer.FileSystem.WriteAllText("ObjetoActual.txt", cadena, False)
- ' My.Computer.FileSystem.WriteAllText("MapCitiesActual.txt", map_cities, False)
- ' TextBox_JSON.Text = var.ToString
- ' Stop
- 'End Try
- x = x + 16
- contador = contador + 1
- If x > 750 Or x > TextBox_ScanX2.Text Then
- x = 16
- y = y + 16
- End If
- ' Informacion
- Label_progresoX.Text = x 'cx
- Label_ProgresoY.Text = y 'cy
- 'showJSON(contador) ' muestra el ultimo objeto cargado
- showProgressBar(x, y, TextBox_ScanX2.Text, TextBox_ScanY2.Text) ' Actualizamos la barra de progreso
- showCuadrantesLeidos(contador * 16)
- End While
- End Sub
- Private Sub insertQuery_cityPos(ByVal s As Boolean, ByVal a1 As Integer, ByVal a2 As Integer)
- Dim t As CityWildernesses
- Dim q As String = ""
- For x As Integer = a2 To a1 - 1
- t = _arraylist_city_wildernesses.Item(x)
- If (s = 1) Then
- TextBox_JSON.Text = "1> " & t.getAllianceId & vbCrLf &
- "2> " & t.getAllianceName & vbCrLf &
- "3> " & t.getCityWildernessesId & vbCrLf &
- "4> " & t.getCityWildernessesLastCollectedAt & vbCrLf &
- "5> " & t.getCityWildernessesLv & vbCrLf &
- "6> " & t.getCityWildernessesX & vbCrLf &
- "7> " & t.getCityWildernessesY & vbCrLf &
- "8> " & t.getOwnerCreatedAt & vbCrLf &
- "9> " & t.getOwnerFamily & vbCrLf &
- "10>" & t.getOwnerId & vbCrLf &
- "11>" & t.getOwnerIsDon & vbCrLf &
- "12>" & t.getOwnerLastDonMessage & vbCrLf &
- "13>" & t.getOwnerLastOnline & vbCrLf &
- "14>" & t.getOwnerLv & vbCrLf &
- "15>" & t.getOwnerName & vbCrLf &
- "16>" & t.getOwnerPlataform & vbCrLf &
- "17>" & t.getOwnerProtectedUntil & vbCrLf &
- "18>" & t.getOwnerRespect & vbCrLf &
- "19>" & t.getOwnerTitle
- Refresh()
- End If
- ' Creo el archivo SQL
- q = "Insert into citywildernesses (alliance_Id, alliance_Name, cityWildernesses_Id, cityWildernesses_LastCollectedAt,cityWildernesses_Lv," &
- "cityWildernesses_X, CityWildernesses_Y, owner_CreatedAt,owner_Family,owner_Id,owner_IsDon,owner_LastDonMessage,owner_LastOnline," &
- "owner_Lv,owner_Name,owner_Plataform,owner_ProtectedUntil,owner_Respect,owner_Title) VALUES (" &
- "'" & t.getAllianceId & "'," &
- "'" & t.getAllianceName & "'," &
- "'" & t.getCityWildernessesId & "'," &
- "'" & t.getCityWildernessesLastCollectedAt & "'," &
- "'" & t.getCityWildernessesLv & "'," &
- "'" & t.getCityWildernessesX & "'," &
- "'" & t.getCityWildernessesY & "'," &
- "'" & t.getOwnerCreatedAt & "'," &
- "'" & t.getOwnerFamily & "'," &
- "'" & t.getOwnerId & "'," &
- "'" & t.getOwnerIsDon & "'," &
- "'" & t.getOwnerLastDonMessage & "'," &
- "'" & t.getOwnerLastOnline & "'," &
- "'" & t.getOwnerLv & "'," &
- "'" & t.getOwnerName & "'," &
- "'" & t.getOwnerPlataform & "'," &
- "'" & t.getOwnerProtectedUntil & "'," &
- "'" & t.getOwnerRespect & "'," &
- "'" & t.getOwnerTitle & "');" & vbCrLf
- My.Computer.FileSystem.WriteAllText("citywildnesses.sql", q, True)
- Next
- End Sub
- Private Sub insertQuery_terrainPos(ByVal s As Boolean, ByVal b1 As Integer, ByVal b2 As Integer)
- Dim t As Terrain
- Dim q As String = ""
- For x As Integer = b2 To b1 - 1
- t = _arraylist_terrain.Item(x)
- If (s = 1) Then
- TextBox_Terrain.Text = "1> " & t.get_terrainType & vbCrLf &
- "2> " & t.get_terrain_lv & vbCrLf &
- "3> " & t.get_terrain_cx & vbCrLf &
- "4> " & t.get_terrain_cy
- Refresh()
- End If
- ' Creo el archivo SQL
- q = "Insert into terrain (type, level, cx, cy) VALUES (" &
- "'" & t.get_terrainType & "'," &
- "'" & t.get_terrain_lv & "'," &
- "'" & t.get_terrain_cx & "'," &
- "'" & t.get_terrain_cy & "');" & vbCrLf
- My.Computer.FileSystem.WriteAllText("terrain.sql", q, True)
- Next
- End Sub
- Private Sub insertQuery_mapCities(ByVal s As Boolean, ByVal c1 As Integer, ByVal c2 As Integer)
- Dim t As MapCities
- Dim q As String = ""
- For x As Integer = c2 To c1 - 1
- t = _arraylist_mapCities.Item(x)
- If (s = 1) Then
- TextBox_MapCities.Text = "1> " & t.getMapCitiesName & vbCrLf &
- "2> " & t.getMapId & vbCrLf &
- "3> " & t.getMapCitiesX & vbCrLf &
- "4> " & t.getMapCitiesY & vbCrLf &
- "5> " & t.getMapCitiesType & vbCrLf &
- "6> " & t.getMapCitiesProtectedUntil & vbCrLf &
- "7> " & t.getMapCitiesProtected & vbCrLf &
- "8> " & t.getOwnerId & vbCrLf &
- "9> " & t.getOwnerName & vbCrLf &
- "10>" & t.getOwnerProtectedUntil & vbCrLf &
- "11>" & t.getOwnerRespectTtile & vbCrLf &
- "12>" & t.getOwnerRespect & vbCrLf &
- "13>" & t.getOwnerLevel & vbCrLf &
- "14>" & t.getOwnerLastOnline & vbCrLf &
- "15>" & t.getOwnerName & vbCrLf &
- "16>" & t.getOwnerFamily & vbCrLf &
- "17>" & t.getOwnerPlatform & vbCrLf &
- "18>" & t.getOwnerIsDon & vbCrLf &
- "19>" & t.getOwnerLastDonMessageSentAt & vbCrLf &
- "20>" & t.getAllianceName & vbCrLf &
- "21>" & t.getAllianceId
- Refresh()
- End If
- ' Creo el archivo SQL
- q = "Insert into mapcities (mapcities_name, mapcities_id, mapcities_x, mapcities_y,mapcities_type,mapcities_protected_until," &
- "mapcities_protected, owner_id, owner_name,owner_protected_until,owner_respect_title,owner_respect,owner_lv,owner_created_at," &
- "owner_last_online,owner_family,owner_plataform,owner_is_don,owner_last_don_message,alliance_name,alliance_id) VALUES (" &
- "'" & t.getMapCitiesName & "'," &
- "'" & t.getMapId & "'," &
- "'" & t.getMapCitiesX & "'," &
- "'" & t.getMapCitiesY & "'," &
- "'" & t.getMapCitiesType & "'," &
- "'" & t.getMapCitiesProtectedUntil & "'," &
- "'" & t.getMapCitiesProtected & "'," &
- "'" & t.getOwnerId & "'," &
- "'" & t.getOwnerName & "'," &
- "'" & t.getOwnerProtectedUntil & "'," &
- "'" & t.getOwnerRespectTtile & "'," &
- "'" & t.getOwnerRespect & "'," &
- "'" & t.getOwnerLevel & "'," &
- "'" & t.getOwnerCreatedAt & "'," &
- "'" & t.getOwnerLastOnline & "'," &
- "'" & t.getOwnerFamily & "'," &
- "'" & t.getOwnerPlatform & "'," &
- "'" & t.getOwnerIsDon & "'," &
- "'" & t.getOwnerLastDonMessageSentAt & "'," &
- "'" & t.getAllianceName & "'," &
- "'" & t.getAllianceId & "');" & vbCrLf
- My.Computer.FileSystem.WriteAllText("mapcities.sql", q, True)
- Next
- End Sub
- Private Function GetURL(ByVal x As String, ByVal y As String)
- Dim FullURL As String = " http://realm116.c3.godfather.wonderhill.com/api/map.json?x=" & x & "&city_id=0&y=" & y & "&_session_id=0&gangster=4238791e6dd7f5e2e376cad3cb291da3dae58fdd&user_id=6108242"
- Return FullURL
- End Function
- Private Sub add_City_wildernesses(ByVal data As String)
- ' Estrategia, contar las llaves que se abren y restar las que se cierran para obtener la longitud de cada player en cada city
- ' Los datos se desmontan para crear un solo objeto cada vez
- Dim c As Char
- Dim cw As String
- Dim pos As Integer = 1
- Dim contador_llaves As Integer = 0
- ' Ante de empezar, limpiar los campos name de { y }
- Dim bug_ini As Integer = 1
- Dim bug_end As Integer = 1
- For x As Integer = bug_ini To data.Length
- bug_ini = InStr(x, data, "name" & Chr(34) & ":" & Chr(34))
- bug_end = InStr(bug_ini + 7, data, Chr(34))
- For y As Integer = bug_ini + 7 To bug_end ' que pongo aqui? -1, -2 o -3?? - Bug de VB, no se puede cambiar la variable del for
- If (y <= bug_end) Then
- If (Mid(data, y, 1) = "{") Or (Mid(data, y, 1) = "}") Or (Mid(data, y, 1) = "'" Or (Mid(data, y, 1) = "\")) Then
- data = data.Remove(y - 1, 1)
- bug_end = bug_end - 1
- End If
- End If
- Next
- Next
- '
- For contador As Integer = 1 To data.Length
- c = Mid(data, contador, 1)
- If c = "{" Then
- contador_llaves = contador_llaves + 1
- If c = "{" And contador_llaves = 1 Then pos = contador
- End If
- If c = "}" Then
- contador_llaves = contador_llaves - 1
- If contador_llaves = 0 Then
- cw = Mid(data, pos, contador - pos + 1)
- Dim a As New CityWildernesses
- a.constructor(cw)
- _arraylist_city_wildernesses.Add(a)
- _c1_a = _c1_a + 1 ' conteo de cuantas wildernesses lleva metidas
- End If
- End If
- Next
- 'TextBox_JSON.Text = "Numero: " & _arraylist_city_wildernesses.Count.ToString
- 'TextBox_JSON.Text = _arraylist_city_wildernesses.Item(0).showData & vbCrLf & vbCrLf
- 'TextBox_JSON.Text = TextBox_JSON.Text & vbCrLf & _arraylist_city_wildernesses.Count
- 'TextBox_JSON.Text = TextBox_JSON.Text & vbCrLf & _arraylist_city_wildernesses.Item(0).showAll()
- 'TextBox_JSON.Text = TextBox_JSON.Text & vbCrLf & _arraylist_city_wildernesses.Item(1).showAll()
- End Sub
- Private Sub add_Terrain(ByVal data As String)
- ' Los datos se desmontan para crear un solo objeto cada vez
- ' Estrategia, buscar [[ y ]]],
- ' TextBox_JSON.Text = data
- ' Problema, contar los corchetes para descartar los anidamientos
- Dim c As Char
- Dim terrain_type, terrain_lv, terrain_cy, terrain_cx As String
- Dim next_pos, next_pos2 As Integer
- For contador As Integer = 1 To data.Length
- c = Mid(data, contador, 1)
- ' Si encuentro una " ya se que lo que sigue es "gang",lv,y,x]
- If (c = Chr(34)) Then
- ' Nombre del terreno (gang, cityscape...)
- next_pos = InStr(contador + 1, data, Chr(34))
- terrain_type = Mid(data, contador + 1, next_pos - contador - 1)
- ' Lv del terreno
- next_pos = InStr(contador + 1, data, ",")
- next_pos2 = InStr(next_pos + 1, data, ",")
- terrain_lv = Mid(data, next_pos + 1, next_pos2 - next_pos - 1)
- ' Pos Y
- next_pos = next_pos2 + 1
- next_pos2 = InStr(next_pos, data, ",")
- terrain_cy = Mid(data, next_pos, next_pos2 - next_pos)
- ' Pos X
- next_pos = next_pos2 + 1
- next_pos2 = InStr(next_pos, data, "]")
- terrain_cx = Mid(data, next_pos, next_pos2 - next_pos)
- contador = next_pos2
- 'MsgBox(terrain_type & "-" & terrain_lv & "-" & terrain_cy & "-" & terrain_cx)
- Dim a As New Terrain
- a.constructor(terrain_type, terrain_lv, terrain_cx, terrain_cy)
- _arraylist_terrain.Add(a)
- _c2_a = _c2_a + 1
- End If
- Next
- End Sub
- Private Sub add_MapCities(ByVal data As String, ByVal debug As String)
- ' Los datos se desmontan para crear un solo objeto cada vez
- ' Estrategia, primero sacar al player, luego sacar los barrios, para ello cortar la city.
- ' Van dos datos dentro, asi que hay que diferenciarlos.
- ' { { }, }, - usare las llaves, porque puede cambiar a }}
- '
- ' Atencion, un bug:
- '
- ' "name":"}ass",
- '
- Dim c1 As Char = "{"
- Dim c2 As Char = "}"
- Dim mapCities As String
- Dim pos1, pos2, llavesAbiertas As Integer
- ' Resolver el bug de las llaves en el campo name del player
- ' Buscar player para acceder a la propiedad name
- Dim bug_pos1 As Integer
- Dim bug_pos2 As Integer
- Dim bug_pos3 As Integer
- Dim bug_pos4 As Integer
- Dim bug_name As String
- bug_pos1 = InStr(data, "player")
- ' Esta funcionando? Una info en pantalla
- Label_bitsLeidos.Text = data.Length.ToString
- For indice As Integer = bug_pos1 To data.Length
- bug_pos2 = InStr(indice, data, "name" & Chr(34) & ":")
- If (bug_pos2 > 0) Then ' Existe en campo name, seguimos
- bug_pos3 = InStr(bug_pos2 + 6, data, Chr(34))
- bug_pos4 = InStr(bug_pos3 + 1, data, Chr(34)) ' DEPURACION: +7
- bug_name = Mid(data, bug_pos3 + 1, bug_pos4 - bug_pos3 - 1)
- ' DEPURACION: recorrer la cadena y eliminar el caracter { }
- ' Al quitar el caracter, hay que quitar una posicion de la cadena, y por un bug en vbasic, no se puede cambiar el valor final de la iteracion
- Dim fin_iteracion As Integer = bug_pos4
- For x As Integer = bug_pos3 To bug_pos4
- If (bug_pos4 <= fin_iteracion) Then
- If (Mid(data, x, 1) = "{") Or (Mid(data, x, 1) = "}") Or (Mid(data, x, 1) = "'" Or (Mid(data, x, 1) = "\")) Then
- data = data.Remove(x - 1, 1)
- fin_iteracion = fin_iteracion - 1
- End If
- End If
- Next
- 'indice = bug_pos4 + 1
- 'If (InStr(bug_name, "}") > 0) Then
- 'data = data.Remove(InStr(bug_pos3, data, "}") - 1, 1)
- 'End If
- 'If (InStr(bug_name, "{") > 0) Then
- 'data = data.Remove(InStr(bug_pos3, data, "{") - 1, 1)
- 'End If
- 'If (InStr(bug_pos4 + 1, data, "player") > 0) Then
- 'indice = InStr(bug_pos4 + 1, data, "player")
- 'End If
- 'MsgBox(bug_name & " " & data.Length, , indice)
- End If
- ' Esta funcionando? Una info en pantalla
- If (indice * 100 / data.Length Mod 2 = 0) Then
- Label_bitsProcesados.Text = indice
- 'Refresh()
- End If
- Next
- ' --- FIN extraccion de llaves / bug
- llavesAbiertas = 0
- For contador As Integer = 1 To data.Length()
- If (Mid(data, contador, 1) = c1) Then
- llavesAbiertas = llavesAbiertas + 1
- If (llavesAbiertas = 1) Then pos1 = contador
- End If
- 'My.Computer.FileSystem.WriteAllText("ObjetoActual.txt", data, False)
- If (Mid(data, contador, 1) = c2) Then
- llavesAbiertas = llavesAbiertas - 1
- If (llavesAbiertas = 0) Then ' Entonces ya tenemos el bloque de ciudades con los datos del owner
- pos2 = contador
- ' Cortar y crear
- mapCities = Mid(data, pos1, pos2 - pos1)
- mapCities = mapCities & "}" ' A veces no sale la llave, otras si, asi que pongo otra y siempre tengo al menos 1.
- Dim a As New MapCities
- a.constructor(mapCities, debug, TextBox_JSON)
- _arraylist_mapCities.Add(a)
- _c3_a = _c3_a + 1
- If (ModoDepuracion) Then
- 'MsgBox(mapCities)
- End If
- End If
- End If
- Next
- End Sub
- Private Sub showProgressBar(ByVal x As Integer, ByVal y As Integer, ByVal x_lim As Integer, ByVal y_lim As Integer)
- Dim perx As Integer = x * 100 / x_lim
- Dim pery As Integer = y * 100 / y_lim
- If perx > 100 Then perx = 100
- If pery > 100 Then pery = 100
- ProgressBar1.Value = perx
- ProgressBar2.Value = pery
- Refresh()
- End Sub
- Private Sub showJSON(ByVal indice As Integer)
- TextBox_JSON.Text = _arraylist_city_wildernesses.Item(indice).showAll()
- Refresh()
- End Sub
- Private Sub showCuadrantesLeidos(ByVal indice)
- Label_cuadrantesLeidos.Text = indice & " / 562500"
- Refresh()
- End Sub
- End Class
- Class CityWildernesses
- Dim _data, __data, _info_player, _info_alianza, _info_condo As String
- Dim _alliance_id, _alliance_name As String
- Dim _owner_family, _owner_id, _owner_lv, _owner_lastOnline, _owner_title, _owner_lastDonMessage, _owner_createdAt, _owner_protectedUntil, _owner_name, _owner_plataform, _owner_isDon, _owner_respect As String
- Dim _cityWildernesses_id, _cityWildernesses_lv, _cityWildernesses_x, _cityWildernesses_y, _cityWildernesses_last_collected_at As String
- Public Sub constructor(ByVal data As String)
- ' Inicializa variables
- data = data.Replace("\", "*") ' problemas con el caracter escape en mysql
- _data = data
- __data = data ' Este no cambia
- _info_player = ""
- _info_alianza = ""
- _info_condo = ""
- Dim pos_ini As Integer = 1
- Dim pos_end As Integer = 1
- Dim pos_ini_alianza As Integer = 1
- Dim pos_end_alianza As Integer = 1
- ' Atencion, desglosar la info del player, alianza y la info del condo antes de comenzar las busquedas
- '*******************
- ' Info de la alianza
- ' Antencion, bug, el nombre de la alianza lleva } - DEPURACION: ya no lleva
- If (InStr(_data, "alliance")) Then
- pos_ini_alianza = InStr(_data, "" & Chr(34) & "alliance" & Chr(34) & ":")
- ' El nombre de la alianza contiene {} los quitamos para cerrar el grupo de la alianza
- 'Dim pos_ini_alianza_name = InStr(pos_ini_alianza, _data, "name" & Chr(34) & ":" & Chr(34))
- 'Dim pos_end_alianza_name = InStr(pos_ini_alianza_name + 1, _data, Chr(34))
- 'For x As Integer = pos_ini_alianza_name + 8 To pos_end_alianza_name
- 'If (Mid(_data, 1)) = "{" Or (Mid(_data, 1)) = "}" Then
- '_data = _data.Remove(x - 1, 1)
- 'End If
- 'Next
- ' el nombre de la alianza ya no contiene {}
- pos_end_alianza = InStr(pos_ini, _data, "}")
- _info_alianza = Mid(_data, pos_ini_alianza + 11, pos_end_alianza - pos_ini_alianza - 11 + 1) ' +1 para que entre el }
- Try
- _data = _data.Remove(pos_ini_alianza - 1, _info_alianza.Length + 11) ' -1 y +1 para que borre la , del inicio y final
- Catch
- ' Si esta al final de la cadena, hay un caracter menos
- _data = _data.Remove(pos_ini_alianza - 1, _info_alianza.Length + 11)
- End Try
- End If
- ' Atencion, el nombre del player puede contener {} tambien hay que arreglar esto
- ' Info del player
- If (InStr(_data, "player")) Then
- pos_ini = InStr(_data, "" & Chr(34) & "player" & Chr(34) & ":")
- ' Busco el nombre del player y le quito los {} - DEPURACION: Ya no lleva
- 'Dim pos_ini_name, pos_end_name As Integer
- 'pos_ini_name = InStr(pos_ini, _data, "name" & Chr(34) & ":" & Chr(34))
- ' Averiguo el name
- 'For x As Integer = pos_ini_name + 8 To _data.Length
- 'If (Mid(_data, x, 1)) = Chr(34) Then
- 'pos_end_name = x
- ' x = _data.Length
- 'End If
- 'Next
- ' Cambio las llaves por nada - TESTEAR!
- 'For x As Integer = pos_ini_name + 8 To pos_end_name
- 'If (Mid(_data, x, 1)) = "{" Or (Mid(_data, x, 1)) = "}" Then
- '_data = _data.Remove(x - 1, 1)
- 'End If
- 'Next
- pos_end = InStr(pos_ini, _data, "}")
- _info_player = Mid(_data, pos_ini + 11, pos_end - pos_ini - 11)
- _info_player = Chr(34) & _info_player & "}" ' DEPURACION: Para que tenga una llave al final del contenido y unas comillas al inicio.
- _data = _data.Remove(pos_ini - 2, pos_end - pos_ini + 2) ' -1 y +1 para que borre la , del inicio y final
- ' Hasta aqui perfecto.
- ' Todo va entre { } y con comillas
- End If
- ' El espacio resultante es la info del condo
- _info_condo = _data ' & "}" ' DEPURACION: este sobra
- ' Datos del Condominio, condo sin ID? Si, la hay.
- ' DEPURACION: Un condo sin ID es poco probable, pero no descarto un bug en Kaban
- If (InStr(_info_condo, "" & Chr(34) & "id" & Chr(34) & ":")) Then
- Try
- ' Buscando la ID del condo (DEPURACION: Perfecto)
- pos_ini = InStr(_info_condo, "" & Chr(34) & "id" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, ",")
- _cityWildernesses_id = Mid(_info_condo, pos_ini + 5, pos_end - pos_ini - 5)
- Catch
- pos_ini = InStr(_info_condo, "" & Chr(34) & "id" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, "}")
- _cityWildernesses_id = Mid(_info_condo, pos_ini + 5, pos_end - pos_ini - 5)
- End Try
- End If
- ' Condo sin level...? Pues si...
- ' DEPURACION: Perfecto. Un condo sin Lv es poco probable, pero no descarto un bug en Kaban
- If InStr(_info_condo, "" & Chr(34) & "level" & Chr(34) & ":") Then
- Try
- ' Buscando el lv del condo
- pos_ini = InStr(_info_condo, "" & Chr(34) & "level" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, ",")
- _cityWildernesses_lv = Mid(_info_condo, pos_ini + 8, pos_end - pos_ini - 8)
- Catch
- pos_ini = InStr(_info_condo, "" & Chr(34) & "level" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, "}")
- _cityWildernesses_lv = Mid(_info_condo, pos_ini + 8, pos_end - pos_ini - 8)
- End Try
- End If
- ' Condos sin coodenadas?? Si... tambien...
- ' DEPURACION: Perfecto. Un condo sin coordenadas es poco probable, pero no descarto un bug en Kaban
- If (InStr(_info_condo, "" & Chr(34) & "x" & Chr(34) & ":")) Then
- Try
- ' Buscando cx del condo
- pos_ini = InStr(_info_condo, "" & Chr(34) & "x" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, ",")
- _cityWildernesses_x = Mid(_info_condo, pos_ini + 4, pos_end - pos_ini - 4)
- Catch
- pos_ini = InStr(_info_condo, "" & Chr(34) & "x" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, "}")
- _cityWildernesses_x = Mid(_info_condo, pos_ini + 4, pos_end - pos_ini - 4)
- End Try
- End If
- ' Condos sin coodenadas?? Si... tambien...
- ' DEPURACION: Perfecto. Un condo sin Lv es poco probable, pero no descarto un bug en Kaban
- If (InStr(_info_condo, "" & Chr(34) & "y" & Chr(34) & ":")) Then
- Try
- ' Buscando cy del condo
- pos_ini = InStr(_info_condo, "" & Chr(34) & "y" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, ",")
- _cityWildernesses_y = Mid(_info_condo, pos_ini + 4, pos_end - pos_ini - 4)
- Catch
- pos_ini = InStr(_info_condo, "" & Chr(34) & "y" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, "}")
- _cityWildernesses_y = Mid(_info_condo, pos_ini + 4, pos_end - pos_ini - 4)
- End Try
- End If
- If (InStr(_info_condo, "last_collected_at")) Then ' Si no tiene dueño, no se recolecciona -.- DE
- Try
- ' Buscando ultima recoleccion del condo
- pos_ini = InStr(_info_condo, "" & Chr(34) & "last_collected_at" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, ",")
- _cityWildernesses_last_collected_at = Mid(_info_condo, pos_ini + 20, pos_end - pos_ini - 20)
- Catch
- 'MsgBox(_info_condo)
- pos_ini = InStr(_info_condo, "" & Chr(34) & "last_collected_at" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_condo, "}")
- _cityWildernesses_last_collected_at = Mid(_info_condo, pos_ini + 20, pos_end - pos_ini - 20)
- End Try
- Else
- _cityWildernesses_last_collected_at = "-1"
- End If
- ' Datos del jugador y su clan (si lo hubiera)
- ' Clan / Alianza
- If (_info_alianza.Length > 0) Then
- pos_ini = InStr(_info_alianza, "" & Chr(34) & "id" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_alianza, "}")
- ' ERROR!!:
- ' "alliance":
- '{
- '"id":300200885,
- '"name":"angeles de la noxe"
- '},
- '
- ' Con esta entrada se consigue: alliance_id = 300200885,"name":"angeles de la noxe"
- ' Estrategia...
- ' Iterar a partir de " y si no es un numero, terminar la iteracion
- Dim nan As Integer
- For x As Integer = pos_ini + 5 To _info_alianza.Length
- nan = Asc(Mid(_info_alianza, x, 1))
- If ((nan < 48) Or (nan > 57)) Then ' del cero al 9
- pos_end = x
- x = _info_alianza.Length
- End If
- Next
- ' DEPURACION: PERFECTO.
- _alliance_id = Mid(_info_alianza, pos_ini + 5, pos_end - pos_ini - 5)
- ' DEPURACION: PERFECTO, solo se coge lo que hay entre las comillas
- pos_ini = InStr(_info_alianza, "" & Chr(34) & "name" & Chr(34) & ":")
- For x As Integer = pos_ini + 8 To _info_alianza.Length
- If (Mid(_info_alianza, x, 1) = Chr(34)) Then
- pos_end = x
- x = _info_alianza.Length
- End If
- Next
- _alliance_name = Mid(_info_alianza, pos_ini + 8, pos_end - pos_ini - 8)
- End If
- ' Jugador
- If (_info_player.Length > 0) Then
- If (InStr(_info_player, "protected_until")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "protected_until" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_protectedUntil = Mid(_info_player, pos_ini + 18, pos_end - pos_ini - 18)
- Catch
- Try
- 'MsgBox(_info_player, , "Protected Until")
- pos_ini = InStr(_info_player, "" & Chr(34) & "protected_until" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_protectedUntil = Mid(_info_player, pos_ini + 18, pos_end - pos_ini - 18)
- Catch
- MsgBox(_info_player, , "Protected Until")
- End Try
- End Try
- Else
- _owner_protectedUntil = "-1"
- End If
- If (InStr(_info_player, "last_don_message_sent_at")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "last_don_message_sent_at" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_lastDonMessage = Mid(_info_player, pos_ini + 27, pos_end - pos_ini - 27)
- Catch
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "last_don_message_sent_at" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_lastDonMessage = Mid(_info_player, pos_ini + 27, pos_end - pos_ini - 27)
- 'MsgBox(_info_player & vbCrLf & pos_end & vbCrLf & pos_ini, , "last_don_message_sent_at")
- Catch
- MsgBox(_info_player, , "last Don Message")
- End Try
- End Try
- Else
- _owner_lastDonMessage = "-1"
- End If
- If (InStr(_info_player, "created_at")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "created_at" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_createdAt = Mid(_info_player, pos_ini + 13, pos_end - pos_ini - 13)
- Catch
- 'MsgBox(_info_player, , "created_at")
- pos_ini = InStr(_info_player, "" & Chr(34) & "created_at" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_createdAt = Mid(_info_player, pos_ini + 13, pos_end - pos_ini - 13)
- End Try
- Else
- _owner_createdAt = "-1"
- End If
- ' Error, si esta info esta al final, no hay , ni }
- If (InStr(_info_player, "id")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "id" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_id = Mid(_info_player, pos_ini + 5, pos_end - pos_ini - 5)
- Catch
- 'MsgBox(_info_player, , "id")
- pos_ini = InStr(_info_player, "" & Chr(34) & "id" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_id = Mid(_info_player, pos_ini + 5, pos_end - pos_ini - 5)
- End Try
- Else
- 'MsgBox(_info_player, , "id")
- _owner_id = "-1"
- End If
- If (InStr(_info_player, "platform")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "platform" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_plataform = Mid(_info_player, pos_ini + 12, pos_end - pos_ini - 13)
- Catch
- 'MsgBox(_info_player, , "platform")
- pos_ini = InStr(_info_player, "" & Chr(34) & "platform" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_plataform = Mid(_info_player, pos_ini + 12, pos_end - pos_ini - 13)
- End Try
- Else
- _owner_plataform = "-1"
- End If
- If (InStr(_info_player, "last_online")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "last_online" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_lastOnline = Mid(_info_player, pos_ini + 14, pos_end - pos_ini - 14)
- Catch
- 'MsgBox(_info_player, , "last_online")
- pos_ini = InStr(_info_player, "" & Chr(34) & "last_online" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_lastOnline = Mid(_info_player, pos_ini + 14, pos_end - pos_ini - 14)
- End Try
- Else
- _owner_lastOnline = "-1"
- End If
- If (InStr(_info_player, "" & Chr(34) & "respect" & Chr(34) & ":")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "respect" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_respect = (Mid(_info_player, pos_ini + 10, pos_end - pos_ini - 10))
- Catch
- Try
- 'MsgBox(_info_player)
- pos_ini = InStr(_info_player, "" & Chr(34) & "respect" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_respect = Mid(_info_player, pos_ini + 10, pos_end - pos_ini - 10)
- Catch
- MsgBox(_info_player, , "respect")
- End Try
- End Try
- Else
- _owner_respect = "-1"
- End If
- If (InStr(_info_player, "is_don")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "is_don" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_isDon = (Mid(_info_player, pos_ini + 9, pos_end - pos_ini - 9))
- Catch
- pos_ini = InStr(_info_player, "" & Chr(34) & "is_don" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_isDon = Mid(_info_player, pos_ini + 9, pos_end - pos_ini - 9)
- End Try
- Else
- _owner_isDon = "-1"
- End If
- If (InStr(_info_player, "respect_title")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "respect_title" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_title = (Mid(_info_player, pos_ini + 17, pos_end - pos_ini - 18))
- Catch
- pos_ini = InStr(_info_player, "" & Chr(34) & "respect_title" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_title = Mid(_info_player, pos_ini + 17, pos_end - pos_ini - 18)
- End Try
- Else
- _owner_title = "-1"
- End If
- If (InStr(_info_player, "level")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "level" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_lv = (Mid(_info_player, pos_ini + 8, pos_end - pos_ini - 8))
- Catch
- pos_ini = InStr(_info_player, "" & Chr(34) & "level" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_lv = Mid(_info_player, pos_ini + 8, pos_end - pos_ini - 8)
- End Try
- Else
- _owner_lv = "-1"
- End If
- If (InStr(_info_player, "family")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "family" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_family = (Mid(_info_player, pos_ini + 9, pos_end - pos_ini - 9))
- Catch
- pos_ini = InStr(_info_player, "" & Chr(34) & "family" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_family = Mid(_info_player, pos_ini + 9, pos_end - pos_ini - 9)
- End Try
- Else
- _owner_family = "-1"
- End If
- If (InStr(_info_player, "name")) Then
- Try
- pos_ini = InStr(_info_player, "" & Chr(34) & "name" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, ",")
- _owner_name = (Mid(_info_player, pos_ini + 8, pos_end - pos_ini - 9))
- Catch
- pos_ini = InStr(_info_player, "" & Chr(34) & "name" & Chr(34) & ":")
- pos_end = InStr(pos_ini, _info_player, "}")
- _owner_name = Mid(_info_player, pos_ini + 8, pos_end - pos_ini - 9)
- End Try
- Else
- _owner_name = "-1"
- End If
- End If
- End Sub
- Public Function showData()
- Return __data
- End Function
- Public Function showCondoId()
- Return _cityWildernesses_id
- End Function
- Public Function showLasctCollectedAt()
- Return _cityWildernesses_last_collected_at
- End Function
- Public Function showAll()
- Dim a As String
- a = "- Info Alianza -" & vbCrLf &
- _info_alianza & vbCrLf & "--------------------" & vbCrLf &
- "- Info player -" & vbCrLf &
- _info_player & vbCrLf & "--------------------" & vbCrLf &
- "- Info Condo -" & vbCrLf &
- _info_condo & vbCrLf & "---------------------" & vbCrLf &
- _cityWildernesses_id & vbCrLf &
- _cityWildernesses_x & vbCrLf &
- _cityWildernesses_y & vbCrLf &
- _cityWildernesses_last_collected_at & vbCrLf & " - Alianza -" & vbCrLf &
- _alliance_id & vbCrLf &
- _alliance_name & vbCrLf & " - PJ Status - " & vbCrLf &
- _owner_family & vbCrLf &
- _owner_id & vbCrLf &
- _owner_lv & vbCrLf &
- _owner_lastOnline & vbCrLf &
- _owner_title & vbCrLf &
- _owner_lastDonMessage & vbCrLf &
- _owner_createdAt & vbCrLf &
- _owner_protectedUntil & vbCrLf &
- _owner_name & vbCrLf &
- _owner_plataform & vbCrLf &
- _owner_isDon & vbCrLf &
- _owner_respect
- Return a
- End Function
- Public Function getCityWildernessesLastCollectedAt()
- Return _cityWildernesses_last_collected_at
- End Function
- Public Function getCityWildernessesY()
- Return _cityWildernesses_y
- End Function
- Public Function getCityWildernessesX()
- Return _cityWildernesses_x
- End Function
- Public Function getCityWildernessesLv()
- Return _cityWildernesses_lv
- End Function
- Public Function getCityWildernessesId()
- Return _cityWildernesses_id
- End Function
- Public Function getOwnerIsDon()
- Return _owner_isDon
- End Function
- Public Function getOwnerRespect()
- Return _owner_respect
- End Function
- Public Function getOwnerCreatedAt()
- Return _owner_createdAt
- End Function
- Public Function getOwnerProtectedUntil()
- Return _owner_protectedUntil
- End Function
- Public Function getOwnerName()
- Return _owner_name
- End Function
- Public Function getOwnerPlataform()
- Return _owner_plataform
- End Function
- Public Function getOwnerLastOnline()
- Return _owner_lastOnline
- End Function
- Public Function getOwnerTitle()
- Return _owner_title
- End Function
- Public Function getOwnerLastDonMessage()
- Return _owner_lastDonMessage
- End Function
- Public Function getAllianceId()
- Return _alliance_id
- End Function
- Public Function getAllianceName()
- Return _alliance_name
- End Function
- Public Function getOwnerFamily()
- Return _owner_family
- End Function
- Public Function getOwnerId()
- Return _owner_id
- End Function
- Public Function getOwnerLv()
- Return _owner_lv
- End Function
- End Class
- Class Terrain
- Dim _terrainType, _terrainLv, _terrainCx, _terrainCy As String
- Public Sub constructor(ByVal terrain_type As String, ByVal terrain_lv As String, ByVal terrain_cx As String, ByVal terrain_cy As String)
- _terrainType = terrain_type
- _terrainLv = terrain_lv
- _terrainCx = terrain_cx
- _terrainCy = terrain_cy
- End Sub
- Public Function showAll()
- Dim a As String = _terrainCx & vbCrLf & _terrainCy & vbCrLf & _terrainLv & vbCrLf & _terrainType & vbCrLf
- Return a
- End Function
- Public Function get_terrainType()
- Return _terrainType
- End Function
- Public Function get_terrain_lv()
- Return _terrainLv
- End Function
- Public Function get_terrain_cx()
- Return _terrainCx
- End Function
- Public Function get_terrain_cy()
- Return _terrainCy
- End Function
- End Class
- Class MapCities
- Dim _MapCities_name, _MapCities_id, _MapCities_y, _MapCities_x, _MapCities_type, _MapCities_protectedUntil, _MapCities_protected, _MapCities_useCommonBuildings As String
- Dim _owner_name, _owner_id, _owner_protected_until, _owner_respect_title, _owner_respect, _owner_level, _owner_createdAt, _owner_lastOnline, _owner_family, _owner_plataform, _owner_isDon, _owner_lastDonMessage As String
- Dim _alliance_name, _alliance_id
- Dim _data As String
- Dim longitud_original As Integer
- ' Sacar al player para obtener los datos de la ciudad
- Public Sub constructor(ByVal data As String, ByVal debug As String, ByRef textBox As TextBox)
- Dim pos1, pos2 As Integer
- Dim alliance, owner As String
- alliance = "-1"
- owner = "-1"
- ' Solo para depuracion
- _data = data
- '
- ' Extraccion de la alianza
- ' ATENCION!! Los de La Camorra tienen caracteres JSON: "name":"LA CAMORRA {^_^}",
- '
- ' "alliance":
- ' {
- ' "name":"LA CAMORRA {^_^}",
- ' "id":300171440
- ' },
- '
- 'Try
- Dim pos1_alliance, pos2_alliance As Integer
- ' Dim pos1_alliance_name, pos2_alliance_name As Integer
- If (InStr(data, "alliance")) Then
- pos1_alliance = InStr(data, "alliance" & Chr(34) & ":")
- ' DEPURACION: buscar el nombre de la alianza y borrar {}, luego continuar con la busqueda de la llave.
- ' DEPURACION: Ya no hace falta, lo hago antes de mandar el texto.
- 'pos1_alliance_name = InStr(pos1_alliance, data, "name" & Chr(34) & ":")
- 'pos2_alliance_name = InStr(pos1_alliance_name + 1, data, Chr(34))
- 'For x As Integer = pos1_alliance_name + 7 To pos2_alliance_name
- 'If (Mid(data, x, 1) = "{") Or (Mid(data, x, 1) = "}") Then
- 'data = data.Remove(x - 1, 1)
- 'End If
- 'Next
- '
- pos2_alliance = InStr(pos1_alliance + 1, data, "}")
- alliance = Mid(data, pos1_alliance + 10 + 1, pos2_alliance - pos1_alliance - 10 - 1) ' +1 para no coger la comilla del principio -1 y del final
- longitud_original = alliance.Length + 12 ' para luego cortar los caracteres en data
- ' Estrategia, buscar name dentro de la alianza, y en el segundo parametro, eliminar las llaves
- 'Dim pos1_name As Integer = InStr(pos1, alliance, "name" & Chr(34) & ":")
- 'Dim pos2_name As Integer = InStr(pos1_name + 6, alliance, Chr(34))
- 'Dim pos3_name As Integer = InStr(pos2_name + 1, alliance, Chr(34))
- 'For posbug As Integer = pos2_name + 1 To pos3_name
- 'If (Mid(alliance, posbug, 1) = "{") Or (Mid(alliance, posbug, 1) = "}") Then
- 'data = data.Remove(posbug - 1, 1)
- 'End If
- 'Next
- 'data = data & "}" ' por si acaso no hubiese, mejor que sobre.
- 'pos2 = InStr(pos1, data, "}")
- 'If Not (Mid(data, pos2 + 1, 1) = Chr(34)) Then ' si no encuentra una comilla doble, es un nombre
- 'pos2 = InStr(pos2 + 1, data, "}") ' entonces busca la siguiente llave
- 'End If
- 'alliance = Mid(data, pos1 + 11, pos2 - pos1 - 11)
- 'alliance = alliance & "," ' de esta manera todos los datos terminan en ,
- alliance = alliance.Replace(Chr(34), "") ' elimino las comillas, de este modo consigo clave:valor,
- alliance = alliance & "," ' el ultimo valor no lleva ,
- ' Corto alliance de data
- data = data.Remove(pos1_alliance - 3, longitud_original + 2)
- ' _alliance_name
- pos1 = InStr(alliance, "name:")
- pos2 = InStr(pos1, alliance, ",")
- _alliance_name = Mid(alliance, pos1 + 5, pos2 - pos1 - 5)
- ' _alliance_id
- pos1 = InStr(alliance, "id:")
- pos2 = InStr(pos1, alliance, ",")
- _alliance_id = Mid(alliance, pos1 + 3, pos2 - pos1 - 3)
- Else
- _alliance_id = -1
- _alliance_name = -1
- End If
- Dim player_pos1, player_pos2 As Integer
- ' Dim player_name_pos1, player_name_pos2 As Integer
- ' Extracion del jugador
- player_pos1 = InStr(data, "player" & Chr(34) & ":")
- ' Borrar las llaves del nombre del jugador
- ' DEPURACION: Esta hecho ya antes de mandarse
- 'player_name_pos1 = InStr(player_pos1 + 1, data, Chr(34))
- 'player_name_pos2 = InStr(player_name_pos1 + 1, data, Chr(34))
- 'For x As Integer = player_name_pos1 To player_name_pos1
- 'If (Mid(data, x, 1) = "{") Or (Mid(data, x, 1) = "}") Then
- 'data = data.Remove(x - 1, 1)
- 'End If
- ' Next
- '
- player_pos2 = InStr(player_pos1, data, "}")
- owner = Mid(data, player_pos1 + 9, player_pos2 - player_pos1 - 9)
- longitud_original = owner.Length + 9 + 2 ' player": mas }, o }} si acaba al final
- owner = owner & "," ' de esta manera todos los datos terminan en ,
- owner = owner.Replace(Chr(34), "") ' elimino las comillas, de este modo consigo clave:valor,
- ' Eliminando owner de data
- data = data.Remove(player_pos1 - 2, longitud_original + 1)
- data = data.Insert(data.Length - 1, ",") ' Antes de } necesito una ,
- ' Eliminando comillas
- data = data.Replace(Chr(34), "")
- ' Eliminando llaves
- 'data = data.Replace("{", "")
- 'data = data.Replace("}", "")
- ' Eliminando residuo - DEPURACION: Ya no es necesario
- 'If (InStr(data, "p,")) Then
- 'pos1 = (InStr(data, "p,"))
- 'data = data.Remove(pos1 - 1, 2)
- 'End If
- ' If (InStr(data, "a,")) Then
- 'pos1 = (InStr(data, "a,"))
- 'data = data.Remove(pos1 - 1, 2)
- 'End If
- ' Añadiendo una coma al fina, de este modo consigo clave:valor, - DEPURACION: No es necesario
- 'data = data & ","
- ' _mapCities_name
- pos1 = InStr(data, "name:")
- pos2 = InStr(pos1, data, ",")
- _MapCities_name = Mid(data, pos1 + 5, pos2 - pos1 - 5)
- ' _MapCities_id
- pos1 = InStr(data, "id:")
- pos2 = InStr(pos1, data, ",")
- _MapCities_id = Mid(data, pos1 + 3, pos2 - pos1 - 3)
- ' _MapCities_x
- pos1 = InStr(data, "x:")
- pos2 = InStr(pos1, data, ",")
- _MapCities_x = Mid(data, pos1 + 2, pos2 - pos1 - 2)
- ' _MapCities_y
- pos1 = InStr(data, "y:")
- pos2 = InStr(pos1, data, ",")
- _MapCities_y = Mid(data, pos1 + 2, pos2 - pos1 - 2)
- ' _MapCities_type
- pos1 = InStr(data, "type:")
- pos2 = InStr(pos1, data, ",")
- _MapCities_type = Mid(data, pos1 + 5, pos2 - pos1 - 5)
- ' _MapCities_protectedUntil
- pos1 = InStr(data, "protected_until:")
- pos2 = InStr(pos1, data, ",")
- _MapCities_protectedUntil = Mid(data, pos1 + 16, pos2 - pos1 - 16)
- ' _MapCities_protected
- pos1 = InStr(data, "protected:")
- pos2 = InStr(pos1, data, ",")
- _MapCities_protected = Mid(data, pos1 + 10, pos2 - pos1 - 10)
- ' _MapCities_useCommonBuildings
- pos1 = InStr(data, "use_common_buildings:")
- pos2 = InStr(pos1, data, ",")
- _MapCities_useCommonBuildings = Mid(data, pos1 + 21, pos2 - pos1 - 21)
- ' ****************************************************
- ' DEPURACION: Perfecto
- ' ****************************************************
- ' _owner_name
- pos1 = InStr(owner, "name:")
- pos2 = InStr(pos1, owner, ",")
- _owner_name = Mid(owner, pos1 + 5, pos2 - pos1 - 5)
- ' _owner_id
- pos1 = InStr(owner, "id:")
- pos2 = InStr(pos1, owner, ",")
- _owner_id = Mid(owner, pos1 + 3, pos2 - pos1 - 3)
- ' _owner_protected_until
- pos1 = InStr(owner, "protected_until:")
- pos2 = InStr(pos1, owner, ",")
- _owner_protected_until = Mid(owner, pos1 + 16, pos2 - pos1 - 16)
- ' _owner_respect_title
- pos1 = InStr(owner, "respect_title:")
- pos2 = InStr(pos1, owner, ",")
- _owner_respect_title = Mid(owner, pos1 + 14, pos2 - pos1 - 14)
- ' _owner_respect
- pos1 = InStr(owner, "respect:")
- pos2 = InStr(pos1, owner, ",")
- _owner_respect = Mid(owner, pos1 + 8, pos2 - pos1 - 8)
- ' _owner_level
- pos1 = InStr(owner, "level:")
- pos2 = InStr(pos1, owner, ",")
- _owner_level = Mid(owner, pos1 + 6, pos2 - pos1 - 6)
- ' _owner_createdAt
- pos1 = InStr(owner, "created_at:")
- pos2 = InStr(pos1, owner, ",")
- _owner_createdAt = Mid(owner, pos1 + 11, pos2 - pos1 - 11)
- ' _owner_lastOnline
- pos1 = InStr(owner, "last_online:")
- pos2 = InStr(pos1, owner, ",")
- _owner_lastOnline = Mid(owner, pos1 + 12, pos2 - pos1 - 12)
- ' _owner_family
- pos1 = InStr(owner, "family:")
- pos2 = InStr(pos1, owner, ",")
- _owner_family = Mid(owner, pos1 + 7, pos2 - pos1 - 7)
- ' _owner_plataform
- pos1 = InStr(owner, "platform:")
- pos2 = InStr(pos1, owner, ",")
- _owner_plataform = Mid(owner, pos1 + 9, pos2 - pos1 - 9)
- ' _owner_isDon
- pos1 = InStr(owner, "is_don:")
- pos2 = InStr(pos1, owner, ",")
- _owner_isDon = Mid(owner, pos1 + 7, pos2 - pos1 - 7)
- ' _owner_lastDonMessage
- pos1 = InStr(owner, "last_don_message_sent_at:")
- pos2 = InStr(pos1, owner, ",")
- _owner_lastDonMessage = Mid(owner, pos1 + 25, pos2 - pos1 - 25)
- ' Catch
- 'Dim d As New Debug
- ' d.newBug(_data)
- ' d.newBug(alliance)
- ' d.newBug(owner)
- 'd.newBug(getAll)
- 'Stop
- 'End Try
- End Sub
- Public Function getMapCitiesName()
- Return _MapCities_name
- End Function
- Public Function getMapId()
- Return _MapCities_id
- End Function
- Public Function getMapCitiesX()
- Return _MapCities_x
- End Function
- Public Function getMapCitiesY()
- Return _MapCities_y
- End Function
- Public Function getMapCitiesType()
- Return _MapCities_type
- End Function
- Public Function getMapCitiesProtectedUntil()
- Return _MapCities_protectedUntil
- End Function
- Public Function getMapCitiesProtected()
- Return _MapCities_protected
- End Function
- Public Function getMapCitiesUseCommonBuildings()
- Return _MapCities_useCommonBuildings
- End Function
- Public Function getOwnerName()
- Return _owner_name
- End Function
- Public Function getOwnerPlatform()
- Return _owner_plataform
- End Function
- Public Function getOwnerRespectTtile()
- Return _owner_respect_title
- End Function
- Public Function getOwnerLastDonMessageSentAt()
- Return _owner_lastDonMessage
- End Function
- Public Function getOwnerRespect()
- Return _owner_respect
- End Function
- Public Function getOwnerLevel()
- Return _owner_level
- End Function
- Public Function getOwnerIsDon()
- Return _owner_isDon
- End Function
- Public Function getOwnerCreatedAt()
- Return _owner_createdAt
- End Function
- Public Function getOwnerLastOnline()
- Return _owner_lastOnline
- End Function
- Public Function getOwnerId()
- Return _owner_id
- End Function
- Public Function getOwnerFamily()
- Return _owner_family
- End Function
- Public Function getOwnerProtectedUntil()
- Return _owner_protected_until
- End Function
- Public Function getAllianceName()
- Return _alliance_name
- End Function
- Public Function getAllianceId()
- Return _alliance_id
- End Function
- Public Function getAll()
- Dim a As String = _MapCities_id & " cityID" & vbCrLf &
- _MapCities_name & " cityName " & vbCrLf &
- _MapCities_protected & " cityProtected " & vbCrLf &
- _MapCities_protectedUntil & " cityProtectedUntil " & vbCrLf &
- _MapCities_type & " cityType " & vbCrLf &
- _MapCities_useCommonBuildings & " cityUseCommonBuildings " & vbCrLf &
- _MapCities_x & " cityX " & vbCrLf &
- _MapCities_y & " cityY " & vbCrLf &
- _owner_createdAt & " OwnerCreated " & vbCrLf &
- _owner_family & " OwnerFamily " & vbCrLf &
- _owner_id & " OwnerId " & vbCrLf &
- _owner_isDon & " OwnerIsDon " & vbCrLf &
- _owner_lastDonMessage & " OwnerLastDonMessage " & vbCrLf &
- _owner_lastOnline & " OwnerLastOnline " & vbCrLf &
- _owner_level & " OwnerLevel " & vbCrLf &
- _owner_name & " OwnerName " & vbCrLf &
- _owner_plataform & " OwnerPlatform " & vbCrLf &
- _owner_protected_until & " OwnerUntil " & vbCrLf &
- _owner_respect & " OwnerRespect " & vbCrLf &
- _owner_respect_title & " OwnerTtile " & vbCrLf &
- _alliance_id & " AllianceId " & vbCrLf &
- _alliance_name & " AllianceName"
- Return a
- End Function
- End Class
- Class Debug
- Public Sub newBug(ByVal data As String)
- My.Computer.FileSystem.WriteAllText("Debug.txt", data, True)
- MsgBox("Archivo creado en: " & My.Computer.FileSystem.CurrentDirectory)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement