Exemple #1
0
        public byte[] BuyItemFromGuild(byte[] argument)
        {
            ushort guildIDBuying    = swap16(BitConverter.ToUInt16(argument, 0));
            uint   itemIDBuying     = swap32(BitConverter.ToUInt32(argument, 2));
            ushort quantityOfBuying = swap16(BitConverter.ToUInt16(argument, 6));
            uint   priceOfEachPiece = swap32(BitConverter.ToUInt32(argument, 8));

            Console.WriteLine("Guild ID " + guildIDBuying + "\nItem ID = " + itemIDBuying + "\nitem Quantity " +
                              quantityOfBuying + "\nprice of each piece " + priceOfEachPiece);

            GuildItemShopModel guildItemShopModel =
                DBAcess.getInstance().GetSingleGuildItem(guildIDBuying, itemIDBuying);

            GuildRepositoryModel guildRepositoryModel = DBAcess.getInstance().GetGuildInfo(guildIDBuying);

            guildItemShopModel.Quantity -= quantityOfBuying;

            uint totalGPToAdd = priceOfEachPiece * quantityOfBuying;

            guildRepositoryModel.Gp += (int)totalGPToAdd;

            DBAcess.getInstance().UpdateSingleGuildItem(guildItemShopModel, false);
            DBAcess.getInstance().UpdateGuildInfo(guildRepositoryModel);

            MemoryStream m = new MemoryStream();

            m.Write(BitConverter.GetBytes(swap16(quantityOfBuying)));
            return(m.ToArray());
        }
Exemple #2
0
        public ushort CreateGuild(byte[] argument, uint masterPlayerID)
        {
            int pos = 0;

            byte[] guildNameBytes = ReadByteString(argument, pos);
            pos += guildNameBytes.Length;

            byte[] guildCommentBytes = ReadByteString(argument, pos);
            pos += guildCommentBytes.Length;

            byte[] guildEmblem = ReadByteGuildEmblem(argument, pos);

            GuildRepositoryModel model = new GuildRepositoryModel();

            model.GuildName         = guildNameBytes;
            model.GuildComment      = guildCommentBytes;
            model.GuildEmblem       = guildEmblem;
            model.GoldCoin          = 0;
            model.SilverCoin        = 0;
            model.BronzeCoin        = 0;
            model.Gp                = 0;
            model.MasterPlayerID    = (int)masterPlayerID;
            model.EstablishmentDate = DateTime.Now.ToString("yyyy/MM/dd");

            ushort guildID = DBAcess.getInstance().CreateGuild(model);

            DBAcess.getInstance().EnrollPlayerInGuild(guildID, masterPlayerID, true);

            return(guildID);
        }
Exemple #3
0
        public byte[] DonateCoinsToGuild(byte[] argument)
        {
            ushort guildIDCointToDonate = swap16(BitConverter.ToUInt16(argument, 0));
            ushort goldCoinDonate       = swap16(BitConverter.ToUInt16(argument, 2));
            ushort silverCoinDonate     = swap16(BitConverter.ToUInt16(argument, 4));
            ushort bronzeCoinDonate     = swap16(BitConverter.ToUInt16(argument, 6));

            Console.WriteLine("Gold Coin Donation " + goldCoinDonate);
            Console.WriteLine("Silver Coin Donation " + silverCoinDonate);
            Console.WriteLine("Bronze Coin Donation " + bronzeCoinDonate);

            GuildRepositoryModel guildRepositoryModel = DBAcess.getInstance().GetGuildInfo(guildIDCointToDonate);

            guildRepositoryModel.GoldCoin   += goldCoinDonate;
            guildRepositoryModel.SilverCoin += silverCoinDonate;
            guildRepositoryModel.BronzeCoin += bronzeCoinDonate;

            DBAcess.getInstance().UpdateGuildInfo(guildRepositoryModel);

            MemoryStream m = new MemoryStream();

            m.Write(BitConverter.GetBytes(swap16(goldCoinDonate)));
            m.Write(BitConverter.GetBytes(swap16(silverCoinDonate)));
            m.Write(BitConverter.GetBytes(swap16(bronzeCoinDonate)));

            return(m.ToArray());
        }
