Ejemplo n.º 1
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null || slotIdx >= 3)
         {
             return;
         }
         PlayerTitles titles  = player.titles;
         int          titleId = titles.GetEquip(slotIdx);
         if (titleId > 0 && player.UpdateEquipedTitle(slotIdx, 0))
         {
             titles.SetEquip(slotIdx, 0);
             if (TitlesManager.Contains(titleId, player.equipments.beret) && player.ExecuteQuery($"UPDATE accounts SET character_beret='0' WHERE id='{player.playerId}'"))
             {
                 player.equipments.beret = 0;
                 Room room = player.room;
                 if (room != null && room.GetSlot(player.slotId, out Slot slot))
                 {
                     slot.equipment = player.equipments;
                 }
             }
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_DETACH_SUCCESS_PAK);
         }
         else
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_DETACH_ERROR_PAK);
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
Ejemplo n.º 2
0
 public override void run()
 {
     try
     {
         Account player = this._client._player;
         if (player == null)
         {
             return;
         }
         PlayerTitles titles = player._titles;
         TitleQ       title  = TitlesXML.getTitle((int)this.titleId, true);
         TitleQ       title1;
         TitleQ       title2;
         TitleQ       title3;
         TitlesXML.get3Titles(titles.Equiped1, titles.Equiped2, titles.Equiped3, out title1, out title2, out title3, false);
         if (this.slotIdx >= (byte)3 || this.titleId >= (byte)45 || (titles == null || title == null) || (title._classId == title1._classId && this.slotIdx != (byte)0 || title._classId == title2._classId && this.slotIdx != (byte)1) || (title._classId == title3._classId && this.slotIdx != (byte)2 || (!titles.Contains(title._flag) || titles.Equiped1 == (int)this.titleId) || (titles.Equiped2 == (int)this.titleId || titles.Equiped3 == (int)this.titleId)))
         {
             this.erro = 2147483648U;
         }
         else if (TitleManager.getInstance().updateEquipedTitle(titles.ownerId, (int)this.slotIdx, (int)this.titleId))
         {
             titles.SetEquip((int)this.slotIdx, (int)this.titleId);
         }
         else
         {
             this.erro = 2147483648U;
         }
         this._client.SendPacket((SendPacket) new BASE_TITLE_USE_PAK(this.erro));
     }
     catch (Exception ex)
     {
         Logger.info("BASE_TITLE_USE_REC: " + ex.ToString());
     }
 }
Ejemplo n.º 3
0
        public static string GetAllTitles(Account p)
        {
            if (p._titles.ownerId == 0L)
            {
                TitleManager.getInstance().CreateTitleDB(p.player_id);
                p._titles = new PlayerTitles()
                {
                    ownerId = p.player_id
                };
            }
            PlayerTitles titles = p._titles;
            int          num    = 0;

            for (int titleId = 1; titleId <= 44; ++titleId)
            {
                TitleQ title = TitlesXML.getTitle(titleId, true);
                if (title != null && !titles.Contains(title._flag))
                {
                    ++num;
                    titles.Add(title._flag);
                    if (titles.Slots < title._slot)
                    {
                        titles.Slots = title._slot;
                    }
                }
            }
            if (num > 0)
            {
                ComDiv.updateDB("player_titles", "titleslots", (object)titles.Slots, "owner_id", (object)p.player_id);
                TitleManager.getInstance().updateTitlesFlags(p.player_id, titles.Flags);
                p.SendPacket((SendPacket) new BASE_2626_PAK(p));
            }
            return(Translation.GetLabel("TitleAcquisiton", (object)num));
        }
