Beispiel #1
0
        private static void OnBuyChampion(NetSessionBase session, IMessage message, object[] args)
        {
            CSUser user           = ( CSUser )args[0];
            int    moneyResult    = ( int )args[1];
            int    diamonedResult = ( int )args[2];
            int    cid            = ( int )args[3];

            Protos.CS2GC_BuyChampionRet response   = (Protos.CS2GC_BuyChampionRet)args[4];
            Protos.DB2CS_BuyChampionRet dbResponse = (Protos.DB2CS_BuyChampionRet)message;
            if (dbResponse.Result == Protos.Global.Types.ECommon.Failed)
            {
                response.Result = Protos.CS2GC_BuyChampionRet.Types.Result.Failed;
            }
            else
            {
                user.money    = moneyResult;
                user.diamoned = diamonedResult;
                user.champions.Add(cid);
                response.Result   = Protos.CS2GC_BuyChampionRet.Types.Result.Success;
                response.Money    = user.money;
                response.Diamoned = user.diamoned;
                response.Cids.AddRange(user.champions);
            }
            user.Send(response);
        }
Beispiel #2
0
        public ErrorCode OnCs2DbBuyChampion(NetSessionBase session, Google.Protobuf.IMessage message)
        {
            Protos.CS2DB_BuyChampion    request = (Protos.CS2DB_BuyChampion)message;
            Protos.DB2CS_BuyChampionRet resp    = ProtoCreator.R_CS2DB_BuyChampion(request.Opts.Pid);
            string    cids      = string.Join('|', request.Cids);
            string    str       = $"UPDATE account_user SET money={request.Money},diamoned={request.Diamoned},champions={cids} where id={request.Ukey}";
            ErrorCode errorCode = DB.instance.accountDB.SqlExecNonQuery(str, out _, out uint _);

            switch (errorCode)
            {
            case ErrorCode.Success:
                request.Result = Protos.Global.Types.ECommon.Success;
                break;

            default:
                request.Result = Protos.Global.Types.ECommon.Failed;
                break;
            }
            session.Send(resp);
            return(ErrorCode.Success);
        }