Exemple #4
0
        public byte[] GetPriceOfItemToBeDonated(ushort guildID, uint itemID)
        {
            GuildItemShopModel guildItemShopModel = DBAcess.getInstance().GetSingleGuildItem(guildID, itemID);

            if (guildItemShopModel == null || guildItemShopModel.ItemShopID == -1 || guildItemShopModel.ItemShopID == 0)
            {
                MemoryStream m = new MemoryStream();

                m = new MemoryStream();
                m.Write(BitConverter.GetBytes(swap32(0)));
                m.Write(BitConverter.GetBytes(swap32(0)));

                return(m.ToArray());
            }
            else
            {
                MemoryStream m = new MemoryStream();

                m = new MemoryStream();
                m.Write(BitConverter.GetBytes(swap32((uint)guildItemShopModel.GeneralPrice)));
                m.Write(BitConverter.GetBytes(swap32((uint)guildItemShopModel.MemberPrice)));

                return(m.ToArray());
            }
        }
Exemple #5
0
        public byte[] LeaveGuildAndAssignMaster(ushort guildID, uint playerToAssign)
        {
            CharacterRepositoryModel characterRepositoryModel = DBAcess.getInstance().GetCharacterInfo(playerToAssign);

            characterRepositoryModel.GuildMaster = 1;
            DBAcess.getInstance().updatePlayerInfo(characterRepositoryModel);
            return(new byte[] { 0x00, 0x00 });
        }
Exemple #6
0
        public byte[] LeaveGuild(ushort guildID, uint characterID)
        {
            CharacterRepositoryModel characterRepositoryModel = DBAcess.getInstance().GetCharacterInfo(characterID);

            characterRepositoryModel.GuildID     = 0;
            characterRepositoryModel.GuildMaster = 0;
            DBAcess.getInstance().updatePlayerInfo(characterRepositoryModel);
            return(new byte[] { 0x00, 0x00 });
        }
Exemple #7
0
        public byte[] TakeItemFromGuild(ushort guildID, uint itemID, ushort quantity)
        {
            GuildItemShopModel guildItemShopModel = DBAcess.getInstance().GetSingleGuildItem(guildID, itemID);

            guildItemShopModel.Quantity -= quantity;
            DBAcess.getInstance().UpdateSingleGuildItem(guildItemShopModel, false);

            MemoryStream m = new MemoryStream();

            m.Write(BitConverter.GetBytes(swap16(quantity)));
            return(m.ToArray());
        }
Exemple #8
0
        public byte[] TakeMoneyFromGuild(ushort guildID, uint amountOfMoney)
        {
            GuildRepositoryModel guildRepositoryModel = DBAcess.getInstance().GetGuildInfo(guildID);

            guildRepositoryModel.Gp -= (int)amountOfMoney;

            DBAcess.getInstance().UpdateGuildInfo(guildRepositoryModel);

            MemoryStream m = new MemoryStream();

            m.Write(BitConverter.GetBytes(swap32(amountOfMoney)));
            return(m.ToArray());
        }
