Exemple #1
0
        private void OnRecvSellSilver(IChannel channel, Message message)
        {
            Console.WriteLine("OnRecvSellSilver");
            CSellSilver request = message as CSellSilver;
            Player      player  = (Player)channel.GetContent();
            ConnectDB   connect = new ConnectDB();
            int         result;

            player.SilverNum = request.silverCoin;
            result           = connect.UpdateSilverNum(player.user, request.silverCoin);
            if (result == 0)
            {
                Console.WriteLine("update silverNum failure");
            }

            if (request.sellAll)
            {
                // delete goods from package
                result = connect.DBDeleteFromPackage(player.user, request.goods);
                if (result == 0)
                {
                    Console.WriteLine("delete silver goods failure");
                }
            }
            else
            {
                // modify the goods number in package
                result = connect.UpdateTreasureNum(player.user, request.goods, request.remainNum);
                if (result == 0)
                {
                    Console.WriteLine("update silver goodsNum failure");
                }
            }
        }
Exemple #2
0
        private void OnRecvSellGold(IChannel channel, Message message)
        {
            Console.WriteLine("OnRecvSellGold");
            CSellGold request = message as CSellGold;
            Player    player  = (Player)channel.GetContent();
            ConnectDB connect = new ConnectDB();
            int       result;

            string goodsName  = request.goods;
            string playerName = player.user;
            int    goodPrice  = request.price;

            // delete from package
            result = connect.DBDeleteFromPackage(playerName, goodsName);
            if (result == 0)
            {
                Console.WriteLine("delete gold goods from package failure");
            }

            // add to mall
            DTreasureMall tmp = new DTreasureMall()
            {
                ownerName = playerName, price = goodPrice, isGold = true
            };

            backMall.Add(goodsName, tmp);
            result = connect.DBAddToMall(goodsName, playerName, true, goodPrice);
            if (result == 0)
            {
                Console.WriteLine("add gold goods to mall failure");
            }
        }
Exemple #3
0
        private void OnRecvUseHp(IChannel channel, Message message)
        {
            Console.WriteLine("OnRecvUseHp");
            CUseHp    msg     = message as CUseHp;
            Player    player  = (Player)channel.GetContent();
            ConnectDB connect = new ConnectDB();

            if (msg.toDelete)
            {
                connect.DBDeleteFromPackage(player.user, "Elixir_3");
            }
            else
            {
                connect.UpdateTreasureNum(player.user, "Elixir_3", msg.ownNum);
            }
        }