Ejemplo n.º 1
0
        internal static PermanentPetRecord CreatePermanentPetRecord(NPCEntry entry, uint ownerId)
        {
            PermanentPetRecord defaultPetRecord = PetMgr.CreateDefaultPetRecord <PermanentPetRecord>(entry, ownerId);

            defaultPetRecord.PetNumber = (uint)PetMgr.PetNumberGenerator.Next();
            defaultPetRecord.IsDirty   = true;
            return(defaultPetRecord);
        }
Ejemplo n.º 2
0
 public static void ListStabledPets(Character chr, NPC stableMaster)
 {
     if (!PetMgr.CheckForStableMasterCheats(chr, stableMaster))
     {
         return;
     }
     PetHandler.SendStabledPetsList((IPacketReceiver)chr, (Unit)stableMaster, (byte)chr.StableSlotCount,
                                    chr.StabledPetRecords);
 }
Ejemplo n.º 3
0
        public static void DeStablePet(Character chr, NPC stableMaster, uint petNumber)
        {
            if (!PetMgr.CheckForStableMasterCheats(chr, stableMaster))
            {
                return;
            }
            PermanentPetRecord stabledPet = chr.GetStabledPet(petNumber);

            chr.DeStablePet(stabledPet);
            PetHandler.SendStableResult((IPacketReceiver)chr, StableResult.DeStableSuccess);
        }
Ejemplo n.º 4
0
 public static void BuyStableSlot(Character chr, NPC stableMaster)
 {
     if (!PetMgr.CheckForStableMasterCheats(chr, stableMaster))
     {
         return;
     }
     if (!chr.TryBuyStableSlot())
     {
         PetHandler.SendStableResult((IPacketReceiver)chr.Client, StableResult.NotEnoughMoney);
     }
     else
     {
         PetHandler.SendStableResult((IPacketReceiver)chr.Client, StableResult.BuySlotSuccess);
     }
 }
Ejemplo n.º 5
0
        public static void SwapStabledPet(Character chr, NPC stableMaster, uint petNumber)
        {
            if (!PetMgr.CheckForStableMasterCheats(chr, stableMaster))
            {
                return;
            }
            NPC activePet = chr.ActivePet;
            PermanentPetRecord stabledPet = chr.GetStabledPet(petNumber);

            if (activePet.Health == 0)
            {
                PetHandler.SendStableResult((IPacketReceiver)chr, StableResult.Fail);
            }
            else if (!chr.TrySwapStabledPet(stabledPet))
            {
                PetHandler.SendStableResult((IPacketReceiver)chr, StableResult.Fail);
            }
            else
            {
                PetHandler.SendStableResult((IPacketReceiver)chr, StableResult.DeStableSuccess);
            }
        }
Ejemplo n.º 6
0
        public static void StablePet(Character chr, NPC stableMaster)
        {
            if (!PetMgr.CheckForStableMasterCheats(chr, stableMaster))
            {
                return;
            }
            NPC activePet = chr.ActivePet;

            if (!chr.GodMode && activePet.Health == 0)
            {
                PetHandler.SendStableResult((IPacketReceiver)chr, StableResult.Fail);
            }
            if (chr.StabledPetRecords.Count < chr.StableSlotCount)
            {
                chr.StablePet();
                PetHandler.SendStableResult((IPacketReceiver)chr, StableResult.StableSuccess);
            }
            else
            {
                PetHandler.SendStableResult((IPacketReceiver)chr, StableResult.Fail);
            }
        }
Ejemplo n.º 7
0
        public static PetNameInvalidReason ValidatePetName(ref string petName)
        {
            if (petName.Length == 0)
            {
                return(PetNameInvalidReason.NoName);
            }
            if (petName.Length < PetMgr.MinPetNameLength)
            {
                return(PetNameInvalidReason.TooShort);
            }
            if (petName.Length > PetMgr.MaxPetNameLength)
            {
                return(PetNameInvalidReason.TooLong);
            }
            if (PetMgr.DoesNameViolate(petName))
            {
                return(PetNameInvalidReason.Profane);
            }
            int  num1 = 0;
            int  num2 = 0;
            int  num3 = 0;
            int  num4 = 0;
            int  num5 = 0;
            int  num6 = 0;
            char ch1  = '1';
            char ch2  = '0';

            for (int index = 0; index < petName.Length; ++index)
            {
                char c = petName[index];
                if (!char.IsLetter(c))
                {
                    switch (c)
                    {
                    case ' ':
                        ++num1;
                        break;

                    case '\'':
                        ++num2;
                        break;

                    default:
                        if (char.IsDigit(c))
                        {
                            ++num4;
                            break;
                        }

                        ++num5;
                        break;
                    }
                }
                else
                {
                    if ((int)c == (int)ch1 && (int)c == (int)ch2)
                    {
                        ++num6;
                    }
                    ch2 = ch1;
                    ch1 = c;
                }

                if (char.IsUpper(c))
                {
                    ++num3;
                }
            }

            if (num6 > 0)
            {
                return(PetNameInvalidReason.ThreeConsecutive);
            }
            if (num1 > 0)
            {
                return(PetNameInvalidReason.ConsecutiveSpaces);
            }
            if (num4 > 0 || num5 > 0 || num2 > 1)
            {
                return(PetNameInvalidReason.Invalid);
            }
            if (num2 == 1)
            {
                int num7 = petName.IndexOf("'");
                if (num7 == 0 || num7 == petName.Length - 1)
                {
                    return(PetNameInvalidReason.Invalid);
                }
            }

            if (RealmServerConfiguration.CapitalizeCharacterNames)
            {
                petName = petName.ToCapitalizedString();
            }
            return(PetNameInvalidReason.Ok);
        }
Ejemplo n.º 8
0
 public static void Init()
 {
     PetMgr.InitMisc();
 }