Exemple #9
0
        public async Task SaveMailAsync(byte[] data)
        {
            var receiver_accountID = new byte[4];
            var receiver           = new byte[16];
            var sender_accountID   = new byte[4];
            var sender             = new byte[16];
            var subject            = new byte[32];
            var body = new byte[1200];
            var face = new byte[25];

            logger.Debug("Taking data block and breaking it out...");
            Buffer.BlockCopy(data, 4, receiver_accountID, 0, 4);
            Buffer.BlockCopy(data, 8, receiver, 0, 16);
            Buffer.BlockCopy(data, 26, sender_accountID, 0, 4);
            Buffer.BlockCopy(data, 30, sender, 0, 16);
            Buffer.BlockCopy(data, 48, subject, 0, 32);
            Buffer.BlockCopy(data, 176, body, 0, 1200);
            Buffer.BlockCopy(data, 1378, face, 0, 25);
            logger.Debug("...completed; dumping primative information");

            logger.Debug("Receiving Account ID: " + swap32(BitConverter.ToUInt32(receiver_accountID)));
            logger.Debug("Receiver Name: " + encoding.GetString(receiver));
            logger.Debug("Sender Account ID: " + swap32(BitConverter.ToUInt32(sender_accountID)));
            logger.Debug("Sender Name: " + encoding.GetString(sender));
            logger.Debug("Subject Line: " + encoding.GetString(subject));
            logger.Debug("Message Body: " + encoding.GetString(body));
            logger.Debug("Face ID: " + encoding.GetString(face));

            var metaModel = new MailMetaModel
            {
                Receiver_Account_ID = (int)swap32(BitConverter.ToUInt32(receiver_accountID)),
                Receiver_Name       = receiver,
                Sender_Account_ID   = (int)swap32(BitConverter.ToUInt32(sender_accountID)),
                Sender_Name         = sender,
                Mail_Subject        = subject,
                date           = DateTime.UtcNow,
                Mail_Delivered = false
            };

            var bodyModel = new MailBodyModel
            {
                Mail_Body    = body,
                Mail_Face_ID = encoding.GetString(face)
            };

            logger.Information($"An email has been sent by {sender} to {receiver}. Saving...", sender, receiver);
            await Task.Run(() => DBAcess.getInstance().CreateNewMail(metaModel, bodyModel));

            logger.Information("The email has been saved to the database");
        }
 private void Client_OnGameClientDisconnected(object sender, EventArgs e)
 {
     if (!(sender is GameClientAsync client))
     {
         return;
     }
     RemoveClient(client);
     if (client.PlayerID != 0)
     {
         DBAcess.getInstance().setPlayerAsOffline(client.PlayerID);
     }
     if (!client.IsAreaServer && lobbyChatService.TryFindLobby(client, out var lobby))
     {
         lobbyChatService.AnnounceRoomDeparture(lobby, (uint)client.ClientIndex);
     }
     client.OnGameClientDisconnected -= Client_OnGameClientDisconnected;
 }
Exemple #11
0
        public List <byte[]> GetPlayerRanking(ushort categoryID, ushort classID)
        {
            List <CharacterRepositoryModel> characterList = DBAcess.getInstance().GetRanking(categoryID, classID);

            List <byte[]> rankingList = new List <byte[]>();

            MemoryStream m = new MemoryStream();

            foreach (var player in characterList)
            {
                m = new MemoryStream();
                m.Write(player.CharachterName);
                m.Write(BitConverter.GetBytes(swap32((uint)player.PlayerID)));
                rankingList.Add(m.ToArray());
            }

            return(rankingList);
        }
Exemple #12
0
        public List <byte[]> GetAllGuildItemsWithSettings(ushort guildID)
        {
            List <GuildItemShopModel> guildItemList = DBAcess.getInstance().GetGuildsItems(guildID);

            List <byte[]> itemList = new List <byte[]>();

            if (guildItemList == null)
            {
                guildItemList = new List <GuildItemShopModel>();
            }

            MemoryStream m = new MemoryStream();

            foreach (var item in guildItemList)
            {
                m = new MemoryStream();
                m.Write(BitConverter.GetBytes(swap32((uint)item.ItemID)), 0, 4);
                m.Write(BitConverter.GetBytes(swap16((ushort)item.Quantity)), 0, 2);
                m.Write(BitConverter.GetBytes(swap32((uint)item.GeneralPrice)), 0, 4);
                m.Write(BitConverter.GetBytes(swap32((uint)item.MemberPrice)), 0, 4);

                if (item.AvailableForGeneral)
                {
                    m.Write(new byte[] { 0x01 });
                }
                else
                {
                    m.Write(new byte[] { 0x00 });
                }

                if (item.AvailableForMember)
                {
                    m.Write(new byte[] { 0x01 });
                }
                else
                {
                    m.Write(new byte[] { 0x00 });
                }

                itemList.Add(m.ToArray());
            }

            return(itemList);
        }
Exemple #13
0
        public List <byte[]> GetGuildItems(ushort guildId, bool isGeneral)
        {
            List <GuildItemShopModel> guildItemList = DBAcess.getInstance().GetGuildsItems(guildId);

            if (guildItemList == null)
            {
                guildItemList = new List <GuildItemShopModel>();
            }

            List <byte[]> listOfItems = new List <byte[]>();
            MemoryStream  m           = new MemoryStream();


            foreach (var item in guildItemList)
            {
                if (isGeneral)
                {
                    if (item.AvailableForGeneral)
                    {
                        m = new MemoryStream();
                        m.Write(BitConverter.GetBytes(swap32((uint)item.ItemID)), 0, 4);
                        m.Write(BitConverter.GetBytes(swap16((ushort)item.Quantity)), 0, 2);
                        m.Write(BitConverter.GetBytes(swap32((uint)item.GeneralPrice)), 0, 4);
                        listOfItems.Add(m.ToArray());
                    }
                }
                else
                {
                    if (item.AvailableForMember)
                    {
                        m = new MemoryStream();
                        m.Write(BitConverter.GetBytes(swap32((uint)item.ItemID)), 0, 4);
                        m.Write(BitConverter.GetBytes(swap16((ushort)item.Quantity)), 0, 2);
                        m.Write(BitConverter.GetBytes(swap32((uint)item.MemberPrice)), 0, 4);
                        listOfItems.Add(m.ToArray());
                    }
                }
            }

            return(listOfItems);
        }
