コード例 #1
0
        public bool HandleTransaction(PUTInventoryItemTransactionStart transactionStart, PUTInventoryItemTransactionEnd transactionEnd)
        {
            Hashtable tagHash = transactionStart.tag as Hashtable;
            string    inapId  = tagHash.GetValue <string>((int)SPC.InapId, string.Empty);
            int       price   = tagHash.GetValue <int>((int)SPC.Price, 0);

            if (!transactionEnd.success)
            {
                SendInapStatusUpdate(transactionStart.gameRefID, inapId, price, false);
                return(false);
            }

            switch ((PostTransactionAction)transactionStart.postTransactionAction)
            {
            case PostTransactionAction.RemoveNebulaCredits: {
                var databaseUser = m_Application.GetUser(new GameRefId(transactionStart.gameRefID));
                if (databaseUser == null)
                {
                    SendInapStatusUpdate(transactionStart.gameRefID, inapId, price, false);
                    return(false);
                }

                databaseUser.RemoveNebulaCredits(price);
                m_Application.SaveUser(databaseUser);
                SendInapStatusUpdate(transactionStart.gameRefID, inapId, price, true);
                SendNebulaCreditsUpdateEvent(transactionStart.gameRefID, databaseUser.nebulaCredits);
                return(true);
            }
            break;
            }
            return(false);
        }
コード例 #2
0
ファイル: S2SMethodInvoker.cs プロジェクト: OlegGelezcov/neb
        public object AddNebulaCredits(string login, string gameRefId, string characterId, int nebulaCredits)
        {
            logger.Info($"{LOG_TAG} => AddNebulaCredits({login}, {gameRefId}, {characterId}, {nebulaCredits})");
            GameRefId   gameRef = new GameRefId(gameRefId);
            DbUserLogin user    = application.GetUser(gameRef);

            if (user == null)
            {
                return((int)ReturnCode.Fatal);
            }
            user.nebulaCredits += nebulaCredits;
            if (user.nebulaCredits < 0)
            {
                user.nebulaCredits = 0;
            }
            application.SaveUser(user);
            application.LogedInUsers.SendEvent(gameRef, new Photon.SocketServer.EventData((byte)LoginEventCode.NebulaCreditsUpdate, new NebulaCreditsUpdateEvent {
                nebulaCredits = user.nebulaCredits
            }));
            return((int)ReturnCode.Ok);
        }