Ejemplo n.º 4
0
 public override void run()
 {
     try
     {
         Account player = this._client._player;
         if (player == null || this.slotIdx >= 3 || player._titles == null)
         {
             return;
         }
         PlayerTitles titles = player._titles;
         int          equip  = titles.GetEquip(this.slotIdx);
         if (equip > 0 && TitleManager.getInstance().updateEquipedTitle(titles.ownerId, this.slotIdx, 0))
         {
             titles.SetEquip(this.slotIdx, 0);
             if (TitleAwardsXML.Contains(equip, player._equip._beret) && ComDiv.updateDB("accounts", "char_beret", (object)0, "player_id", (object)player.player_id))
             {
                 player._equip._beret = 0;
                 Room room = player._room;
                 if (room != null)
                 {
                     AllUtils.updateSlotEquips(player, room);
                 }
             }
         }
         else
         {
             this.erro = 2147483648U;
         }
         this._client.SendPacket((SendPacket) new BASE_TITLE_DETACH_PAK(this.erro));
     }
     catch (Exception ex)
     {
         Logger.info("BASE_TITLE_DETACH_REC: " + ex.ToString());
     }
 }
        public static string GetAllTitles(Account p)
        {
            if (p._titles.ownerId == 0)
            {
                TitleManager.getInstance().CreateTitleDB(p.player_id);
                p._titles = new PlayerTitles {
                    ownerId = p.player_id
                };
            }
            PlayerTitles titles = p._titles;
            int          count  = 0;

            for (int i = 1; i <= 44; i++)
            {
                TitleQ title = TitlesXML.getTitle(i, true);
                if (title != null && !titles.Contains(title._flag))
                {
                    count++;
                    titles.Add(title._flag);
                    if (titles.Slots < title._slot)
                    {
                        titles.Slots = title._slot;
                    }
                }
            }
            if (count > 0)
            {
                ComDiv.updateDB("player_titles", "titleslots", titles.Slots, "owner_id", p.player_id);
                TitleManager.getInstance().updateTitlesFlags(p.player_id, titles.Flags);
                p.SendPacket(new BASE_2626_PAK(p));
            }
            return(Translation.GetLabel("TitleAcquisiton", count));
        }
Ejemplo n.º 6
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null || titleId >= 45)
         {
             return;
         }
         PlayerTitles titles = player.titles;
         TitleQ       titleQ = TitlesManager.GetTitle(titleId);
         if (titleQ == null)
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_GET_ERROR_PAK);
             return;
         }
         TitlesManager.Get2Titles(titleQ.req1, titleQ.req2, out TitleQ titleReq1, out TitleQ titleReq2);
         if ((titleQ.req1 == 0 || titleReq1 != null) && (titleQ.req2 == 0 || titleReq2 != null) && player.rankId >= titleQ.rank && player.brooch >= titleQ.brooch && player.medal >= titleQ.medals && player.blueorder >= titleQ.blueOrder && player.insignia >= titleQ.insignia && !titles.Contains(titleQ.flag) && titles.Contains(titleReq1.flag) && titles.Contains(titleReq2.flag))
         {
             if (titles.Slots < titleQ.slot && player.UpdateTitleSlots(titleQ.slot))
             {
                 titles.Slots = titleQ.slot;
             }
             if (player.UpdateTitlesFlags(titles.Add(titleQ.flag)) && player.UpdateTitleRequirements(player.brooch - titleQ.brooch, player.insignia - titleQ.insignia, player.medal - titleQ.medals, player.blueorder - titleQ.blueOrder))
             {
                 player.brooch    -= titleQ.brooch;
                 player.medal     -= titleQ.medals;
                 player.blueorder -= titleQ.blueOrder;
                 player.insignia  -= titleQ.insignia;
                 List <ItemsModel> items = TitlesManager.GetAwards(titleId);
                 if (items.Count > 0)
                 {
                     client.SendPacket(new PROTOCOL_INVENTORY_ITEM_CREATE_ACK(1, player, items));
                 }
                 client.SendPacket(new BASE_QUEST_UPDATE_INFO_PAK(player));
                 client.SendPacket(new BASE_TITLE_GET_PAK(0, titles.Slots));
             }
             else
             {
                 client.SendCompletePacket(PackageDataManager.BASE_TITLE_GET_ERROR_PAK);
             }
         }
         else
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_GET_ERROR_PAK);
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
 /// <summary>
 /// Eventos, Títulos, Missões, Inventário, Status, Lista de amigos (Clean), Sessão, ClanMatch, Sala, Config, Connection,
 /// </summary>
 public void SimpleClear()
 {
     _titles    = new PlayerTitles();
     _mission   = new PlayerMissions();
     _inventory = new PlayerInventory();
     _status    = new AccountStatus();
     FriendSystem.CleanList();
     Session     = null;
     _event      = null;
     _match      = null;
     _room       = null;
     _config     = null;
     _connection = null;
 }
Ejemplo n.º 8
0
 public void SimpleClear()
 {
     this._titles    = new PlayerTitles();
     this._mission   = new PlayerMissions();
     this._inventory = new PlayerInventory();
     this._status    = new AccountStatus();
     this.FriendSystem.CleanList();
     this.Session     = (PlayerSession)null;
     this._event      = (PlayerEvent)null;
     this._match      = (Match)null;
     this._room       = (Room)null;
     this._config     = (PlayerConfig)null;
     this._connection = (GameClient)null;
 }
