/// <summary>Sends an arena team query response to the client.</summary>
 /// <param name="client">the client to send to</param>
 /// <param name="team">arena team to be sent</param>
 public static void SendArenaTeamQueryResponse(IPacketReceiver client, ArenaTeam team)
 {
     using (RealmPacketOut queryResponsePacket = ArenaTeamHandler.CreateArenaTeamQueryResponsePacket(team))
         client.Send(queryResponsePacket, false);
     using (RealmPacketOut statsResponsePacket = ArenaTeamHandler.CreateArenaTeamStatsResponsePacket(team))
         client.Send(statsResponsePacket, false);
 }
        public static void HandleArenaTeamRoster(IRealmClient client, RealmPacketIn packet)
        {
            ArenaTeam arenaTeam = ArenaMgr.GetArenaTeam(packet.ReadUInt32());

            if (arenaTeam == null)
            {
                return;
            }
            ArenaTeamHandler.SendArenaTeamRosterResponse((IPacketReceiver)client, arenaTeam);
        }
Exemple #3
0
        public static void HandlePetitionOffer(IRealmClient client, RealmPacketIn packet)
        {
            var unk        = packet.ReadUInt32();
            var petitionId = packet.ReadEntityId();
            var playerId   = packet.ReadEntityId();

            var player   = World.GetCharacter(playerId.Low);
            var petition = PetitionRecord.LoadRecordByItemId(petitionId.Low);

            var namePlayer = player.Name;

            if (player.Faction != client.ActiveCharacter.Faction)
            {
                if (petition.Type == PetitionType.Guild)
                {
                    GuildHandler.SendResult(client, GuildCommandId.CREATE, client.ActiveCharacter.Name, GuildResult.NOT_ALLIED);
                }
                else
                {
                    ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.INVITE, ArenaTeamResult.NOT_ALLIED);
                }
                return;
            }

            if (petition.Type == PetitionType.Guild)
            {
                if (player.IsInGuild)
                {
                    GuildHandler.SendResult(client, GuildCommandId.INVITE, namePlayer, GuildResult.ALREADY_IN_GUILD_S);
                    return;
                }
            }
            else
            {
                if (player.ArenaTeamMember[(uint)ArenaMgr.GetSlotByType((uint)petition.Type)] != null)
                {
                    ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.CREATE, string.Empty, namePlayer, ArenaTeamResult.ALREADY_IN_ARENA_TEAM_S);
                    return;
                }
                else if (player.Level < 80)
                {
                    ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.CREATE, string.Empty, namePlayer, ArenaTeamResult.TARGET_TOO_LOW);
                    return;
                }
            }

            SendPetitionSignatures(player.Client, client.ActiveCharacter.Inventory.GetItem(petitionId) as PetitionCharter);
        }
Exemple #4
0
        public static void HandlePetitionRename(IRealmClient client, RealmPacketIn packet)
        {
            var petitionGuid = packet.ReadEntityId();
            var newName      = packet.ReadCString().Trim();

            var charter = client.ActiveCharacter.Inventory.GetItem(petitionGuid) as PetitionCharter;
            var chr     = client.ActiveCharacter;

            if (charter.Petition.Type == PetitionType.Guild)
            {
                if (!GuildMgr.IsValidGuildName(newName))
                {
                    GuildHandler.SendResult(chr, GuildCommandId.CREATE, newName, GuildResult.NAME_INVALID);
                    return;
                }
                else if (GuildMgr.DoesGuildExist(newName))
                {
                    GuildHandler.SendResult(chr, GuildCommandId.CREATE, newName, GuildResult.NAME_EXISTS);
                    return;
                }
            }
            else
            {
                if (!ArenaMgr.IsValidArenaTeamName(newName))
                {
                    ArenaTeamHandler.SendResult(chr, ArenaTeamCommandId.CREATE, newName, string.Empty, ArenaTeamResult.NAME_INVALID);
                    return;
                }
                else if (ArenaMgr.DoesArenaTeamExist(newName))
                {
                    ArenaTeamHandler.SendResult(chr, ArenaTeamCommandId.CREATE, newName, string.Empty, ArenaTeamResult.NAME_EXISTS);
                    return;
                }
            }

            charter.Petition.Name = newName;
            charter.Petition.Update();

            SendPetitionRename(client, charter);
        }
Exemple #5
0
        public static void HandlePetitionTurnIn(IRealmClient client, RealmPacketIn packet)
        {
            var petitionGuid = packet.ReadEntityId();
            var petition     = client.ActiveCharacter.Inventory.GetItem(petitionGuid) as PetitionCharter;

            if (petition == null)
            {
                return;
            }

            var name = petition.Petition.Name;
            var type = petition.Petition.Type;

            if (petition.Petition.SignedIds.Count < ((uint)type - 1))
            {
                SendPetitionTurnInResults(client, PetitionTurns.NEED_MORE_SIGNATURES);
                return;
            }
            if (type == PetitionType.Guild && client.ActiveCharacter.IsInGuild)
            {
                SendPetitionTurnInResults(client, PetitionTurns.ALREADY_IN_GUILD);
                return;
            }
            else if (client.ActiveCharacter.ArenaTeamMember[(uint)ArenaMgr.GetSlotByType((uint)type)] != null)
            {
                ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.CREATE, name, string.Empty, ArenaTeamResult.ALREADY_IN_ARENA_TEAM);
                return;
            }
            else if (type == PetitionType.Guild && GuildMgr.DoesGuildExist(name))
            {
                GuildHandler.SendResult(client, GuildCommandId.CREATE, name, GuildResult.NAME_EXISTS);
                return;
            }
            else if (ArenaMgr.DoesArenaTeamExist(name))
            {
                ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.CREATE, name, string.Empty, ArenaTeamResult.NAME_EXISTS);
                return;
            }
            else
            {
                petition.Destroy();
                if (type == PetitionType.Guild)
                {
                    var guild = new Guild(client.ActiveCharacter.Record, name);
                    foreach (var chr in petition.Petition.SignedIds)
                    {
                        if (chr == 0)
                        {
                            continue;
                        }
                        else
                        {
                            var character = World.GetCharacter(chr);
                            guild.AddMember(character);
                        }
                    }
                }
                else
                {
                    var team = new ArenaTeam(client.ActiveCharacter.Record, name, (uint)type);
                    foreach (var chr in petition.Petition.SignedIds)
                    {
                        if (chr == 0)
                        {
                            continue;
                        }
                        else
                        {
                            var character = World.GetCharacter(chr);
                            team.AddMember(character);
                        }
                    }
                }

                SendPetitionTurnInResults(client, PetitionTurns.OK);
            }
        }