Exemple #14
0
        public byte[] UpdateGuildEmblemComment(byte[] argument, ushort guildID)
        {
            int pos = 0;

            byte[] guildNameBytes = ReadByteString(argument, pos);
            pos += guildNameBytes.Length;

            byte[] guildCommentBytes = ReadByteString(argument, pos);
            pos += guildCommentBytes.Length;

            byte[] guildEmblem = ReadByteGuildEmblem(argument, pos);

            GuildRepositoryModel guildRepositoryModel = DBAcess.getInstance().GetGuildInfo(guildID);

            guildRepositoryModel.GuildComment = guildCommentBytes;
            guildRepositoryModel.GuildEmblem  = guildEmblem;

            DBAcess.getInstance().UpdateGuildInfo(guildRepositoryModel);

            return(new byte[] { 0x00, 0x00 });
        }
Exemple #15
0
        public byte[] AddItemToGuildInventory(ushort guildID, uint itemID, ushort itemQuantity, uint generalPrice,
                                              uint memberPrice, bool isGeneral, bool isMember, bool isGuildMaster)
        {
            bool isNewItem = false;
            GuildItemShopModel guildItemShopModel = DBAcess.getInstance().GetSingleGuildItem(guildID, itemID);

            if (guildItemShopModel == null || guildItemShopModel.ItemShopID == -1 || guildItemShopModel.ItemShopID == 0)
            {
                guildItemShopModel                     = new GuildItemShopModel();
                guildItemShopModel.ItemID              = (int)itemID;
                guildItemShopModel.GuildID             = guildID;
                guildItemShopModel.Quantity            = 0;
                guildItemShopModel.GeneralPrice        = 0;
                guildItemShopModel.MemberPrice         = 0;
                guildItemShopModel.AvailableForGeneral = false;
                guildItemShopModel.AvailableForMember  = false;

                isNewItem = true;
            }

            guildItemShopModel.Quantity += itemQuantity;



            if (isGuildMaster)
            {
                // edit price and publishing settings
                guildItemShopModel.GeneralPrice        = (int)generalPrice;
                guildItemShopModel.MemberPrice         = (int)memberPrice;
                guildItemShopModel.AvailableForGeneral = isGeneral;
                guildItemShopModel.AvailableForMember  = isMember;
            }

            DBAcess.getInstance().UpdateSingleGuildItem(guildItemShopModel, isNewItem);

            MemoryStream m = new MemoryStream();

            m.Write(BitConverter.GetBytes(swap16(itemQuantity)));
            return(m.ToArray());
        }
Exemple #16
0
        public List <byte[]> GetListOfGuilds()
        {
            List <GuildRepositoryModel> guildRepositoryModels = DBAcess.getInstance().GetAllGuilds();

            if (guildRepositoryModels == null)
            {
                guildRepositoryModels = new List <GuildRepositoryModel>();
            }

            List <byte[]> listOfGuilds = new List <byte[]>();

            MemoryStream m = new MemoryStream();

            foreach (var guild in guildRepositoryModels)
            {
                m = new MemoryStream();
                m.Write(BitConverter.GetBytes(swap16((ushort)guild.GuildID)), 0, 2);
                m.Write(guild.GuildName);

                listOfGuilds.Add(m.ToArray());
            }

            return(listOfGuilds);
        }
