Advertisement
Luciano_fuentes

Sistema de Parties v0.2

May 1st, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. '**************************************************
  4. ''      FENIX XIII.
  5. ''      AUTOR; G Toyz.
  6. ''      FECHA; 04/17 - 05/17
  7. ''      SISTEMA; Party v0.2
  8. ''      ACLARACIÓN; Party. Party. MAB, cof cof se la come cof cof, no es grupo (?
  9. '**************************************************
  10.  
  11. Public Parties As Collection
  12.  
  13. Public Sub AñadirParty(ByVal UsuarioIndex As Integer)
  14.    
  15.     If .Party.PartyIndex > 0 Then
  16.         Call WriteConsoleMsg(UsuarioIndex, "[PARTY]»» Primero debes " & IIf(UserList(UsuarioIndex).Party.estatus = Lider, "disolver", "abandonar") & " la party para poder crear una.", FontTypeNames.FONTTYPE_CONSEJO)
  17.         Exit Sub
  18.     End If
  19.    
  20.     Dim nuevaParty As New clsParty
  21.    
  22.     Parties.Add nuevaParty
  23.     UserList(UsuarioIndex).Party.estatus = Lider
  24.     EnviarSolicitudIngreso UsuarioIndex, UsuarioIndex
  25.     AñadirMiembro 1, Parties.Count 'TODO: Default, xD. Después lo cambio, igual no genera error pero rico hardcode.
  26.    
  27.     Set nuevaParty = Nothing
  28.    
  29.     Call WriteConsoleMsg(UsuarioIndex, "[PARTY]»» Has creado una party.", FontTypeNames.FONTTYPE_CONSEJO)
  30.     Call WriteActualizarDatosParty(UsuarioIndex)
  31. End Sub
  32.  
  33. Public Sub EnviarSolicitudIngreso(ByVal UsuarioIndex As Integer, ByVal LiderIndex As Integer)
  34.    
  35.     If LiderIndex = 0 Then
  36.         Call WriteConsoleMsg(UsuarioIndex, "[PARTY]»» Clickea al líder de la party.", FontTypeNames.FONTTYPE_CONSEJO)
  37.         Exit Sub
  38.     End If
  39.  
  40.     If UserList(LiderIndex).Party.PartyIndex > 0 Then
  41.         Call WriteConsoleMsg(UsuarioIndex, "[PARTY]»» Primero debes " & IIf(UserList(LiderIndex).Party.estatus = Lider, "disolver", "abandonar") & " la party para poder entrar a una.", FontTypeNames.FONTTYPE_CONSEJO)
  42.         Exit Sub
  43.     End If
  44.  
  45.     If Not UserList(LiderIndex).Party.estatus = Lider Then
  46.         Call WriteConsoleMsg(UsuarioIndex, "[PARTY]»» El usuario no es líder de ninguna party.", FontTypeNames.FONTTYPE_CONSEJO)
  47.         Exit Sub
  48.     End If
  49.    
  50.     Parties.Item(UserList(UsuarioIndex).Party.PartyIndex).Miembros.Add UsuarioIndex
  51.    
  52.     Call WriteConsoleMsg(LiderIndex, "[PARTY]»» Nueva solicitud de ingreso", FontTypeNames.FONTTYPE_CONSEJO)
  53.     Call WriteActualizarDatosParty(LiderIndex)
  54.  
  55. End Sub
  56.  
  57. Public Sub AñadirMiembro(ByVal SolicitudIndex As Integer, ByVal PartyIndex As Integer)
  58.    
  59.     Dim UsuarioIndex As Integer
  60.     Dim nuevoMiembro As New clsMiembrosParty
  61.    
  62.     UsuarioIndex = Parties.Item(PartyIndex).Solicitudes.Item(SolicitudIndex)
  63.    
  64.     With UserList(UsuarioIndex)
  65.         If Not .Party.estatus = Lider Then Exit Sub
  66.    
  67.         If .Party.PartyIndex > 0 Then
  68.             Call WriteConsoleMsg(UsuarioIndex, "[PARTY] »» Primero debes " & IIf(.Party.estatus = Lider, "disolver", "abandonar") & " la party para poder entrar a una.", FontTypeNames.FONTTYPE_CONSEJO)
  69.             Exit Sub
  70.         End If
  71.        
  72.         Call SendData(SendTarget.ToPartyArea, PartyIndex, PrepareMessageConsoleMsg("[PARTY]»» " & .Name & " ha ingresado a la party.", FontTypeNames.FONTTYPE_CONSEJO))
  73.     End With
  74.    
  75.     With nuevoMiembro
  76.         .Experiencia = 0
  77.         .UsuarioIndex = UsuarioIndex
  78.         Call ResetearPorcentajes(UsuarioIndex)
  79.     End With
  80.    
  81.     Parties.Item(PartyIndex).Miembros.Add nuevoMiembro
  82.     Parties.Item(PartyIndex).Solicitudes.Remove SolicitudIndex
  83.    
  84.     With UserList(UsuarioIndex).Party
  85.         .MiembroIndex = Parties.Item(PartyIndex).Miembros.Count
  86.         .PartyIndex = PartyIndex
  87.     End With
  88.    
  89.     Set nuevoMiembro = Nothing
  90.    
  91.     Call WriteActualizarDatosParty(UsuarioIndex)
  92. End Sub
  93.  
  94. Public Sub QuitarMiembro(ByVal PartyIndex As Integer, ByVal MiembroIndex As Integer)
  95.  
  96.     Dim UsuarioIndex As Integer
  97.     UsuarioIndex = Parties.Item(PartyIndex).Miembros.Item(MiembroIndex).UsuarioIndex
  98.  
  99.     With UserList(UsuarioIndex)
  100.         Call SendData(SendTarget.ToPartyArea, PartyIndex, PrepareMessageConsoleMsg _
  101.                 ("[PARTY]»» " & .Name & " abandona la party.", FontTypeNames.FONTTYPE_CONSEJO))
  102.    
  103.         With .Party
  104.             .estatus = SinParty
  105.             .MiembroIndex = 0
  106.             .PartyIndex = 0
  107.         End With
  108.     End With
  109.    
  110.     Call WriteConsoleMsg(UsuarioIndex, "[PARTY]»» Abandonas la party.", FontTypeNames.FONTTYPE_CONSEJO)
  111.  
  112.     With Parties.Item(PartyIndex)
  113.         DarExperiencia UsuarioIndex, .Miembros.Item(MiembroIndex).Experiencia
  114.         .Miembros.Remove MiembroIndex
  115.         ResetearPorcentajes PartyIndex
  116.     End With
  117.    
  118. End Sub
  119.  
  120. Public Sub RepartirExperiencia(ByVal PartyIndex As Byte, ByVal ExperienciaTotal As Long)
  121.  
  122.     Dim LoopC As Long
  123.     Dim Experiencia As Long
  124.     Dim cantidadMiembros As Byte
  125.    
  126.     With Parties.Item(PartyIndex)
  127.         cantidadMiembros = .Miembros.Count
  128.         For LoopC = 1 To cantidadMiembros
  129.             With .Miembros.Item(LoopC)
  130.                 Experiencia = CLng(Round(ExperienciaTotal * .Porcentaje / 100))
  131.                 .Experiencia = .Experiencia + Experiencia
  132.                 Call WriteActualizarDatosParty(.UsuarioIndex)
  133.             End With
  134.         Next LoopC
  135.     End With
  136. End Sub
  137.  
  138. Private Sub DarExperiencia(ByVal UsuarioIndex As Integer, ByVal Experiencia As Long)
  139.  
  140.     With UserList(UsuarioIndex)
  141.         .Stats.Exp = .Stats.Exp + Experiencia
  142.         If .Stats.Exp > MAXEXP Then _
  143.             .Stats.Exp = MAXEXP
  144.         Call WriteConsoleMsg(UsuarioIndex, "[PARTY]»» Has ganado " & Experiencia & " puntos de experiencia durante la party.", FontTypeNames.FONTTYPE_CONSEJO)
  145.         Call CheckUserLevel(UsuarioIndex)
  146.     End With
  147. End Sub
  148.  
  149. Private Sub ResetearPorcentajes(ByVal PartyIndex As Byte)
  150.    
  151.     Dim Porcentaje As Byte
  152.     Dim cantidadMiembros As Byte
  153.     Dim LoopC As Long
  154.    
  155.     With Parties.items(PartyIndex)
  156.         cantidadMiembros = .Miembros.Count
  157.         Porcentaje = CByte(Round(100 / cantidadMiembros))
  158.        
  159.         For LoopC = 1 To cantidadMiembros
  160.             .Miembros.Item(LoopC).Porcentaje = Porcentaje
  161.         Next LoopC
  162.         Call SendData(SendTarget.ToPartyArea, PartyIndex, PrepareMessageConsoleMsg _
  163.                 ("[PARTY]»» Los porcentajes han sido reseteados.", FontTypeNames.FONTTYPE_CONSEJO))
  164.     End With
  165.    
  166. End Sub
  167.  
  168. Public Sub EnviarToParty(ByRef dataTosend As String, ByVal sndIndex As Byte)
  169.  
  170.     Dim LoopC  As Long
  171.      
  172.     For LoopC = 1 To Parties.Item(sndIndex).Miembros.Count
  173.         Call EnviarDatosASlot(Parties.Item(sndIndex).Miembros.Item(LoopC).UsuarioIndex, dataTosend)
  174.     Next LoopC
  175.  
  176. End Sub
  177.  
  178. Public Sub DisolverParty(ByVal UsuarioIndex As Byte)
  179.  
  180.     Dim LoopC As Long
  181.     Dim PartyIndex As Byte
  182.    
  183.     If Not UserList(UsuarioIndex).Party.estatus = Lider Then Exit Sub
  184.    
  185.     PartyIndex = UserList(UsuarioIndex).Party.PartyIndex
  186.    
  187.     With Parties.Item(PartyIndex)
  188.         Call SendData(SendTarget.ToPartyArea, PartyIndex, PrepareMessageConsoleMsg _
  189.             ("[PARTY]»» El líder a disuelto la party", FontTypeNames.FONTTYPE_CONSEJO))
  190.            
  191.         For LoopC = 1 To .Miembros.Count
  192.             Call QuitarMiembro(PartyIndex, LoopC)
  193.         Next LoopC
  194.     End With
  195. End Sub
  196.  
  197. Public Sub SetearPorcentajes(ByVal PartyIndex As Byte, ByRef Miembros() As Byte, ByRef Porcentajes() As Byte)
  198.  
  199.     Dim LoopC As Long
  200.     Dim PorcentajeTotal As Byte
  201.    
  202.     With Parties.Item(PartyIndex)
  203.        
  204.         For LoopC = 1 To .Miembros.Count
  205.             PorcentajeTotal = PorcentajeTotal + Porcentajes(LoopC)
  206.         Next LoopC
  207.        
  208.         If PorcentajeTotal <> 100 Then Exit Sub
  209.        
  210.         For LoopC = 1 To .Miembros.Count
  211.             .Miembros.Item(Miembros(LoopC)).Porcentaje = Porcentajes(LoopC)
  212.         Next LoopC
  213.     End With
  214. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement