Example #1
0
        private static void GetRankig(ThreadClient client)
        {
            SQLQuery       sQLQuery = new SQLQuery();
            List <dynamic> dynamics = sQLQuery.SqlGetRanking();

            foreach (dynamic din in dynamics)
            {
                client.SendMessage(din);
            }
        }
Example #2
0
        private static void GetItemArsenal(ThreadClient client, int idPlayer)
        {
            SQLQuery       sQLQuery = new SQLQuery();
            List <dynamic> dynamics = sQLQuery.SqlGetItemArsenal(idPlayer);

            foreach (dynamic din in dynamics)
            {
                client.SendMessage(din);
            }
        }
Example #3
0
        private static void GetMessageChat(ThreadClient client, int sender, int receiver)
        {
            SQLQuery       sQLQuery = new SQLQuery();
            List <dynamic> dynamics = sQLQuery.SqlGetMessage(sender, receiver);

            foreach (dynamic din in dynamics)
            {
                client.SendMessage(din);
            }
        }
Example #4
0
        private static void InsertBuyItem(List <dynamic> DinBuy, ThreadClient client, Int32 idPlayer, Int32 listSize, int emerald)
        {
            if (DinBuy.Count == listSize)
            {
                bool     InsertSucess           = false;
                Int32    id_tbItem              = 0;
                Int32    amountItemPurchase     = 0;
                Int32    valueUnitItemPurchase  = 0;
                Int32    valueTotalItemPurchase = 0;
                DateTime dateTime  = DateTime.Now;
                SQLQuery sQLQuery  = new SQLQuery();
                Int32?   idPuchese = sQLQuery.SqlSetPurchase(dateTime, idPlayer);

                if (idPuchese != null)
                {
                    foreach (dynamic dynBuy in BuyList)
                    {
                        id_tbItem              = dynBuy.id_tbItem;
                        amountItemPurchase     = dynBuy.amountItemPurchase;
                        valueUnitItemPurchase  = dynBuy.valueUnitItemPurchase;
                        valueTotalItemPurchase = dynBuy.valueTotalItemPurchase;

                        InsertSucess = sQLQuery.SqlSetItemPuchase((Int32)idPuchese, id_tbItem, amountItemPurchase, valueUnitItemPurchase, valueTotalItemPurchase);
                        if (InsertSucess == false)
                        {
                            break;
                        }
                    }
                    switch (InsertSucess)
                    {
                    case true:
                        UpdateArsenal(client, idPlayer, DinBuy, emerald);
                        break;

                    case false:
                        BuyPlayers.Remove(idPlayer);
                        client.SendMessage(new { Type = STORE_TYPE_SET_BUY_ERRO });
                        break;
                    }
                }
                else
                {
                    BuyPlayers.Remove(idPlayer);
                    client.SendMessage(new { Type = STORE_TYPE_SET_BUY_ERRO });
                }
            }
            else
            {
                client.SendMessage(new { Type = PROGRESSBAR_TYPE_NEXT });
            }
        }
Example #5
0
        private static void SetOffOrOnPlayer(ThreadClient client, int idPlayer, int OffOn)
        {
            SQLQuery sQLQuery = new SQLQuery();
            Boolean  OK       = sQLQuery.SqlSetOffOnLine(idPlayer, OffOn);

            switch (OK)
            {
            case true:
                Console.WriteLine("Status Gravado");
                switch (OffOn)
                {
                case 1:
                    Console.WriteLine("Client ONLINE");
                    if (MessegeOnLine.ContainsKey(idPlayer) == false)
                    {
                        MessegeOnLine.Add(idPlayer, client);
                        client.SendMessage(new
                        {
                            Type = MESSAGE_TYPE_SET_PLAYER_ON_LINE_SUCCESS
                        });
                    }
                    else
                    {
                        MessegeOnLine.Remove(idPlayer);

                        MessegeOnLine.Add(idPlayer, client);
                        client.SendMessage(new
                        {
                            Type = MESSAGE_TYPE_SET_PLAYER_ON_LINE_SUCCESS
                        });
                    }
                    break;

                case 0:
                    Console.WriteLine("Client OFFLINE");
                    if (MessegeOnLine.ContainsKey(idPlayer) == true)
                    {
                        MessegeOnLine.Remove(idPlayer);
                    }
                    break;
                }
                break;

            case false:
                Console.WriteLine("status não gravado.");
                client.SendMessage(new { Type = MESSAGE_TYPE_SET_PLAYER_ON_LINE_ERRO });
                break;
            }
            UpdateStatus(idPlayer);
        }