Ejemplo n.º 9
0
 public void SimpleClear()
 {
     _config      = null;
     _titles      = null;
     _bonus       = null;
     _event       = null;
     _connection  = null;
     _inventory   = new PlayerInventory();
     FriendSystem = new FriendSystem();
     _clanPlayers = new List <Account>();
     _equip       = new PlayerEquipedItems();
     _mission     = new PlayerMissions();
     _status      = new AccountStatus();
 }
Ejemplo n.º 10
0
 public void SimpleClear()
 {
     this._config      = (PlayerConfig)null;
     this._titles      = (PlayerTitles)null;
     this._bonus       = (PlayerBonus)null;
     this._event       = (PlayerEvent)null;
     this._connection  = (LoginClient)null;
     this._inventory   = new PlayerInventory();
     this.FriendSystem = new FriendSystem();
     this._clanPlayers = new List <Account>();
     this._equip       = new PlayerEquipedItems();
     this._mission     = new PlayerMissions();
     this._status      = new AccountStatus();
 }
Ejemplo n.º 11
0
        public void GetAccountInfos(int LoadType)
        {
            if (LoadType <= 0 || this.player_id <= 0L)
            {
                return;
            }
            if ((LoadType & 1) == 1)
            {
                this._titles = TitleManager.getInstance().getTitleDB(this.player_id);
            }
            if ((LoadType & 2) == 2)
            {
                this._bonus = PlayerManager.getPlayerBonusDB(this.player_id);
            }
            if ((LoadType & 4) == 4)
            {
                List <Friend> friendList = PlayerManager.getFriendList(this.player_id);
                if (friendList.Count > 0)
                {
                    this.FriendSystem._friends = friendList;
                    AccountManager.getFriendlyAccounts(this.FriendSystem);
                }
            }
            if ((LoadType & 8) == 8)
            {
                this._event = PlayerManager.getPlayerEventDB(this.player_id);
            }
            if ((LoadType & 16) == 16)
            {
                this._config = PlayerManager.getConfigDB(this.player_id);
            }
            if ((LoadType & 32) != 32)
            {
                return;
            }
            List <Friend> friendList1 = PlayerManager.getFriendList(this.player_id);

            if (friendList1.Count <= 0)
            {
                return;
            }
            this.FriendSystem._friends = friendList1;
        }
        public static string SendTitlePlayer(string str)
        {
            string txt = str.Substring(str.IndexOf(" ") + 1);

            string[] split     = txt.Split(' ');
            long     player_id = Convert.ToInt64(split[0]);

            Account p = AccountManager.getAccount(player_id, 0);

            if (p._titles.ownerId == 0)
            {
                TitleManager.getInstance().CreateTitleDB(p.player_id);
                p._titles = new PlayerTitles {
                    ownerId = p.player_id
                };
            }
            PlayerTitles titles = p._titles;
            int          count  = 0;

            for (int i = 1; i <= 44; i++)
            {
                TitleQ title = TitlesXML.getTitle(i, true);
                if (title != null && !titles.Contains(title._flag))
                {
                    count++;
                    titles.Add(title._flag);
                    if (titles.Slots < title._slot)
                    {
                        titles.Slots = title._slot;
                    }
                }
            }
            if (count > 0)
            {
                ComDiv.updateDB("player_titles", "titleslots", titles.Slots, "owner_id", p.player_id);
                TitleManager.getInstance().updateTitlesFlags(p.player_id, titles.Flags);
                p.SendPacket(new BASE_2626_PAK(p));
            }
            return(Translation.GetLabel("TitleAcquisiton", count));
        }
        public PlayerTitles getTitleDB(long pId)
        {
            PlayerTitles title = new PlayerTitles();

            if (pId == 0)
            {
                return(title);
            }
            try
            {
                using (NpgsqlConnection connection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = connection.CreateCommand();
                    connection.Open();
                    command.Parameters.AddWithValue("@owner", pId);
                    command.CommandText = "SELECT * FROM player_titles WHERE owner_id=@owner";
                    command.CommandType = CommandType.Text;
                    NpgsqlDataReader data = command.ExecuteReader();
                    while (data.Read())
                    {
                        title.ownerId  = pId;
                        title.Equiped1 = data.GetInt32(1);
                        title.Equiped2 = data.GetInt32(2);
                        title.Equiped3 = data.GetInt32(3);
                        title.Flags    = data.GetInt64(4);
                        title.Slots    = data.GetInt32(5);
                    }
                    command.Dispose();
                    data.Close();
                    connection.Dispose();
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[TitleManager.getTitleDB] Erro fatal!");
            }
            return(title);
        }
 /// <summary>
 /// Gera informações adicionais a conta\n0 = Nada\n1 = Títulos\n2 = Bônus\n4 = Amigos (Completo)\n8 = Eventos\n16 = Configurações\n32 = Amigos (Básico)
 /// </summary>
 /// <param name="LoadType">Detalhes</param>
 public void GetAccountInfos(int LoadType)
 {
     if (LoadType > 0 && player_id > 0)
     {
         if ((LoadType & 1) == 1)
         {
             _titles = TitleManager.getInstance().getTitleDB(player_id);
         }
         if ((LoadType & 2) == 2)
         {
             _bonus = PlayerManager.getPlayerBonusDB(player_id);
         }
         if ((LoadType & 4) == 4)
         {
             List <Friend> fs = PlayerManager.getFriendList(player_id);
             if (fs.Count > 0)
             {
                 FriendSystem._friends = fs;
                 AccountManager.getFriendlyAccounts(FriendSystem);
             }
         }
         if ((LoadType & 8) == 8)
         {
             _event = PlayerManager.getPlayerEventDB(player_id);
         }
         if ((LoadType & 16) == 16)
         {
             _config = PlayerManager.getConfigDB(player_id);
         }
         if ((LoadType & 32) == 32)
         {
             List <Friend> fs = PlayerManager.getFriendList(player_id);
             if (fs.Count > 0)
             {
                 FriendSystem._friends = fs;
             }
         }
     }
 }
 public override void run()
 {
     try
     {
         Account p = _client._player;
         if (p == null || slotIdx >= 3 || p._titles == null)
         {
             return;
         }
         PlayerTitles t       = p._titles;
         int          titleId = t.GetEquip(slotIdx);
         if (titleId > 0 &&
             TitleManager.getInstance().updateEquipedTitle(t.ownerId, slotIdx, 0))
         {
             t.SetEquip(slotIdx, 0);
             if (TitleAwardsXML.Contains(titleId, p._equip._beret) && ComDiv.updateDB("contas", "char_beret", 0, "player_id", p.player_id))
             {
                 p._equip._beret = 0;
                 Room room = p._room;
                 if (room != null)
                 {
                     AllUtils.updateSlotEquips(p, room);
                 }
             }
         }
         else
         {
             erro = 0x80000000;
         }
         _client.SendPacket(new BASE_TITLE_DETACH_PAK(erro));
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[BASE_TITLE_DETACH_REC.run] Erro fatal!");
     }
 }
Ejemplo n.º 16
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null)
         {
             return;
         }
         PlayerTitles titles = player.titles;
         TitleQ       titleQ = TitlesManager.GetTitle(titleId);
         if (slotIdx >= 3 || titleId >= 45 || titleQ == null || titles.Equiped1 == titleId || titles.Equiped2 == titleId || titles.Equiped3 == titleId)
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_USE_ERROR_PAK);
             return;
         }
         TitlesManager.GetTitlesEquipped(titles.Equiped1, titles.Equiped2, titles.Equiped3, out TitleQ titleEquiped1, out TitleQ titleEquiped2, out TitleQ titleEquiped3);
         if (titleQ.classId == titleEquiped1.classId && slotIdx != 0 || titleQ.classId == titleEquiped2.classId && slotIdx != 1 || titleQ.classId == titleEquiped3.classId && slotIdx != 2 || !titles.Contains(titleQ.flag))
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_USE_ERROR_PAK);
             return;
         }
         if (player.UpdateEquipedTitle(slotIdx, titleId))
         {
             titles.SetEquip(slotIdx, titleId);
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_USE_SUCCESS_PAK);
         }
         else
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_USE_ERROR_PAK);
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
Ejemplo n.º 17
0
 public void GetAccountInfos(int LoadType)
 {
     if (LoadType == 0 || this.player_id == 0L)
     {
         return;
     }
     if ((LoadType & 1) == 1)
     {
         this._titles = TitleManager.getInstance().getTitleDB(this.player_id);
     }
     if ((LoadType & 2) == 2)
     {
         this._bonus = PlayerManager.getPlayerBonusDB(this.player_id);
     }
     if ((LoadType & 4) == 4)
     {
         List <Friend> friendList = PlayerManager.getFriendList(this.player_id);
         if (friendList.Count > 0)
         {
             this.FriendSystem._friends = friendList;
         }
     }
     if ((LoadType & 8) == 8)
     {
         this._event = PlayerManager.getPlayerEventDB(this.player_id);
         if (this._event == null)
         {
             PlayerManager.addEventDB(this.player_id);
             this._event = new PlayerEvent();
         }
     }
     if ((LoadType & 16) != 16)
     {
         return;
     }
     this._config = PlayerManager.getConfigDB(this.player_id);
 }