Exemple #17
0
        public byte[] SetItemVisibilityAndPrice(byte[] argument) // from guild master window
        {
            ushort  GuildIDMaster      = swap16(BitConverter.ToUInt16(argument, 0));
            uint    itemIDmaster       = swap32(BitConverter.ToUInt32(argument, 2));
            uint    GeneralPriceMaster = swap32(BitConverter.ToUInt32(argument, 6));
            uint    MemberPriceMaster  = swap32(BitConverter.ToUInt32(argument, 10));
            Boolean isGeneralMaster    = argument[14] == 0x01;
            Boolean isMemberMaster     = argument[15] == 0x01;

            GuildItemShopModel guildItemShopModel =
                DBAcess.getInstance().GetSingleGuildItem(GuildIDMaster, itemIDmaster);

            guildItemShopModel.GeneralPrice        = (int)GeneralPriceMaster;
            guildItemShopModel.MemberPrice         = (int)MemberPriceMaster;
            guildItemShopModel.AvailableForGeneral = isGeneralMaster;
            guildItemShopModel.AvailableForMember  = isMemberMaster;

            DBAcess.getInstance().UpdateSingleGuildItem(guildItemShopModel, false);

            Console.Write("GenePrice " + GeneralPriceMaster + "\nMemberPrice " + MemberPriceMaster + "\nisGeneral " +
                          isGeneralMaster + "\nisMember " + isMemberMaster);

            return(new byte[] { 0x00, 0x00 });
        }
Exemple #18
0
        public byte[] GetPlayerGuild(uint characterID)
        {
            CharacterRepositoryModel characterRepositoryModel = DBAcess.getInstance().GetCharacterInfo(characterID);

            MemoryStream m = new MemoryStream();

            if (characterRepositoryModel.GuildMaster == 1) // the player is guild master
            {
                m.Write(new byte[] { 0x01 });
                m.Write(BitConverter.GetBytes(((ushort)characterRepositoryModel.GuildID).Swap()));
            }
            else if (characterRepositoryModel.GuildMaster == 2)  // the player is a normal member
            {
                m.Write(new byte[] { 0x02 });
                m.Write(BitConverter.GetBytes(((ushort)characterRepositoryModel.GuildID).Swap()));
            }
            else
            {
                m.Write(new byte[] { 0x00, 0x00, 0x00 });
            }


            return(m.ToArray());
        }
Exemple #19
0
        public byte[] getRankingPlayerInfo(uint playerID)
        {
            CharacterRepositoryModel characterRepositoryModel = DBAcess.getInstance().GetCharacterInfo(playerID);
            GuildRepositoryModel     guildRepositoryModel     = null;
            bool inGuild = false;

            if (characterRepositoryModel.GuildID != 0)
            {
                guildRepositoryModel = DBAcess.getInstance().GetGuildInfo((ushort)characterRepositoryModel.GuildID);
                inGuild = true;
            }

            MemoryStream m = new MemoryStream();

            m.Write(characterRepositoryModel.CharachterName);

            if (characterRepositoryModel.ClassID == 0)
            {
                m.Write(new byte[] { 0x00 });
            }
            if (characterRepositoryModel.ClassID == 1)
            {
                m.Write(new byte[] { 0x01 });
            }
            if (characterRepositoryModel.ClassID == 2)
            {
                m.Write(new byte[] { 0x02 });
            }
            if (characterRepositoryModel.ClassID == 3)
            {
                m.Write(new byte[] { 0x03 });
            }
            if (characterRepositoryModel.ClassID == 4)
            {
                m.Write(new byte[] { 0x04 });
            }
            if (characterRepositoryModel.ClassID == 5)
            {
                m.Write(new byte[] { 0x05 });
            }

            m.Write(BitConverter.GetBytes(swap16((ushort)characterRepositoryModel.CharachterLevel)));
            m.Write(characterRepositoryModel.Greeting);

            if (inGuild && guildRepositoryModel != null)
            {
                m.Write(guildRepositoryModel.GuildName);
            }
            else
            {
                m.Write(new byte[] { 0x00 });
            }

            m.Write(BitConverter.GetBytes(swap32((uint)characterRepositoryModel.ModelNumber)));

            if (characterRepositoryModel.OnlineStatus)
            {
                m.Write(new byte[] { 0x01 });
            }
            else
            {
                m.Write(new byte[] { 0x00 });
            }

            if (characterRepositoryModel.GuildMaster == 1)
            {
                m.Write(new byte[] { 0x01 });
            }
            else if (characterRepositoryModel.GuildMaster == 2)
            {
                m.Write(new byte[] { 0x02 });
            }
            else
            {
                m.Write(new byte[] { 0x03 });
            }

            return(m.ToArray());
        }
Exemple #20
0
        public byte[] GetGuildInfo(ushort guildID)
        {
            GuildRepositoryModel     guildRepositoryModel = DBAcess.getInstance().GetGuildInfo(guildID);
            CharacterRepositoryModel guildMaster          =
                DBAcess.getInstance().GetCharacterInfo((uint)guildRepositoryModel.MasterPlayerID);
            List <CharacterRepositoryModel> listOfmembers = DBAcess.getInstance().GetAllGuildMembers(guildID);


            MemoryStream m = new MemoryStream();

            m.Write(guildRepositoryModel.GuildName);
            m.Write(_encoding.GetBytes(guildRepositoryModel.EstablishmentDate)); //date
            m.Write(new byte[] { 0x00 });
            m.Write(guildMaster.CharachterName);


            int memTotal    = listOfmembers.Count;
            int twinBlade   = 0;
            int bladeMaster = 0;
            int heavyBlade  = 0;
            int heaveyAxes  = 0;
            int longArm     = 0;
            int waveMaster  = 0;
            int totalLevel  = 0;


            foreach (var member in listOfmembers)
            {
                if (member.ClassID == 0)
                {
                    twinBlade++;
                }
                if (member.ClassID == 1)
                {
                    bladeMaster++;
                }
                if (member.ClassID == 2)
                {
                    heavyBlade++;
                }
                if (member.ClassID == 3)
                {
                    heaveyAxes++;
                }
                if (member.ClassID == 4)
                {
                    longArm++;
                }

                if (member.ClassID == 5)
                {
                    waveMaster++;
                }

                totalLevel += member.CharachterLevel;
            }

            int avgLevel = 0;

            if (memTotal != 0)
            {
                avgLevel = totalLevel / memTotal;
            }


            m.Write(BitConverter.GetBytes(swap16((ushort)memTotal)), 0, 2);
            m.Write(BitConverter.GetBytes(swap16((ushort)twinBlade)), 0, 2);
            m.Write(BitConverter.GetBytes(swap16((ushort)bladeMaster)), 0, 2);
            m.Write(BitConverter.GetBytes(swap16((ushort)heavyBlade)), 0, 2);
            m.Write(BitConverter.GetBytes(swap16((ushort)heaveyAxes)), 0, 2);
            m.Write(BitConverter.GetBytes(swap16((ushort)longArm)), 0, 2);
            m.Write(BitConverter.GetBytes(swap16((ushort)waveMaster)), 0, 2);
            m.Write(BitConverter.GetBytes(swap16((ushort)avgLevel)), 0, 2);


            m.Write(BitConverter.GetBytes(swap32((uint)guildRepositoryModel.GoldCoin)), 0, 4);
            m.Write(BitConverter.GetBytes(swap32((uint)guildRepositoryModel.SilverCoin)), 0, 4);
            m.Write(BitConverter.GetBytes(swap32((uint)guildRepositoryModel.BronzeCoin)), 0, 4);

            m.Write(BitConverter.GetBytes(swap32((uint)guildRepositoryModel.Gp)), 0, 4);

            m.Write(guildRepositoryModel.GuildComment);

            m.Write(guildRepositoryModel.GuildEmblem);
            m.Write(new byte[] { 0x00 });

            return(m.ToArray());
        }
Exemple #21
0
 public byte[] DestroyGuild(ushort guildID)
 {
     DBAcess.getInstance().DeleteGuild(guildID);
     return(new byte[] { 0x00, 0x00 });
 }
 public async Task <IList <BbsThreadModel> > GetThreadsAsync(int categoryId)
 {
     return(await Task.Run(() => DBAcess.getInstance().getThreadsByCategoryID(categoryId)));
 }
 public async Task <IList <BbsPostMetaModel> > GetThreadDetailsAsync(int threadId)
 {
     return(await Task.Run(() => DBAcess.getInstance().GetPostsMetaByThreadId(threadId)));
 }
Exemple #24
0
 public async Task <MailBodyModel> GetMailContent(int mailId)
 {
     logger.Debug($"Fetching Mail Content for {mailId}", mailId);
     return(await Task.Run(() => DBAcess.getInstance().GetMailBodyByMailId(mailId)));
 }