Example #6
0
        private static void SetNewMessage(ThreadClient client, int sender_id_tbPlayer, int receiver_id_tbPlayer, string messageMessage, DateTime dateTimeMessage, string loginSender)
        {
            SQLQuery sQLQuery = new SQLQuery();
            Boolean  OkSend   = sQLQuery.SqlInsertMenssage(sender_id_tbPlayer, receiver_id_tbPlayer, messageMessage, dateTimeMessage);
            Boolean  OK       = MessegeOnLine.ContainsKey(receiver_id_tbPlayer);

            switch (OkSend)
            {
            case true:
                switch (OK)
                {
                case true:
                    ThreadClient receiver = MessegeOnLine[receiver_id_tbPlayer];
                    string       format   = "yyyy/MM/dd HH:mm:ss";
                    string       date     = dateTimeMessage.ToString(format);
                    receiver.SendMessage(new
                    {
                        Type = MESSAGE_TYPE_NEW_MESSAGE_ONLINE,
                        loginSender,
                        sender_id_tbPlayer,
                        messageMessage,
                        date
                    });
                    break;

                case false:
                    client.SendMessage(new
                    {
                        Type    = MESSAGE_TYPE_SEVER,
                        message = "Server: Client está Offline, sua mensagem foi gravada",
                    });
                    break;
                }
                break;

            case false:
                client.SendMessage(new
                {
                    Type    = MESSAGE_TYPE_SEVER,
                    message = "Server Log: Erro ao gravar mensagem no banco de dados",
                });
                break;
            }
        }
Example #7
0
        private static void UpdatePlayer(ThreadClient client, string loginPlayer, string passwordPlayer, string secretPhresePlayer)
        {
            SQLQuery sQLQuery = new SQLQuery();
            Boolean  OK       = sQLQuery.SqlUpdatePassword(loginPlayer, passwordPlayer, secretPhresePlayer);

            switch (OK)
            {
            case true:
                client.SendMessage(new
                {
                    Type = FORGOT_PASSWORD_TYPE_RETURN_SUCCESS
                });
                break;

            case false:
                client.SendMessage(new
                {
                    Type = FORGOT_PASSWORD_TYPE_RETURN_ERROR
                });
                break;
            }
        }
Example #8
0
        private static void SetNewPlayer(ThreadClient client, string fullNamePlayer, string loginPlayer, string passwordPlayer, string secretPhresePlayer, string avatarPlayer)
        {
            SQLQuery sQLQuery = new SQLQuery();
            Boolean  OK       = sQLQuery.SqlSetNewPlayer(fullNamePlayer, loginPlayer, passwordPlayer, secretPhresePlayer, avatarPlayer);

            switch (OK)
            {
            case true:
                client.SendMessage(new
                {
                    Type = REGISTER_TYPE_RETURN_SUCCESS
                });
                break;

            case false:
                client.SendMessage(new
                {
                    Type = REGISTER_TYPE_RETURN_ERROR
                });
                break;
            }
        }
Example #9
0
        private static void UpdateArsenal(ThreadClient client, int idPlayer, List <dynamic> DinBuy, int emerald)
        {
            Console.WriteLine("ARSENAL_TYPE_GET_ITEM");
            Boolean  InsertSucess       = false;
            Int32    id_tbItem          = 0;
            Int32    amountItemPurchase = 0;
            SQLQuery sQLQuery           = new SQLQuery();

            foreach (dynamic dynBuy in BuyList)
            {
                id_tbItem          = dynBuy.id_tbItem;
                amountItemPurchase = dynBuy.amountItemPurchase;

                InsertSucess = sQLQuery.SqlSetOrUpdateArsenal(idPlayer, id_tbItem, amountItemPurchase);
                if (InsertSucess == false)
                {
                    break;
                }
            }
            if (InsertSucess == true)
            {
                BuyPlayers.Remove(idPlayer);
                if (SetEmeraldUpdatePlayer(client, idPlayer, emerald) == true)
                {
                    GetItemArsenal(client, idPlayer);
                    client.SendMessage(new { Type = STORE_TYPE_SET_BUY_SUCCESS });
                }
                else
                {
                    client.SendMessage(new { Type = ARSENAL_TYPE_GET_ITEM_ERRO });
                }
            }
            else
            {
                client.SendMessage(new { Type = ARSENAL_TYPE_GET_ITEM_ERRO });
            }
        }
Example #10
0
        private static Boolean SetEmeraldUpdatePlayer(ThreadClient client, int idPlayer, int emerald)
        {
            SQLQuery sQLQuery = new SQLQuery();

            return(sQLQuery.SqlUpdateEmaraldPlayer(idPlayer, emerald));
        }