Exemple #6
0
        public static void HandlePetitionBuy(IRealmClient client, RealmPacketIn packet)
        {
            var chr = client.ActiveCharacter;

            var petitionerId = packet.ReadEntityId();
            var petitioner   = chr.Map.GetObject(petitionerId) as NPC;

            //var petitionId = packet.ReadInt32();
            //var petitionCreator = packet.ReadEntityId();
            //packet.SkipBytes(4 + 8);
            packet.Position += 4 + 8;
            var name = packet.ReadCString().Trim();

            //var bodytext = packet.ReadCString().Trim();
            //var minSignatures = packet.ReadInt32();
            //var maxSignatures = packet.ReadInt32();
            //var deadline = packet.ReadInt32();
            //var issueDate = packet.ReadInt32();
            //var allowedGuildId = packet.ReadInt32();
            //var allowedClassMask = packet.ReadInt32();
            //var allowedRaceMask = packet.ReadInt32();
            //var allowedGender = packet.ReadInt32(); // wow is sexist... :(
            //var allowedMinLevel = packet.ReadInt32();
            //var allowedMaxLevel = packet.ReadInt32();
            //packet.SkipBytes(4 * 10);
            //packet.Position += (7 * 8) + 2 + 1 + 8;
            packet.Position += 4 * 10;
            var choice = packet.ReadInt32();

            //var petitionType = packet.ReadInt32();
            //packet.SkipBytes(4);
            packet.Position += 4;

            if (petitioner != null && petitioner.IsPetitioner && petitioner.CheckVendorInteraction(chr))
            {
                ItemId       itemId = 0;
                uint         cost   = 0;
                PetitionType type   = PetitionType.None;

                if (petitioner.IsGuildPetitioner)
                {
                    if (chr.IsInGuild)
                    {
                        GuildHandler.SendResult(chr, GuildCommandId.CREATE, name, GuildResult.ALREADY_IN_GUILD);
                        return;
                    }
                    if (!GuildMgr.IsValidGuildName(name))
                    {
                        GuildHandler.SendResult(chr, GuildCommandId.CREATE, name, GuildResult.NAME_INVALID);
                        return;
                    }
                    else if (GuildMgr.DoesGuildExist(name))
                    {
                        GuildHandler.SendResult(chr, GuildCommandId.CREATE, name, GuildResult.NAME_EXISTS);
                        return;
                    }
                    itemId = PetitionerEntry.GuildPetitionEntry.ItemId;
                    cost   = GuildMgr.GuildCharterCost;
                    type   = PetitionType.Guild;
                }
                else if (petitioner.IsArenaPetitioner)
                {
                    switch (choice)
                    {
                    case 1:
                        itemId = PetitionerEntry.ArenaPetition2v2Entry.ItemId;
                        cost   = PetitionerEntry.ArenaPetition2v2Entry.Cost;
                        type   = PetitionType.Arena2vs2;
                        break;

                    case 2:
                        itemId = PetitionerEntry.ArenaPetition3v3Entry.ItemId;
                        cost   = PetitionerEntry.ArenaPetition3v3Entry.Cost;
                        type   = PetitionType.Arena3vs3;
                        break;

                    case 3:
                        itemId = PetitionerEntry.ArenaPetition5v5Entry.ItemId;
                        cost   = PetitionerEntry.ArenaPetition5v5Entry.Cost;
                        type   = PetitionType.Arena5vs5;
                        break;

                    default:
                        return;
                    }
                    if (!ArenaMgr.IsValidArenaTeamName(name))
                    {
                        ArenaTeamHandler.SendResult(chr, ArenaTeamCommandId.CREATE, name, string.Empty, ArenaTeamResult.NAME_INVALID);
                        return;
                    }
                    else if (ArenaMgr.DoesArenaTeamExist(name))
                    {
                        ArenaTeamHandler.SendResult(chr, ArenaTeamCommandId.CREATE, name, string.Empty, ArenaTeamResult.NAME_EXISTS);
                        return;
                    }
                }
                if (itemId != 0 && cost != 0 && type != PetitionType.None)
                {
                    var templ = ItemMgr.GetTemplate(itemId);
                    if (templ == null)
                    {
                        SendBuyError(chr, petitioner, itemId, BuyItemError.CantFindItem);
                    }
                    else if (chr.Money < cost)
                    {
                        SendBuyError(chr, petitioner, itemId, BuyItemError.NotEnoughMoney);
                    }
                    else if (!PetitionRecord.CanBuyPetition(chr.EntityId.Low))
                    {
                        chr.SendSystemMessage("You can't buy another petition !");
                    }
                    else
                    {
                        var slotId = chr.Inventory.FindFreeSlot(templ, 1);
                        if (slotId.Container == null)
                        {
                            SendBuyError(chr, petitioner, itemId, BuyItemError.CantCarryAnymore);
                        }
                        else
                        {
                            var item = slotId.Container.AddUnchecked(slotId.Slot, templ, 1, true) as PetitionCharter;
                            item.Petition = new PetitionRecord(name, chr.EntityId.Low, item.EntityId.Low, type);
                            item.Petition.Create();

                            chr.Money -= cost;

                            item.SetEnchantId(EnchantSlot.Permanent, item.EntityId.Low);
                        }
                    }
                }
            }
        }
 public static void SendArenaTeamRosterResponse(IPacketReceiver client, ArenaTeam team)
 {
     using (RealmPacketOut rosterResponsePacket = ArenaTeamHandler.CreateArenaTeamRosterResponsePacket(team))
         client.Send(rosterResponsePacket, false);
 }
 /// <summary>Sends result of actions connected with arenas</summary>
 /// <param name="client">the client to send to</param>
 /// <param name="commandId">command executed</param>
 /// <param name="resultCode">The <see cref="T:WCell.Constants.ArenaTeams.ArenaTeamResult" /> result code</param>
 public static void SendResult(IPacketReceiver client, ArenaTeamCommandId commandId, ArenaTeamResult resultCode)
 {
     ArenaTeamHandler.SendResult(client, commandId, string.Empty, string.Empty, resultCode);
 }