Exemple #25
0
 public async Task <IList <MailMetaModel> > GetMailAsync(int accountId)
 {
     logger.Information($"Account {accountId} has requested their mail", accountId);
     return(await Task.Run(() => DBAcess.getInstance().GetAccountMail(accountId)));
 }
 public async Task <BbsPostBody> GetThreadPostContentAsync(int postId)
 {
     return(await Task.Run(() => DBAcess.getInstance().GetPostBodyByPostId(postId)));
 }
Exemple #27
0
        public List <byte[]> GetGuildMembersListByClass(ushort guildID, ushort categoryID, uint playerID)
        {
            List <CharacterRepositoryModel> allMembers = DBAcess.getInstance().GetAllGuildMembers(guildID);

            if (allMembers == null)
            {
                allMembers = new List <CharacterRepositoryModel>();
            }

            MemoryStream m = new MemoryStream();

            List <byte[]> membersList = new List <byte[]>();

            if (categoryID == 1) // get all members
            {
                foreach (var member in allMembers)
                {
                    if (member.PlayerID == playerID)
                    {
                        continue;
                    }

                    m = new MemoryStream();

                    m.Write(member.CharachterName);

                    if (member.ClassID == 0)
                    {
                        m.Write(new byte[] { 0x00 });
                    }
                    if (member.ClassID == 1)
                    {
                        m.Write(new byte[] { 0x01 });
                    }
                    if (member.ClassID == 2)
                    {
                        m.Write(new byte[] { 0x02 });
                    }
                    if (member.ClassID == 3)
                    {
                        m.Write(new byte[] { 0x03 });
                    }
                    if (member.ClassID == 4)
                    {
                        m.Write(new byte[] { 0x04 });
                    }
                    if (member.ClassID == 5)
                    {
                        m.Write(new byte[] { 0x05 });
                    }

                    m.Write(BitConverter.GetBytes(swap16((ushort)member.CharachterLevel)));
                    m.Write(member.Greeting);

                    if (member.OnlineStatus)
                    {
                        m.Write(new byte[] { 0x01 });
                    }
                    else
                    {
                        m.Write(new byte[] { 0x00 });
                    }


                    m.Write(BitConverter.GetBytes(swap32((uint)member.ModelNumber)));

                    m.Write(BitConverter.GetBytes(swap32((uint)member.PlayerID))); // Player ID
                    m.Write(BitConverter.GetBytes(member.GuildMaster));

                    membersList.Add(m.ToArray());
                }

                return(membersList);
            }

            int classID = categoryID - 2;



            foreach (var member in allMembers)
            {
                if (member.PlayerID == playerID)
                {
                    continue;
                }


                if (member.ClassID != classID)
                {
                    continue;
                }


                m = new MemoryStream();

                m.Write(member.CharachterName);



                if (member.ClassID == 0)
                {
                    m.Write(new byte[] { 0x00 });
                }
                if (member.ClassID == 1)
                {
                    m.Write(new byte[] { 0x01 });
                }
                if (member.ClassID == 2)
                {
                    m.Write(new byte[] { 0x02 });
                }
                if (member.ClassID == 3)
                {
                    m.Write(new byte[] { 0x03 });
                }
                if (member.ClassID == 4)
                {
                    m.Write(new byte[] { 0x04 });
                }
                if (member.ClassID == 5)
                {
                    m.Write(new byte[] { 0x05 });
                }

                m.Write(BitConverter.GetBytes(swap16((ushort)member.CharachterLevel)));
                m.Write(member.Greeting);


                if (member.OnlineStatus)
                {
                    m.Write(new byte[] { 0x01 });
                }
                else
                {
                    m.Write(new byte[] { 0x00 });
                }

                m.Write(BitConverter.GetBytes(swap32((uint)member.ModelNumber)));

                m.Write(BitConverter.GetBytes(swap32((uint)member.PlayerID))); // Player ID
                m.Write(BitConverter.GetBytes(member.GuildMaster));

                membersList.Add(m.ToArray());
            }

            return(membersList);
        }
 public async Task <IList <BbsCategoryModel> > GetCategoriesAsync()
 {
     return(await Task.Run(() => DBAcess.getInstance().GetListOfBbsCategory()));
 }