Ejemplo n.º 1
0
        public static void CreateNewParty(Client leader)
        {
            PacketHitList hitlist = null;

            PacketHitList.MethodStart(ref hitlist);
            List <string> partyIDs = new List <string>();

            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players))
            {
                partyIDs = LoadPartyIDList(dbConnection.Database);
            }

            if (leader.Player.PartyID == null)
            {
                string partyID = null;
                rwLock.EnterWriteLock();
                try
                {
                    while (true)
                    {
                        string tempID = Security.PasswordGen.Generate(10, 15);
                        if (partyIDs.Contains(tempID) == false)
                        {
                            partyID = tempID;
                            break;
                        }
                    }
                    Party party = new Party(partyID, leader);
                    leader.Player.PartyID = partyID;
                    parties.Add(partyID, party);
                }
                finally
                {
                    rwLock.ExitWriteLock();
                }
                leader.Player.AddExpKitModule(new AvailableExpKitModule(Enums.ExpKitModules.Party, true));
                PacketBuilder.AppendPartyMemberDataFor(leader, hitlist, 0);
                hitlist.AddPacket(leader, PacketBuilder.CreateChatMsg("You have created a new party!", Text.BrightGreen));
            }
            else
            {
                hitlist.AddPacket(leader, PacketBuilder.CreateChatMsg("You are already in a party!", Text.BrightRed));
            }

            PacketHitList.MethodEnded(ref hitlist);
        }