Advertisement
Luciano_fuentes

Parties

Apr 26th, 2017
213
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
  7. ''      SISTEMA; Party.
  8. ''      ACLARACIÓN; Party. Party. MAB cof cof se la come cof cof no es grupo.
  9. '**************************************************
  10.  
  11. Public Const MAX_PARTICIPANTES_PARTY As Byte = 10          '    «   Cantidad máxima de participantes en una party.
  12. Private Const MAX_PARTIES As Byte = 50                                      '    «   Cantidad máxima de parties.
  13.  
  14. Private Type tUsuarios              '   «   Información del usuario.
  15.    UsuarioIndex As Integer        '   «   ID (userindex) del usuario (userlist()).
  16.    Porcentaje As Byte                '   «   Porcentaje de la experiencia recaudada que le pertenece.
  17.    Experiencia As Long             '   «   Experiencia que lleva acumulada.
  18. End Type
  19.  
  20. Private Type tGeneral                                                                                       '   «   Datos generales de las parties.
  21.    Participantes(1 To MAX_PARTICIPANTES_PARTY) As tUsuarios      '   «   Participantes de la party.
  22.    Solicitudes(1 To MAX_PARTICIPANTES_PARTY) As Integer               '   «   Solicitudes de ingreso a la party.
  23.    CantidadParticipantes As Byte                                                                   '   «   Cantidad de participantes que tiene la party.
  24.    Lider As Byte                                                                                                 '   «    ID (de Participantes()) del lider de la party.
  25. End Type
  26.  
  27. Public Parties(1 To MAX_PARTIES) As tGeneral    '   «   Todas las parties.
  28.  
  29. Public Sub AñadirParty(ByVal UsuarioIndex As Integer)   '   «   Método para crear una nueva party. _
  30.                                                                                                            (Añadir hace referencia por el array Parties())
  31.  
  32.     Dim PartyIndex As Byte
  33.    
  34.     PartyIndex = DamePartyIndex()
  35.    
  36.     With UserList(UsuarioIndex)
  37.         '   «   ¿Ya está en una party el usuario?
  38.        If .Party.PartyIndex > 0 Then
  39.             Call WriteConsoleMsg(UsuarioIndex, "Primero debes " & IIf(.Party.Lider, "disolver", "abandonar") & " la party para poder fundar una.", FontTypeNames.FONTTYPE_CONSEJO)
  40.             Exit Sub
  41.         End If
  42.        
  43.         .Party.PartyIndex = PartyIndex
  44.         .Party.ParticipanteIndex = 1
  45.     End With
  46.    
  47.     With Parties(PartyIndex)
  48.         .CantidadParticipantes = 1
  49.         .Lider = 1      '       ««  El que la crea es el lider.
  50.        .Participantes(.Lider).UsuarioIndex = UsuarioIndex
  51.         .Participantes(.Lider).Porcentaje = 100     '      «  Default
  52.    End With
  53.    
  54.     Call WriteConsoleMsg(UsuarioIndex, "Has fundado una party.", FontTypeNames.FONTTYPE_CONSEJO)
  55. End Sub
  56.  
  57.  
  58. Public Sub EnviarSolicitudIngreso(ByVal UsuarioIndex As Integer, ByVal LiderIndex As Integer) '   «  Método para enviar una _
  59.                                                                                                                                                                             Solicitud de ingreso a la party.
  60.    
  61.     Dim SolicitudIndex As Byte
  62.    
  63.     If LiderIndex = 0 Then
  64.         Call WriteConsoleMsg(UsuarioIndex, "Clickea al lider de la party.", FontTypeNames.FONTTYPE_CONSEJO)
  65.         Exit Sub
  66.     End If
  67.    
  68.     If Not UserList(LiderIndex).Party.Lider Then
  69.         Call WriteConsoleMsg(UsuarioIndex, "El usuario no es lider de ninguna party.", FontTypeNames.FONTTYPE_CONSEJO)
  70.         Exit Sub
  71.     End If
  72.    
  73.     SolicitudIndex = DameSolicitudIndex(UserList(LiderIndex).Party.PartyIndex)
  74.    
  75.     If SolicitudIndex = 0 Then
  76.         Call WriteConsoleMsg(UsuarioIndex, "La party ya tiene muchas solicitudes de ingreso, intente más tarde", FontTypeNames.FONTTYPE_CONSEJO)
  77.         Exit Sub
  78.     End If
  79.    
  80.     Parties(UserList(LiderIndex).Party.PartyIndex).Solicitudes(SolicitudIndex) = UsuarioIndex
  81.    
  82.     Call WriteActualizarDatosParty(LiderIndex)
  83. End Sub
  84.  
  85. Public Sub AñadirParticipante(ByVal SolicitudIndex As Byte, ByVal PartyIndex As Byte)  '   «   Método para añadir un participante _
  86.                                                                                                                                                                  a la party.
  87.    
  88.     Dim ParticipanteIndex As Byte
  89.     Dim UsuarioIndex As Integer
  90.     UsuarioIndex = Parties(PartyIndex).Solicitudes(SolicitudIndex)
  91.     ParticipanteIndex = DameParticipanteIndex(PartyIndex)
  92.    
  93.     With UserList(UsuarioIndex)
  94.         If .Party.PartyIndex > 0 Then
  95.             Call WriteConsoleMsg(UsuarioIndex, "Primero debes " & IIf(.Party.Lider, "disolver", "abandonar") & " la party para poder entrar a una.", FontTypeNames.FONTTYPE_CONSEJO)
  96.             Exit Sub
  97.         End If
  98.        
  99.         .Party.PartyIndex = PartyIndex
  100.         .Party.ParticipanteIndex = ParticipanteIndex
  101.        
  102.         Call SendData(SendTarget.ToPartyArea, PartyIndex, PrepareMessageConsoleMsg(.Name & " ha ingresado a la party.", FontTypeNames.FONTTYPE_CONSEJO))
  103.     End With
  104.    
  105.     Parties(PartyIndex).CantidadParticipantes = Parties(PartyIndex).CantidadParticipantes + 1
  106.     With Parties(PartyIndex).Participantes(PartyIndex)
  107.         .Experiencia = 0
  108.         .UsuarioIndex = UsuarioIndex
  109.         ResetearPorcentajes PartyIndex
  110.     End With
  111.    
  112.     Parties(PartyIndex).Solicitudes(SolicitudIndex) = 0
  113.     Call WriteActualizarDatosParty(UsuarioIndex)
  114. End Sub
  115.  
  116. Public Sub QuitarParticipante(ByVal UsuarioIndex As Integer)    '   «   Método para quitar a un participante de la party.
  117.    Call SendData(SendTarget.ToPartyArea, UserList(UsuarioIndex).Party.PartyIndex, PrepareMessageConsoleMsg(UserList(UsuarioIndex).Name & " abandona la party.", FontTypeNames.FONTTYPE_CONSEJO))
  118.     Call WriteConsoleMsg(UsuarioIndex, "Abandonas la party.", FontTypeNames.FONTTYPE_CONSEJO)
  119.     With Parties(UserList(UsuarioIndex).Party.PartyIndex)
  120.         DarExperiencia UsuarioIndex, .Participantes(UserList(UsuarioIndex).Party.ParticipanteIndex).Experiencia
  121.         .Participantes(UserList(UsuarioIndex).Party.ParticipanteIndex).Experiencia = 0
  122.         .Participantes(UserList(UsuarioIndex).Party.ParticipanteIndex).Porcentaje = 0
  123.         .Participantes(UserList(UsuarioIndex).Party.ParticipanteIndex).UsuarioIndex = 0
  124.         .CantidadParticipantes = .CantidadParticipantes - 1
  125.         ResetearPorcentajes UserList(UsuarioIndex).Party.PartyIndex
  126.     End With
  127. End Sub
  128.  
  129. Public Sub RepartirExperiencia(ByVal PartyIndex As Byte, ByVal Experiencia As Long)  '   «   Método para repartir la experiencia _
  130.                                                                                                                                                                  recaudada en el momento.
  131.  
  132.     Dim LoopC As Long
  133.    
  134.     With Parties(PartyIndex)
  135.         For LoopC = 1 To MAX_PARTICIPANTES_PARTY
  136.             If .Participantes(LoopC).UsuarioIndex > 0 Then
  137.                 Experiencia = CLng(Round(Experiencia * .Participantes(LoopC).Porcentaje / 100))
  138.                 .Participantes(LoopC).Experiencia = Experiencia
  139.             End If
  140.         Next LoopC
  141.     End With
  142. End Sub
  143.  
  144. Private Sub DarExperiencia(ByVal UsuarioIndex As Integer, ByVal Experiencia As Long) '  « Método para entregar la experiencia _
  145.                                                                                                                                                                recaudada hasta el momento a un usuario.
  146.    With UserList(UsuarioIndex)
  147.         .Stats.Exp = .Stats.Exp + Experiencia
  148.         If .Stats.Exp > MAXEXP Then _
  149.             .Stats.Exp = MAXEXP
  150.         Call WriteConsoleMsg(UsuarioIndex, "Has ganado " & Experiencia & " puntos de experiencia durante la party.", FontTypeNames.FONTTYPE_CONSEJO)
  151.         Call CheckUserLevel(UsuarioIndex)
  152.     End With
  153. End Sub
  154.  
  155. Private Sub ResetearPorcentajes(ByVal PartyIndex As Byte)   '   «   Método para restablecer los porcentajes a default.
  156.    
  157.     Dim Porcentaje As Byte
  158.     Dim LoopC As Long
  159.    
  160.     With Parties(PartyIndex)
  161.         Porcentaje = CByte(Round(100 / .CantidadParticipantes))
  162.        
  163.         For LoopC = 1 To .CantidadParticipantes
  164.             .Participantes(LoopC).Porcentaje = Porcentaje
  165.         Next LoopC
  166.         Call SendData(SendTarget.ToPartyArea, PartyIndex, PrepareMessageConsoleMsg("Los porcentajes han sido reseteados.", FontTypeNames.FONTTYPE_CONSEJO))
  167.     End With
  168.    
  169. End Sub
  170.  
  171. Public Sub EnviarToParty(ByRef dataTosend As String, ByVal sndIndex As Byte)    '   «   Método readaptado del anterior sistema. _
  172.                                                                                                                                                         Este cumple enviar data a todos los _
  173.                                                                                                                                                         participantes de la party.
  174.  
  175.     Dim LoopC  As Long
  176.      
  177.     For LoopC = 1 To MAX_PARTICIPANTES_PARTY
  178.         With Parties(sndIndex)
  179.             If .Participantes(LoopC).UsuarioIndex > 0 Then
  180.                 Call EnviarDatosASlot(.Participantes(LoopC).UsuarioIndex, dataTosend)
  181.             End If
  182.         End With
  183.     Next LoopC
  184.  
  185. End Sub
  186.  
  187. Public Sub DisolverParty(ByVal UsuarioIndex As Byte)    '   «   Método para disolver la party.
  188.    
  189.     Dim LoopC As Long
  190.    
  191.     With Parties(UserList(UsuarioIndex).Party.PartyIndex)
  192.    
  193.         If Not .Lider = UserList(UsuarioIndex).Party.ParticipanteIndex Then Exit Sub
  194.        
  195.         For LoopC = 1 To MAX_PARTICIPANTES_PARTY
  196.             If .Participantes(LoopC).UsuarioIndex > 0 Then
  197.                 Call QuitarParticipante(.Participantes(LoopC).UsuarioIndex)
  198.             End If
  199.         Next LoopC
  200.  
  201.         .Lider = 0
  202.         .CantidadParticipantes = 0
  203.         Erase .Participantes()
  204.         Erase .Solicitudes()
  205.     End With
  206. End Sub
  207.  
  208. Private Function DameSolicitudIndex(ByVal PartyIndex As Byte) As Byte   '   «   Método para devolver el ID libre del array Solicitudes().
  209.  
  210.     Dim LoopC As Long
  211.    
  212.     With Parties(PartyIndex)
  213.         For LoopC = 1 To MAX_PARTICIPANTES_PARTY
  214.             If .Solicitudes(LoopC) = 0 Then
  215.                 DameSolicitudIndex = LoopC
  216.                 Exit Function
  217.             End If
  218.         Next LoopC
  219.     End With
  220.    
  221. End Function
  222.  
  223. Private Function DameParticipanteIndex(ByVal PartyIndex As Byte) As Byte    '   «   Método para devolver el ID libre del array Participantes().
  224.    
  225.     Dim LoopC As Long
  226.    
  227.     With Parties(PartyIndex)
  228.         For LoopC = 1 To MAX_PARTICIPANTES_PARTY
  229.             If .Participantes(LoopC).UsuarioIndex = 0 Then
  230.                 DameParticipanteIndex = LoopC
  231.                 Exit Function
  232.             End If
  233.         Next LoopC
  234.     End With
  235.    
  236. End Function
  237.  
  238. Private Function DamePartyIndex() As Byte   '   « Método para devolver el ID libre del array Parties().
  239.    
  240.     Dim LoopC As Long
  241.    
  242.     For LoopC = 1 To MAX_PARTIES
  243.         '   Si la party tiene líder. Todas las partys tienen, obligatoriamente, líder. En caso de que no tenga líder es porque esa party no existe.
  244.        If Parties(LoopC).Lider = 1 Then
  245.             DamePartyIndex = LoopC
  246.             Exit Function
  247.         End If
  248.     Next LoopC
  249.    
  250. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement