コード例 #1
0
        public void PlayerPangControlLocker(GPlayer player, Packet packet)
        {
            //120 =você inseriu um valor maior do que o permitido
            //111 = valor de entrada maior do que o que você tem
            //100 falhou
            //101 falied
            void SendCode(uint Code = 0)
            {
                player.Response.Write(new byte[] { 0x71, 0x01, });
                player.Response.Write(Code);
                player.SendResponse();
            }

            var Action = packet.ReadByte();
            var Pang   = packet.ReadUInt64();

            bool Check()
            {
                return(player.GetPang <= 0 || Pang <= 0);
            }

            try
            {
                if (!Check())
                {
                    SendCode(110);
                }
                else
                {
                    SendCode();
                    switch (Action)
                    {
                    case 0:     //puxa pangs
                    {
                        try
                        {
                            if (player.RemoveLockerPang((uint)Pang))
                            {
                                player.AddPang((uint)Pang);
                            }
                        }
                        catch
                        {
                            SendCode(100);
                            return;
                        }
                    }
                    break;

                    case 1:      //guarda pangs
                    {
                        try
                        {
                            if (player.RemovePang((uint)Pang))
                            {
                                player.AddLockerPang((uint)Pang);
                            }
                        }
                        catch
                        {
                            SendCode(100);
                            return;
                        }
                    }
                    break;
                    }

                    //reload pangs(reenvia os pangs na caixa de pangs do client)
                    player.SendPang();

                    //SendPangs in dolfine(envia os pangs na caixa do dolfine)
                    player.SendLockerPang();
                    var _db = new PangyaEntities();
                    _db.ProcSavePersonalLog((int)player.GetUID, Action, (int)player.LockerPang);
                }
            }
            catch
            {
                SendCode(100);
            }
        }