예제 #1
0
    public void ReqPurchase(PackMsg pack)
    {
        ReqPurchase   data    = pack.msg.reqPurchase;
        ServerSession session = pack.session;

        GameMsg msg = new GameMsg
        {
            cmd = (int)CMD.RspPurchase
        };

        PlayerData playerData = cacheSvc.GetPlayerDataCache(session);

        //钻石不够
        if (playerData.diamond < data.costDiamond)
        {
            msg.err = (int)ErrorCode.LackCrystal;
        }
        else
        {
            playerData.diamond -= data.costDiamond;
            PshTaskProgs pshTaskPrgs = null;
            switch (data.buyType)
            {
            case 0:
                //更新任务进度
                pshTaskPrgs         = TaskSys.Instance.CalcTaskProgs(playerData, 4);
                playerData.stamina += 100;
                break;

            case 1:
                //更新任务进度
                pshTaskPrgs      = TaskSys.Instance.CalcTaskProgs(playerData, 5);
                playerData.coin += 100;
                break;
            }

            if (!cacheSvc.UpdatePlayerData(playerData.id, playerData))
            {
                msg.err = (int)ErrorCode.UpdateDBError;
            }
            else
            {
                RspPurchase rspPurchase = new RspPurchase
                {
                    buyType = data.buyType,
                    diamond = playerData.diamond,
                    coin    = playerData.coin,
                    stamina = playerData.stamina
                };
                //并包优化
                msg.rspPurchase  = rspPurchase;
                msg.pshTaskProgs = pshTaskPrgs;
            }
        }
        session.SendMsg(msg);
    }
예제 #2
0
 public ResCommon UpdatePurchase(ReqPurchase reqUpdatePurchase)
 {
     return(DBCall.UpdatePurchase(reqUpdatePurchase, StaticConst.SPUPDATEPURCHASE));
 }
예제 #3
0
 public ResCommon InsertPurchase(ReqPurchase reqPurchase)
 {
     return(DBCall.InsertPurchase(reqPurchase, StaticConst.SPINSERTPURCHASE));
 }