コード例 #1
0
        public override void Execute(Level level)
        {
            var rd = (ResourceData)ObjectManager.DataTables.GetDataById(m_vResourceId);

            if (rd != null)
            {
                if (m_vResourceCount >= 1)
                {
                    if (!rd.PremiumCurrency)
                    {
                        var avatar            = level.GetPlayerAvatar();
                        var diamondCost       = GamePlayUtil.GetResourceDiamondCost(m_vResourceCount, rd);
                        var unusedResourceCap = avatar.GetUnusedResourceCap(rd);
                        if (m_vResourceCount <= unusedResourceCap)
                        {
                            if (avatar.HasEnoughDiamonds(diamondCost))
                            {
                                avatar.UseDiamonds(diamondCost);
                                avatar.CommodityCountChangeHelper(0, rd, m_vResourceCount);
                                if (m_vIsCommandEmbedded >= 1)
                                {
                                    ((Command)m_vCommand).Execute(level);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 internal override void Process()
 {
     if (Depth >= MaxEmbeddedDepth)
     {
         IPEndPoint r = this.Device.Socket.RemoteEndPoint as IPEndPoint;
         ConnectionBlocker.AddNewIpToBlackList(r.Address.ToString());
         ResourcesManager.DropClient(this.Device.Socket.Handle);
     }
     else
     {
         var rd = (ResourceData)CSVManager.DataTables.GetDataById(m_vResourceId);
         if (rd != null)
         {
             if (m_vResourceCount >= 1)
             {
                 if (!rd.PremiumCurrency)
                 {
                     var avatar            = this.Device.Player.Avatar;
                     var diamondCost       = GamePlayUtil.GetResourceDiamondCost(m_vResourceCount, rd);
                     var unusedResourceCap = avatar.GetUnusedResourceCap(rd);
                     if (m_vResourceCount <= unusedResourceCap)
                     {
                         if (avatar.HasEnoughDiamonds(diamondCost))
                         {
                             avatar.UseDiamonds(diamondCost);
                             avatar.CommodityCountChangeHelper(0, rd, m_vResourceCount);
                             if (m_vIsCommandEmbedded)
                             {
                                 int     CommandID = this.Reader.ReadInt32();
                                 Command _Command  =
                                     Activator.CreateInstance(CommandFactory.Commands[CommandID], this.Reader,
                                                              this.Device, CommandID) as Command;
                                 if (_Command != null)
                                 {
                                     _Command.Decode();
                                     _Command.Process();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
        public override void Execute(Level level)
        {
            if (Depth >= MaxEmbeddedDepth)
            {
                IPEndPoint r = level.GetClient().Socket.RemoteEndPoint as IPEndPoint;
                ConnectionBlocker.AddNewIpToBlackList(r.Address.ToString());
                ResourcesManager.DropClient(level.GetClient().Socket.Handle.ToInt64());
            }
            else
            {
                var rd = (ResourceData)CSVManager.DataTables.GetDataById(m_vResourceId);
                if (rd != null)
                {
                    if (m_vResourceCount >= 1)
                    {
                        if (!rd.PremiumCurrency)
                        {
                            var avatar            = level.GetPlayerAvatar();
                            var diamondCost       = GamePlayUtil.GetResourceDiamondCost(m_vResourceCount, rd);
                            var unusedResourceCap = avatar.GetUnusedResourceCap(rd);
                            if (m_vResourceCount <= unusedResourceCap)
                            {
                                if (avatar.HasEnoughDiamonds(diamondCost))
                                {
                                    avatar.UseDiamonds(diamondCost);
                                    avatar.CommodityCountChangeHelper(0, rd, m_vResourceCount);
                                    if (m_vIsCommandEmbedded)
                                    {
                                        Depth++;

                                        if (Depth >= MaxEmbeddedDepth)
                                        {
                                            throw new ArgumentException(
                                                      "A command contained embedded command depth was greater than max embedded commands.");
                                        }

                                        ((Command)m_vCommand).Execute(level);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public override void Execute(Level level)
        {
            var rd = (ResourceData)ObjectManager.DataTables.GetDataById(m_vResourceId);

            if (rd != null)
            {
                if (m_vResourceCount >= 1)
                {
                    if (!rd.PremiumCurrency)
                    {
                        var avatar            = level.GetPlayerAvatar();
                        var diamondCost       = GamePlayUtil.GetResourceDiamondCost(m_vResourceCount, rd);
                        var unusedResourceCap = avatar.GetUnusedResourceCap(rd);
                        if (m_vResourceCount <= unusedResourceCap)
                        {
                            if (avatar.HasEnoughDiamonds(diamondCost))
                            {
                                avatar.UseDiamonds(diamondCost);
                                avatar.CommodityCountChangeHelper(0, rd, m_vResourceCount);
                                if (m_vIsCommandEmbedded)
                                {
                                    Depth++;

                                    if (Depth >= MaxEmbeddedDepth)
                                    {
                                        throw new ArgumentException(
                                                  "A command contained embedded command depth was greater than max embedded commands.");
                                    }

                                    ((Command)m_vCommand).Execute(level);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        public override void Execute(Level level)
        {
            if (Depth >= 10)
            {
                //TODO: Block Exploitor's IP.
                ResourcesManager.DropClient(level.GetClient().GetSocketHandle());
            }
            else
            {
                ResourceData dataById = (ResourceData)CSVManager.DataTables.GetDataById(m_vResourceId);
                if (dataById == null || m_vResourceCount < 1 || dataById.PremiumCurrency)
                {
                    return;
                }

                ClientAvatar avatar = level.GetPlayerAvatar();
                int          resourceDiamondCost = GamePlayUtil.GetResourceDiamondCost(m_vResourceCount, dataById);
                if (m_vResourceCount > avatar.GetUnusedResourceCap(dataById) || !avatar.HasEnoughDiamonds(resourceDiamondCost))
                {
                    return;
                }

                avatar.UseDiamonds(resourceDiamondCost);
                avatar.CommodityCountChangeHelper(0, (Data)dataById, m_vResourceCount);
                if (!m_vIsCommandEmbedded)
                {
                    return;
                }

                if (m_vIsCommandEmbedded && m_vCommand != null)
                {
                    var cmd = (Command)m_vCommand;
                    cmd.Execute(level);
                }
            }
        }