Ejemplo n.º 18
0
 public void GetAccountInfos(int LoadType)
 {
     if (LoadType == 0 || player_id == 0)
     {
         return;
     }
     if ((LoadType & 1) == 1)
     {
         _titles = TitleManager.getInstance().getTitleDB(player_id);
     }
     if ((LoadType & 2) == 2)
     {
         _bonus = PlayerManager.getPlayerBonusDB(player_id);
     }
     if ((LoadType & 4) == 4)
     {
         List <Friend> fs = PlayerManager.getFriendList(player_id);
         if (fs.Count > 0)
         {
             FriendSystem._friends = fs;
         }
     }
     if ((LoadType & 8) == 8)
     {
         _event = PlayerManager.getPlayerEventDB(player_id);
         if (_event == null)
         {
             PlayerManager.addEventDB(player_id);
             _event = new PlayerEvent();
         }
     }
     if ((LoadType & 16) == 16)
     {
         _config = PlayerManager.getConfigDB(player_id);
     }
 }
 public override void run()
 {
     try
     {
         Account p = _client._player;
         if (p == null)
         {
             return;
         }
         PlayerTitles t = p._titles;
         TitleQ       titleQ = TitlesXML.getTitle(titleId),
                      eq1, eq2, eq3;
         TitlesXML.get3Titles(t.Equiped1, t.Equiped2, t.Equiped3, out eq1, out eq2, out eq3, false);
         if (slotIdx >= 3 || titleId >= 45 || t == null || titleQ == null || titleQ._classId == eq1._classId && slotIdx != 0 || titleQ._classId == eq2._classId && slotIdx != 1 || titleQ._classId == eq3._classId && slotIdx != 2 || !t.Contains(titleQ._flag) || t.Equiped1 == titleId || t.Equiped2 == titleId || t.Equiped3 == titleId)
         {
             erro = 0x80000000;
         }
         else
         {
             if (TitleManager.getInstance().updateEquipedTitle(t.ownerId, slotIdx, titleId))
             {
                 t.SetEquip(slotIdx, titleId);
             }
             else
             {
                 erro = 0x80000000;
             }
         }
         _client.SendPacket(new BASE_TITLE_USE_PAK(erro));
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[BASE_TITLE_USE_REC.run] Erro fatal!");
     }
 }
Ejemplo n.º 20
0
        public static string SendTitlePlayer(string str)
        {
            Account account = AccountManager.getAccount(Convert.ToInt64(str.Substring(str.IndexOf(" ") + 1).Split(' ')[0]), 0);

            if (account._titles.ownerId == 0L)
            {
                TitleManager.getInstance().CreateTitleDB(account.player_id);
                account._titles = new PlayerTitles()
                {
                    ownerId = account.player_id
                };
            }
            PlayerTitles titles = account._titles;
            int          num    = 0;

            for (int titleId = 1; titleId <= 44; ++titleId)
            {
                TitleQ title = TitlesXML.getTitle(titleId, true);
                if (title != null && !titles.Contains(title._flag))
                {
                    ++num;
                    titles.Add(title._flag);
                    if (titles.Slots < title._slot)
                    {
                        titles.Slots = title._slot;
                    }
                }
            }
            if (num > 0)
            {
                ComDiv.updateDB("player_titles", "titleslots", (object)titles.Slots, "owner_id", (object)account.player_id);
                TitleManager.getInstance().updateTitlesFlags(account.player_id, titles.Flags);
                account.SendPacket((SendPacket) new BASE_2626_PAK(account));
            }
            return(Translation.GetLabel("TitleAcquisiton", (object)num));
        }
Ejemplo n.º 21
0
 public void SetPlayerId()
 {
     _titles = new PlayerTitles();
     _bonus  = new PlayerBonus();
     GetAccountInfos(8);
 }
Ejemplo n.º 22
0
 public void SetPlayerId()
 {
     this._titles = new PlayerTitles();
     this._bonus  = new PlayerBonus();
     this.GetAccountInfos(8);
 }
Ejemplo n.º 23
0
 public BATTLE_READYBATTLE2_PAK(SLOT slot,PlayerTitles title)
 {
     this.slot  = slot;
     this.title = title;
 }